public void move(HexPosition[] path)
    {
        if (path.Length < 2)
        {
            state = State.ATTACK;
            return;
        }

        HexPosition destination = path [path.Length - 1];

        this.path = new Vector3[path.Length];
        for (int i = 0; i < path.Length; ++i)
        {
            this.path [i] = path [i].getPosition();
        }
        state = State.ATTACK;
        if (destination.containsKey("Unit"))
        {
            print("ERROR: Space occupied.");
            moveComplete();
            return;
        }
        position.remove("Unit");
        destination.add("Unit", this);
        //transform.position = desitination.getPosition();
        t        = 0;
        n        = 0;
        moving   = true;
        position = destination;
    }
 public void undoMovement(HexPosition pos)
 {
     state = State.MOVE;
     position.remove("Unit");
     pos.add("Unit", this);
     SetPosition(pos);
     moving = false;
 }
Example #3
0
 public void Respawn(HexPosition a_position, int a_heading = Heading.N)
 {
     hitPoints = hitPointsMax;
     hexPos    = a_position;
     heading   = a_heading;
     altitude  = altitudeBase;
     speed     = speedMax;
     hexPos.add(GameBoard.KEY_UNIT_AIR, this);
 }
Example #4
0
    void Generate()
    {
        traversiblePositions = new List <HexPosition>();

        for (int x = 0; x < size.x; x++)
        {
            for (int y = 0; y < size.y; y++)
            {
                int terrainIdx   = Random.Range(0, terrainTypes.Length - 1);
                int heightOffset = Random.Range(0, 3);

                //Vector3 pos = new Vector3(x, 0, y);
                HexPosition newTile = new HexPosition(x, y);

                Vector3 newPos = newTile.getPosition();
                newPos.y = heightOffset * 0.08f;

                GameObject terrainInstance = Instantiate(terrainTypes[terrainIdx], newPos, Quaternion.Euler(0, 30, 0), this.transform);
                newTile.add("Terrain", terrainInstance);
                traversiblePositions.Add(newTile);
            }
        }
    }
 public void SetPosition(HexPosition position)
 {
     this.position      = position;
     transform.position = position.getPosition();
     position.add("Unit", this);
 }
Example #6
0
 public void UpdatePositionTo(HexPosition pos)
 {
     hexPos.remove(GameBoard.KEY_UNIT_AIR);
     hexPos = pos;
     hexPos.add(GameBoard.KEY_UNIT_AIR, this);
 }
Example #7
0
 public void start_at(HexPosition destination)
 {
     destination.add ("Unit", this);
     this.moving = true;
     this.position = destination;
 }
Example #8
0
 public void move(HexPosition desitination, HexPosition[] path)
 {
     this.path = new Vector3[path.Length];
     for (int i = 0; i < path.Length; ++i) {
         this.path[i] = path[i].getPosition();
     }
     state = State.ATTACK;
     if (desitination.containsKey ("Unit")) {
         print ("Space occupied.");
         grid.actionComplete();
         return;
     }
     position.remove ("Unit");
     desitination.add ("Unit", this);
     //transform.position = desitination.getPosition();
     t = 0;
     n = 0;
     moving = true;
     position = desitination;
 }