Example #1
0
    public override void Update(Battle battle)
    {
        base.Update(battle);
        var tile = battle.map.mouse.tileUnderMouse;

        if (tile != null && _tileUnderMouse != tile)   // new tile under mouse
        {
            _tileUnderMouse = tile;
            if (_battler.hasMoveAction && _pathFinder.CostToTile(tile) <= _battler.MoveRange)
            {
                _movePath = _pathFinder.PathToTile(tile);
            }
            else
            {
                _movePath = null;
            }
            if (_movePath != null)
            {
                _overlay.DrawPath(_movePath);
            }
        }

        if (Input.GetMouseButtonUp(0))
        {
            if (tile.battler != null)
            {
                battle.states.Push(new SelectFeat(_battler, tile));
            }
            else if (_movePath != null)
            {
                battle.states.Push(new MoveUnit(_battler, _movePath));
            }
            else
            {
                battle.states.Pop();
            }
        }
    }