Exemplo n.º 1
0
 public void ToggleUnitIndicator(Unit u)
 {
     if (turn_manager.current_state == state_player)
     {
         UnitCastIndicator.ToggleUnit(u);
     }
 }
Exemplo n.º 2
0
    public bool listenInput()
    {
        bool validInput = false;

        castedSpell = false;
        //Keyboard
        if (Input.GetKey("w"))
        {
            validInput     = true;
            current_target = Direction.Up;
        }
        else if (Input.GetKey("a"))
        {
            current_target = Direction.Left;
            validInput     = true;
        }
        else if (Input.GetKey("s"))
        {
            current_target = Direction.Down;
            validInput     = true;
        }
        else if (Input.GetKey("d"))
        {
            current_target = Direction.Right;
            validInput     = true;
        }
        else if (Input.GetKey("space"))         //skips turn
        {
            current_target = Direction.None;
            validInput     = true;
        }
        else if (Input.GetKeyUp("1"))
        {
            spellIndicator.toggleIndicator();
            PlayerCastIndicator.ToggleUnit(this);
            current_target = Direction.None;
        }
        else
        {
            current_target = Direction.None;
        }

        //Check to see if player is going somewhere invalid
        int newX = 0, newY = 0;

        switch (current_target)
        {
        case Direction.Down:
            newX = Map_position_x;
            newY = Map_position_y - 1;
            if (MapTools.IsOutOfBounds(newX, newY))
            {
                current_target = Direction.None;
                validInput     = false;
            }
            else
            {
                if ((GameTools.Map.map_unit_occupy[newX, newY] != null &&
                     !GameTools.Map.map_unit_occupy[newX, newY].IsEntityAbleToMoveHere(this)) ||
                    GameTools.Base.IsMovingOnTurret(newX, newY) ||
                    (!TileTools.IsLand(GameTools.Map.TileMapData[newX, newY])))
                {
                    current_target = Direction.None;
                    validInput     = false;
                }
            }
            break;

        case Direction.Up:
            newX = Map_position_x;
            newY = Map_position_y + 1;
            if (MapTools.IsOutOfBounds(newX, newY))
            {
                current_target = Direction.None;
                validInput     = false;
            }
            else
            {
                if ((GameTools.Map.map_unit_occupy[newX, newY] != null &&
                     !GameTools.Map.map_unit_occupy[newX, newY].IsEntityAbleToMoveHere(this)) ||
                    GameTools.Base.IsMovingOnTurret(newX, newY) ||
                    (!TileTools.IsLand(GameTools.Map.TileMapData[newX, newY])))
                {
                    current_target = Direction.None;
                    validInput     = false;
                }
            }
            break;

        case Direction.Left:
            newX = Map_position_x - 1;
            newY = Map_position_y;
            if (MapTools.IsOutOfBounds(newX, newY))
            {
                current_target = Direction.None;
                validInput     = false;
            }
            else
            {
                if ((GameTools.Map.map_unit_occupy[newX, newY] != null &&
                     !GameTools.Map.map_unit_occupy[newX, newY].IsEntityAbleToMoveHere(this)) ||
                    GameTools.Base.IsMovingOnTurret(newX, newY) ||
                    (!TileTools.IsLand(GameTools.Map.TileMapData[newX, newY])))
                {
                    current_target = Direction.None;
                    validInput     = false;
                }
            }
            break;

        case Direction.Right:
            newX = Map_position_x + 1;
            newY = Map_position_y;
            if (MapTools.IsOutOfBounds(newX, newY))
            {
                current_target = Direction.None;
                validInput     = false;
            }
            else
            {
                if ((GameTools.Map.map_unit_occupy[newX, newY] != null &&
                     !GameTools.Map.map_unit_occupy[newX, newY].IsEntityAbleToMoveHere(this)) ||
                    GameTools.Base.IsMovingOnTurret(newX, newY) ||
                    (!TileTools.IsLand(GameTools.Map.TileMapData[newX, newY])))
                {
                    current_target = Direction.None;
                    validInput     = false;
                }
            }
            break;

        case Direction.None:
            break;
        }

        //Mouse
        if (Input.GetMouseButtonDown(0))
        {
            if (spellIndicator.IsShowingIndicator)
            {
                validInput = CastMainSpell();
            }
        }
        return(validInput);
    }