Beispiel #1
0
    void OnTriggerStay(Collider otherCollider)
    {
        if (!PushingEnabled)
        {
            return;
        }
        if (_isSliding || _hasFinishedSliding)
        {
            return;
        }

        GameObject other = otherCollider.gameObject;

        if (!CommonObjects.IsPlayer(other))
        {
            return;
        }
        if (requiresPowerBracelet && !Inventory.Instance.HasItem("PowerBracelet"))
        {
            return;
        }

        Player          player = CommonObjects.Player_C;
        IndexDirection2 dir    = GetPushDirection(player);

        if (!dir.IsZero())
        {
            Slide(dir);
        }
    }
Beispiel #2
0
    void SetNextMoveDirection()
    {
        Vector3 p = transform.position;

        IndexDirection2 newMoveDir = IndexDirection2.zero;

        if (MoveDirection_Tile.IsDown())
        {
            if (p.z <= Boundary.yMin)
            {
                newMoveDir = IndexDirection2.up;
            }
        }
        else if (MoveDirection_Tile.IsUp())
        {
            if (p.z >= Boundary.yMax)
            {
                newMoveDir = (Extensions.FlipCoin()) ? IndexDirection2.left : IndexDirection2.right;
            }
        }
        else
        {
            if (Extensions.FlipCoin(chanceToMoveDown))
            {
                newMoveDir = IndexDirection2.down;
            }
            else
            {
                if (MoveDirection_Tile.IsRight())
                {
                    if (p.x >= Boundary.xMax)
                    {
                        newMoveDir = IndexDirection2.left;
                    }
                }
                else if (MoveDirection_Tile.IsLeft())
                {
                    if (p.x <= Boundary.xMin)
                    {
                        newMoveDir = IndexDirection2.right;
                    }
                }
            }
        }

        if (newMoveDir.IsZero())
        {
            newMoveDir = MoveDirection_Tile;
        }

        MoveDirection_Tile = newMoveDir;
    }
Beispiel #3
0
    public bool TryMoveCursor(IndexDirection2 dir)
    {
        if (dir.IsZero() || _cursorCooldownActive)
        {
            return(false);
        }

        Index2 n = _cursorIndex + dir;

        if (wraps)
        {
            if (n.x < 0)
            {
                n.x += numColumns;
            }
            else if (n.x >= numColumns)
            {
                n.x -= numColumns;
            }

            if (n.y < 0)
            {
                n.y += numRows;
            }
            else if (n.y >= numRows)
            {
                n.y -= numRows;
            }
        }

        CursorIndex = n;

        StartCursorCooldownTimer();

        return(true);
    }