コード例 #1
0
 public void DisplayText(int playerNum, ActionType action, GameModel.Piece piece1, GameModel.Piece piece2)
 {
     if (action != ActionType.Swap || action != ActionType.Transform)
     {
         Debug.LogError("Wrong function called to display given actions");
         return;
     }
     m_textArea.GetComponent <Text>().text += "\n" + "Player " + playerNum + " "
                                              + GetString.GetStr(action) + " "
                                              + GetString.GetStr(piece1.Type)
                                              + (action == ActionType.Swap ? " and " : " to ")
                                              + GetString.GetStr(piece2.Type);
 }
コード例 #2
0
        // Opens an action menu (from 1 to 4 actions) on front/around a given piece, containing given actions
        public void OpenActionMenu(GameModel.Piece piece, List <ActionType> actions)
        {
            int menuType = actions.Count - 1;

            // Setting buttons' sprites and tag
            for (int i = 0; i < menuType; i++)
            {
                m_menuArray[menuType].transform.GetChild(i).GetComponent <ActionButton>().Type = actions[i];
            }

            m_menuArray[menuType].transform.position = Board.Instance().GetPieceState(piece).transform.position + Vector3.one;
            m_menuArray[menuType].SetActive(true);
        }
コード例 #3
0
        public void DisplayText(int playerNum, ActionType action, GameModel.Piece piece, GameModel.Square toSqr)
        {
            if (action != ActionType.Create || action != ActionType.Move)
            {
                Debug.LogError("Wrong function called to display given actions");
                return;
            }

            m_textArea.GetComponent <Text>().text =
                "\n" + "Player " + playerNum + " "
                + GetString.GetStr(action) + " "
                + GetString.GetStr(piece.Type) + " to "
                + GetString.GetStr(toSqr);
        }
コード例 #4
0
        // Adds a miniature of a given piece to the its enemy's captured pieces panel
        public void AddCapturedPiece(GameModel.Piece piece)
        {
            GameObject childObj            = null;
            string     captPieceSpritePath = GetString.GetStr(piece.Type) + " ";
            string     captPieceText       = "";
            int        numPiece;

            if (piece.Color == Color.Black)
            {
                captPieceSpritePath += "A1.png";

                for (int i = 0; i < m_blackCapturedPieces.transform.childCount; i++)
                {
                    childObj      = m_blackCapturedPieces.transform.GetChild(i).gameObject;
                    captPieceText = childObj.transform.GetChild(0).gameObject.GetComponent <Text>().text;
                    numPiece      = captPieceText[1];

                    if (childObj.GetComponent <Image>().sprite.name == "blackPiece.png")
                    {
                        childObj.GetComponent <Image>().sprite = Resources.Load <Sprite>(captPieceSpritePath);
                        childObj.SetActive(true);
                    }
                    else if (childObj.GetComponent <Image>().sprite.name == captPieceSpritePath)
                    {
                        captPieceText = captPieceText.Replace((char)numPiece, (char)++numPiece);
                        if (!childObj.transform.GetChild(0).gameObject.activeInHierarchy)
                        {
                            childObj.transform.GetChild(0).gameObject.SetActive(true);
                        }
                    }
                }
            }

            if (piece.Color == Color.White)
            {
                captPieceSpritePath += "B1.png";

                for (int i = 0; i < m_whiteCaptpuredPieces.transform.childCount; i++)
                {
                    childObj      = m_whiteCaptpuredPieces.transform.GetChild(i).gameObject;
                    captPieceText = childObj.transform.GetChild(0).gameObject.GetComponent <Text>().text;
                    numPiece      = captPieceText[1];

                    if (childObj.GetComponent <Image>().sprite.name == "blackPiece.png")
                    {
                        childObj.GetComponent <Image>().sprite = Resources.Load <Sprite>(captPieceSpritePath);
                        childObj.SetActive(true);
                    }
                    else if (childObj.GetComponent <Image>().sprite.name == captPieceSpritePath)
                    {
                        captPieceText = captPieceText.Replace((char)numPiece, (char)++numPiece);
                        if (!childObj.transform.GetChild(0).gameObject.activeInHierarchy)
                        {
                            childObj.transform.GetChild(0).gameObject.SetActive(true);
                        }
                    }
                }
            }

            if (childObj != null)
            {
                childObj.transform.GetChild(0).GetComponent <Text>().text = captPieceText;
            }
            else
            {
                Debug.LogError("Error in AddCapturedPiece() : ChildObj cannot be null");
                // ReSharper disable once RedundantJumpStatement
                return;
            }
        }