예제 #1
0
    public bool Turn(Field.Tile target)
    {
        if (tile == null || target == null)
        {
            return(false);
        }
        if (target == tile.left)
        {
            direction = Field.Directions.LEFT;
        }
        else
        if (target == tile.right)
        {
            direction = Field.Directions.RIGHT;
        }
        else
        if (target == tile.up)
        {
            direction = Field.Directions.UP;
        }
        else
        if (target == tile.down)
        {
            direction = Field.Directions.DOWN;
        }
        else
        {
            return(false);
        }

        _face.UpdateDirectionView(direction);
        return(true);
    }
예제 #2
0
    public void UpdateDirectionView(Field.Directions direction)
    {
        HideAll();

        switch (direction)
        {
        case Field.Directions.UP:
            _bottomDir.Show();
            break;

        case Field.Directions.DOWN:
            _topDir.Show();
            break;

        case Field.Directions.LEFT:
            _leftDir.Show();
            break;

        case Field.Directions.RIGHT:
            _rightDir.Show();
            break;

        default:
            break;
        }
    }
예제 #3
0
    public override bool MoveByDirection(Field.Directions direction)
    {
        var isValid = base.MoveByDirection(direction);

        if (uses_curtain && tile.type != Field.Tile.TileTypes.CURTAIN)
        {
            GlobalEventSystem.RaiseCurtainLeave(tile);
        }

        return(isValid);
    }
예제 #4
0
    public virtual bool MoveByDirection(Field.Directions direction)
    {
        var isvalid = Move(direction);

        if (isvalid)
        {
            _SetPosition(tile.tileView.transform.position, true);
        }

        return(isvalid);
    }
예제 #5
0
    public virtual bool ForceMoveByDirection(Field.Directions direction)
    {
        var isvalid = ForceMove(direction);

        _face.UpdateDirectionView(direction);

        if (isvalid)
        {
            _SetPosition(tile.tileView.transform.position, true);
        }

        return(isvalid);
    }
예제 #6
0
    public override bool Move(Field.Directions direction)
    {
        if (movement_disabled)
        {
            this.direction = direction;
            return(false);
        }
        bool is_valid = base.Move(direction);

        if (is_valid)
        {
            FieldUpdate();
        }
        return(is_valid);
    }
예제 #7
0
    public virtual bool Move(Field.Directions direction)
    {
        //Debug.Log( "Move called by " + GetInstanceID() );
        if (tile == null)
        {
            return(false);
        }
        Field.Tile target;
        switch (direction)
        {
        case Field.Directions.UP:
            target = tile.up;
            break;

        case Field.Directions.DOWN:
            target = tile.down;
            break;

        case Field.Directions.LEFT:
            target = tile.left;
            break;

        case Field.Directions.RIGHT:
            target = tile.right;
            break;

        default:
            target = null;
            break;
        }
        this.direction = direction;
        if (target != null)
        {
            if (this == GlobalDataHolder.player)
            {
                target.Activate();
            }
            if ((target.passable) && target.unit == null)
            {
                //Debug.Log( "Moved from (" + tile.x.ToString() + ";" + tile.y.ToString() + ") to (" + target.x.ToString() + ";" + target.y.ToString() +")");
                target.unit = this;
                tile.unit   = null;
                tile        = target;
                return(true);
            }
        }
        return(false);
    }
예제 #8
0
    public virtual bool Move(Field.Directions direction)
    {
        if (tile == null)
        {
            return(false);
        }
        Field.Tile target;
        switch (direction)
        {
        case Field.Directions.UP:
            target = tile.up;
            break;

        case Field.Directions.DOWN:
            target = tile.down;
            break;

        case Field.Directions.LEFT:
            target = tile.left;
            break;

        case Field.Directions.RIGHT:
            target = tile.right;
            break;

        default:
            target = null;
            break;
        }
        this.direction = direction;
        if (target != null && target.unit == null)
        {
            if (target.type == Field.Tile.TileTypes.ROAD)
            {
                target.unit = this;
                tile.unit   = null;
                tile        = target;
                return(true);
            }
            else
            {
                Action(target);
                return(true);
            }
        }
        return(false);
    }
예제 #9
0
        public Tile this[Field.Directions direction]
        {
            get
            {
                switch (direction)
                {
                case Field.Directions.UP:
                    return(up);

                case Field.Directions.DOWN:
                    return(down);

                case Field.Directions.LEFT:
                    return(left);

                case Field.Directions.RIGHT:
                    return(right);

                default:
                    return(null);
                }
            }
        }