예제 #1
0
    public virtual void MoveAlongDirection(Direction direction, float _speed)
    {
        Vector3Int toAdd = Vector3Int.zero;

        switch (direction)
        {
        case Direction.Up:
            toAdd += new Vector3Int(0, 0, 1);
            break;

        case Direction.Down:
            toAdd += new Vector3Int(0, 0, -1);
            break;

        case Direction.Left:
            toAdd += new Vector3Int(-1, 0, 0);
            break;

        case Direction.Right:
            toAdd += new Vector3Int(1, 0, 0);
            break;

        default:
            break;
        }

        if (GridHolder.IsWalkable(pos.x + toAdd.x, pos.y + toAdd.z) == false)
        {
            return;
        }

        MakeCurrentCellWalkable();
        if (GetComponent <iTween>())
        {
            Destroy(GetComponent <iTween>());
            this.transform.position = pos.GetAsBoardAlignedVector3Int();
        }
        pos.x += toAdd.x;
        pos.y += toAdd.z;

        iTween.MoveTo(this.gameObject, iTween.Hash(
                          "position", new Vector3(pos.x, this.transform.position.y, pos.y),
                          "time", _speed,
                          "easeType", iTween.EaseType.linear
                          ));


        RotateToFaceDirection(direction);
        MakeCurrentCellNotWalkable();
    }
예제 #2
0
 internal Vector3Int AsBoardOrientedVector3Int()
 {
     return(pos.GetAsBoardAlignedVector3Int());
 }