about summary refs log tree commit diff stats
path: root/data/maps/the_entry/rooms/Flipped Link Area.txtpb
blob: 5251023ba9f267ac0a16be493992957e3430bdee (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
name: "Flipped Link Area"
display_name: "Pyramid Area"
panels {
  name: "WANDER"
  path: "Panels/Pilgrimage/cream_4"
  clue: "wander"
  answer: "roam"
  symbols: SUN
}
paintings {
  name: "NEAR"
  path: "Components/Paintings/aches2"
  orientation: "north"
  gravity: Y_PLUS
  display_name: "Flipper Near Painting"
}
paintings {
  name: "FAR"
  path: "Components/Paintings/aches4"
  orientation: "south"
  gravity: Y_PLUS
  display_name: "Flipped Far Painting"
}
Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.fourisland.fourpuzzle.gamestate.mapview.viewpoint;

import com.fourisland.fourpuzzle.Game;
import com.fourisland.fourpuzzle.gamestate.mapview.Map;
import com.fourisland.fourpuzzle.gamestate.mapview.event.HeroEvent;
import java.awt.Point;

/**
 *
 * @author hatkirby
 */
public class AutomaticViewpoint implements Viewpoint {
    
    private Map map;
    private Point heroLoc = new Point();
    private Point viewpoint;
    
    public AutomaticViewpoint(Map map)
    {
        this.map = map;
        
        refresh();
    }
    
    private void refresh()
    {
        int x,y;
        
        HeroEvent hero = Game.getHeroEvent();
        heroLoc.setLocation(hero.getLocation());
        
        Point endLoc = new Point(hero.getLocation());
        if (hero.isMoving())
        {
            switch (hero.getDirection())
            {
                case North: endLoc.translate(0, -1); break;
                case West: endLoc.translate(-1, 0); break;
                case South: endLoc.translate(0, 1); break;
                case East: endLoc.translate(1, 0); break;
            }
        }
        
        if (Math.max(endLoc.x,heroLoc.x) > 10)
        {
            if (Math.max(endLoc.x,heroLoc.x) < (map.getSize().width - 9))
            {
                x = (heroLoc.x - 10) * 16;
                x += hero.getMovingX();
            } else {
                x = (map.getSize().width - 20) * 16;
            }
        } else {
            x = 0;
        }
        
        if (Math.max(endLoc.y,heroLoc.y) > 7)
        {
            if (Math.max(endLoc.y,heroLoc.y) < (map.getSize().height - 7))
            {
                y = (heroLoc.y - 7) * 16;
                y += hero.getMovingY();
            } else {
                y = (map.getSize().height - 15) * 16;
            }
        } else {
            y = 0;
        }
        
        viewpoint = new Point(x,y);
    }

    public int getX()
    {
        if (!Game.getHeroEvent().getLocation().equals(heroLoc) || Game.getHeroEvent().isMoving())
        {
            refresh();
        }
        
        return viewpoint.x;
    }

    public int getY()
    {
        if (!Game.getHeroEvent().getLocation().equals(heroLoc) || Game.getHeroEvent().isMoving())
        {
            refresh();
        }
        
        return viewpoint.y;
    }

}