コード例 #1
0
    private IEnumerator MoveTileAnimation(Vector2 movingTilePosition, Vector2 targetTilePosition)
    {
        CrabAnimation crab  = GetAnimationByType(AnimationType.CRAB) as CrabAnimation;
        TileBools     bools = TileGrid.s_Instance.GetTileNode((int)movingTilePosition.x, (int)movingTilePosition.y).Bools;

        crab.SetAnimation(CrabAnimation.States.Dive.ToString(), false);
        yield return(new WaitForSeconds(2f));

        crab.transform.position = movingTilePosition;
        crab.SetAnimation(CrabAnimation.States.TileTop.ToString(), false);
        CameraScreenShake.s_Instance.ShakeScreen(1f);
        TileGrid.s_Instance.DestroyNode((int)movingTilePosition.x, (int)movingTilePosition.y);
        crab.AddAnimation(CrabAnimation.States.Idle.ToString(), true);
        yield return(new WaitForSeconds(1.3f));

        crab.SetAnimation(CrabAnimation.States.Dive.ToString(), false);
        yield return(new WaitForSeconds(2f));

        TileGrid.s_Instance.PlaceNewCard((int)targetTilePosition.x, (int)targetTilePosition.y, bools.Up, bools.Right, bools.Down, bools.Left, bools.Middle, true);
        crab.transform.position = crab.RandomPosition;
        crab.SetAnimation(CrabAnimation.States.Up.ToString(), false);
        crab.AddAnimation(CrabAnimation.States.Idle.ToString(), true);
        if (s_OnActionFXCompleted != null)
        {
            s_OnActionFXCompleted();
        }
    }
コード例 #2
0
    public bool DestroyNode(int x, int y, float delay = 0)
    {
        if (!m_NodeGrid[x, y].IsEdgeStone && m_NodeGrid[x, y].IsFilled && m_NodeGrid[x, y].IsDestructable)
        {
            TileBools bools = new TileBools();
            bools.Up                  = false;
            bools.Right               = false;
            bools.Down                = false;
            bools.Left                = false;
            bools.Middle              = false;
            m_NodeGrid[x, y].Bools    = bools;
            m_NodeGrid[x, y].IsFilled = false;

            if (delay > 0)
            {
                StartCoroutine(UpdateArt(m_NodeGrid[x, y], delay));
            }
            else
            {
                m_NodeGrid[x, y].UpdateArt();
            }
            StartCoroutine(DestroyBridges(m_NodeBridges[x, y], delay));
            return(true);
        }
        else
        {
            return(false);
        }
    }
コード例 #3
0
    /// <summary>
    /// Rotates a card/node in the grid
    /// </summary>
    /// <param name="x"></param>
    /// <param name="y"></param>
    public void RotateCard(int x, int y)
    {
        TileNode  RotatingNode = m_NodeGrid[x, y];
        TileBools tempBools    = new TileBools();

        tempBools.Up     = RotatingNode.Bools.Left;
        tempBools.Right  = RotatingNode.Bools.Up;
        tempBools.Down   = RotatingNode.Bools.Right;
        tempBools.Left   = RotatingNode.Bools.Down;
        tempBools.Middle = RotatingNode.Bools.Middle;
        DestroyNode(x, y);
        PlaceNewCard(x, y, tempBools.Up, tempBools.Right, tempBools.Down, tempBools.Left, tempBools.Middle, true, true, false);
    }
コード例 #4
0
    /// <summary>
    /// Creates a new grid
    /// </summary>
    public void InstantiateNewGrid()
    {
        m_PlayerStartNodes = new TileNode[PlayersManager.s_Instance.Players.Count];
        m_NodeBridges      = new Bridges[m_GridXSize + 2, m_GridYSize + 2];
        m_NodeGrid         = new TileNode[m_GridXSize + 2, m_GridYSize + 2];
        for (int i = 0; i < m_GridXSize + 2; i++)
        {
            for (int j = 0; j < m_GridYSize + 2; j++)
            {
                TileNode  newNode   = new TileNode();
                Bridges   newbridge = new Bridges();
                TileBools bools     = new TileBools();
                newNode.IsFilled       = false;
                newNode.DebugModus     = false;
                newNode.IsDestructable = true;
                if (i == 0 || i == m_GridXSize + 1 || j == 0 || j == m_GridYSize + 1)
                {
                    newNode.IsEdgeStone    = true;
                    newNode.IsDestructable = false;
                    newNode.TileObject     = null;
                }
                else
                {
                    GameObject    tileObj     = Instantiate(m_NodeObjectPrefab, new Vector3(i, j, 0), Quaternion.identity, transform);
                    ClickedOnTile TileClicker = tileObj.GetComponent <ClickedOnTile>();
                    TileClicker.TilePosX = i;
                    TileClicker.TilePosY = j;
                    newNode.TileObject   = tileObj;
                }

                if (i == 1 && j == m_GridYSize)
                {
                    newNode.IsFilled       = true;
                    newNode.IsDestructable = false;
                    bools.Right            = true;
                    bools.Down             = true;
                    bools.Middle           = true;
                    bools.Middle           = false;
                    newNode.IsStartPoint   = true;
                    m_PlayerStartNodes[0]  = newNode;
                }
                if (i == m_GridXSize && j == 1)
                {
                    newNode.IsFilled       = true;
                    newNode.IsDestructable = false;
                    bools.Left             = true;
                    bools.Up              = true;
                    bools.Middle          = false;
                    newNode.IsFilled      = true;
                    newNode.IsStartPoint  = true;
                    m_PlayerStartNodes[1] = newNode;
                }
                if (i == 1 && j == 1 && PlayersManager.s_Instance.Players.Count >= 3)
                {
                    newNode.IsFilled       = true;
                    newNode.IsDestructable = false;
                    bools.Right            = true;
                    bools.Up              = true;
                    bools.Middle          = false;
                    newNode.IsFilled      = true;
                    newNode.IsStartPoint  = true;
                    m_PlayerStartNodes[2] = newNode;
                    Players[2].SetActive(true);
                }
                if (i == m_GridXSize && j == m_GridYSize && PlayersManager.s_Instance.Players.Count >= 4)
                {
                    newNode.IsFilled       = true;
                    newNode.IsDestructable = false;
                    bools.Left             = true;
                    bools.Down             = true;
                    bools.Middle           = false;
                    newNode.IsFilled       = true;
                    newNode.IsStartPoint   = true;
                    m_PlayerStartNodes[3]  = newNode;
                    Players[3].SetActive(true);
                }
                else if (i == (m_GridXSize + 1) / 2 && j == (m_GridYSize + 1) / 2)
                {
                    newNode.IsFilled       = true;
                    newNode.IsDestructable = false;
                    bools.Left             = true;
                    bools.Up           = true;
                    bools.Middle       = false;
                    bools.Down         = true;
                    bools.Right        = true;
                    newNode.IsFilled   = true;
                    newNode.IsEndpoint = true;
                }
                newNode.Bools = bools;
                newNode.UpdateArt();
                m_NodeGrid[i, j]    = newNode;
                m_NodeBridges[i, j] = newbridge;
            }
        }
    }
