public List <Pyramid_Board> GetSituatableBoards(Pyramid_BlockType blockType)
    {
        situatableBoards = new List <Pyramid_Board>();

        for (int y = maxHeight - 1; y >= 1; y--)
        {
            for (int x = 0; x < boards[y].Count; x++)
            {
                if (boards[y][x].Block == null)
                {
                    if (boards[y - 1][x].Block != null && boards[y - 1][x + 1].Block != null)
                    {
                        if (blockType == Pyramid_BlockType.Joker)
                        {
                            situatableBoards.Add(boards[y][x]);
                        }
                        else if (boards[y - 1][x].Block.BlockType == blockType || boards[y - 1][x + 1].Block.BlockType == blockType)
                        {
                            if (boards[y - 1][x].Block.BlockType != Pyramid_BlockType.Joker && boards[y - 1][x + 1].Block.BlockType != Pyramid_BlockType.Joker)
                            {
                                situatableBoards.Add(boards[y][x]);
                            }
                        }
                    }
                }
            }
        }

        situatableBoards.AddRange(boards[0].Where(board => board.Block == null));

        return(situatableBoards);
    }
Exemple #2
0
 void SetBlock(Pyramid_BlockType blockType)
 {
     //Debug.Log(Index +". SetBlock : " + blockType);
     Block = tempBlock.Spawn(cachedTransform, Vector3.zero);
     Block.Init(blockType);
     Block.cachedTransform.localScale = Vector3.one;
     Block.ShowSituateAnimation();
 }
    public void Init(Pyramid_BlockType blockType, Action <Pyramid_UIBlock> onClick)
    {
        isSelected = false;
        canSelect  = false;

        this.BlockType = blockType;
        image.sprite   = Pyramid_Main.instance.GetBlockImage(blockType);
        this.onClick   = onClick;
    }
    void CheckAndShowSituatableBoards(Pyramid_BlockType blockType)
    {
        situatableBoards = GetSituatableBoards(blockType);

        if (situatableBoards.Count == 0)
        {
            //Game End.
        }

        for (int i = 0; i < situatableBoards.Count; i++)
        {
            situatableBoards[i].ShowCanSelect(() =>
            {
                players[(int)Turn.Player].RemoveSelectedBlock();
                HideAllSituatableBoards();
                Pyramid_UIManager.instance.OnBlockSituated(Pyramid_UIManager.instance.CurrentSelectedBlock);
                NextTurn();
            });
        }
    }
Exemple #5
0
 public void SetBlockByComputer(Pyramid_BlockType blockType)
 {
     SetBlock(blockType);
     Pyramid_Main.instance.NextTurn();
 }
 public void Init(Pyramid_BlockType blockType)
 {
     BlockType    = blockType;
     image.sprite = Pyramid_Main.instance.GetBlockImage(blockType);
 }
    void GetRandomSituateType()
    {
        int randomIdx = Random.Range(0, randomTypes.Count);

        situateType = randomTypes[randomIdx];
    }
 public void OnBlockSelected(Pyramid_BlockType blockType)
 {
     HideAllSituatableBoards();
     CheckAndShowSituatableBoards(blockType);
 }
 public Sprite GetSelectedBlockImage(Pyramid_BlockType blockType)
 {
     return(blockAtlas.GetSprite(blockType.ToString() + "_Selected"));
 }
 public Sprite GetBlockImage(Pyramid_BlockType blockType)
 {
     return(blockAtlas.GetSprite(blockType.ToString()));
 }