コード例 #5
0
    public bool PlaceNewCard(int x, int y, bool UpCard, bool RightCard, bool DownCard, bool LeftCard, bool MiddleCard, bool ignoreConnect = false, bool ignoreRules = false, bool playAnim = true, float delay = 0)
    {
        if (m_NodeGrid[x, y].CheckPlacement(UpCard, RightCard, DownCard, LeftCard, ignoreConnect, ignoreRules) && !m_NodeGrid[x, y].IsFilled)
        {
            float     offset;
            TileBools bools = new TileBools();
            bools.Up                  = UpCard;
            bools.Right               = RightCard;
            bools.Down                = DownCard;
            bools.Left                = LeftCard;
            bools.Middle              = MiddleCard;
            m_NodeGrid[x, y].Bools    = bools;
            m_NodeGrid[x, y].IsFilled = true;
            if (playAnim)
            {
                m_NodeGrid[x, y].TileObject.transform.position = new Vector3(x, y + TileSpawnOffsetY, 0);
                m_NodeGrid[x, y].TileObject.transform.DOMoveY(y, 0.4f);
                offset = TileSpawnOffsetY + 0.12f;
            }
            else
            {
                offset = 0.12f;
            }
            if (delay > 0)
            {
                StartCoroutine(UpdateArt(m_NodeGrid[x, y], delay));
            }
            else
            {
                m_NodeGrid[x, y].UpdateArt();
            }

            if (UpCard && m_NodeGrid[x, y].AllNeighbours.up.IsFilled && m_NodeGrid[x, y].AllNeighbours.up.Bools.Down)
            {
                GameObject Bridge = Instantiate(TileArtLib.s_Bridges[0], new Vector3(x, y + offset + 0.5f, 0), Quaternion.identity, m_NodeGrid[x, y].TileObject.transform);
                m_NodeBridges[x, y].bridgeUp       = Bridge;
                m_NodeBridges[x, y + 1].bridgeDown = Bridge;
            }
            if (RightCard && m_NodeGrid[x, y].AllNeighbours.right.IsFilled && m_NodeGrid[x, y].AllNeighbours.right.Bools.Left)
            {
                GameObject Bridge = Instantiate(TileArtLib.s_Bridges[1], new Vector3(x + 0.5f, y + offset, 0), Quaternion.identity, m_NodeGrid[x, y].TileObject.transform);
                m_NodeBridges[x, y].bridgeRight    = Bridge;
                m_NodeBridges[x + 1, y].bridgeLeft = Bridge;
            }
            if (DownCard && m_NodeGrid[x, y].AllNeighbours.down.IsFilled && m_NodeGrid[x, y].AllNeighbours.down.Bools.Up)
            {
                GameObject Bridge = Instantiate(TileArtLib.s_Bridges[0], new Vector3(x, y + offset - 0.5f, 0), Quaternion.identity, m_NodeGrid[x, y].TileObject.transform);
                m_NodeBridges[x, y].bridgeDown   = Bridge;
                m_NodeBridges[x, y - 1].bridgeUp = Bridge;
            }
            if (LeftCard && m_NodeGrid[x, y].AllNeighbours.left.IsFilled && m_NodeGrid[x, y].AllNeighbours.left.Bools.Right)
            {
                GameObject Bridge = Instantiate(TileArtLib.s_Bridges[1], new Vector3(x - 0.5f, y + offset, 0), Quaternion.identity, m_NodeGrid[x, y].TileObject.transform);
                m_NodeBridges[x, y].bridgeLeft      = Bridge;
                m_NodeBridges[x - 1, y].bridgeRight = Bridge;
            }
            return(true);
        }
        else
        {
            return(false);
        }
    }