예제 #1
0
        public void alterOnlinePlayerText(string playerName)
        {
            //Define variables
            GameObject onlinePlayerBox = GameObject.Find("OnlinePlayerContent");

            //Check if the player exists, that means we need to remove it
            if (onlinePlayerDictionary.Keys.Contains(playerName))
            {
                ourGLM.destroyObject(playerName + " Text Label");
                onlinePlayerDictionary.Remove(playerName);
            }
            else
            {
                onlinePlayerDictionary.Add(playerName, ourGLM.createObject("UI/ChatText").GetComponent <Text>());
                onlinePlayerBox.GetComponent <RectTransform>().sizeDelta = new Vector2(0, onlinePlayerDictionary.Count * 20);

                onlinePlayerDictionary[playerName].name = playerName + " Text Label";
                onlinePlayerDictionary[playerName].text = playerName;
                onlinePlayerDictionary[playerName].rectTransform.SetParent(onlinePlayerBox.GetComponent <RectTransform>());
            }
            //Update position of all PlayerNames
            int i = 0;

            foreach (string key in onlinePlayerDictionary.Keys)
            {
                onlinePlayerDictionary[key].rectTransform.offsetMin = new Vector2(9, -5 + i * 20);
                onlinePlayerDictionary[key].rectTransform.offsetMax = new Vector2(0, 15 + i * 20);
                //onlinePlayerDictionary[key].rectTransform.localPosition = new Vector2(0, i * 20);
                i++;
            }
        }
예제 #2
0
        public void drawHexGrid(int maxHeight)
        {
            float xPos = 0;
            float yPos = 0;

            for (int y = 0; y < maxHeight; y++)
            {
                //Determine the shift
                if (y % 2 != 0)
                {
                    xPos = 0.866f;
                }
                else
                {
                    xPos = 0;
                }

                for (int x = 0; x < 12; x++)
                {
                    GameObject aDumHex = ourGLM.createObject("hexagon");
                    aDumHex.transform.localPosition = new Vector3(xPos, 0, yPos);
                    aDumHex.transform.SetParent(GameObject.Find("HexGrid").transform);
                    aDumHex.transform.GetChild(0).gameObject.AddComponent <HexTileController>();
                    aDumHex.name = "Hex " + x + "-" + y;

                    xPos += 1.73f;
                }
                yPos += 1.5f;
            }
        }
예제 #3
0
        public void HandleResponse(ISFSObject anObjectIn, GameLobbyManager ourGLM)
        {
            //Create Unit GameObject and Set it's parent
            GameObject aUnit = ourGLM.createObject("Units/" + anObjectIn.GetUtfString("UnitID"));

            aUnit.transform.SetParent(GameObject.Find("Units").transform);

            //Set its position
            aUnit.transform.localPosition = ourGLM.getGameManager().getLocation(anObjectIn.GetInt("xLoc"), anObjectIn.GetInt("yLoc"));

            //Determine if it needs to be rotated
            if (anObjectIn.GetInt("yLoc") > 6)
            {
                aUnit.transform.Rotate(0, 180, 0);
            }
        }
        public void HandleResponse(ISFSObject anObjectIn, GameLobbyManager ourGLM)
        {
            //Define variables
            GameObject formationsPanel = ourGLM.createObject("UI/FormationsPanel");

            formationsPanel.name = "FormationsPanel";
            formationsPanel.transform.SetParent(GameObject.Find("Canvas").transform);
            formationsPanel.transform.localPosition = new Vector3();

            if (anObjectIn.GetInt("NumberOfFormations") > 0)
            {
                string[] formationButtonNames = anObjectIn.GetUtfStringArray("FormationNames");
                for (int i = 0; i < formationButtonNames.Length; i++)
                {
                    Transform aFormationButton = formationsPanel.transform.FindChild("New 1v1 Formation");
                    aFormationButton.GetComponentInChildren <Text>().text = formationButtonNames[i];
                    aFormationButton.name = formationButtonNames[i];

                    //Add Button Event Listener and Button to the ButtonDictionary
                    ourGLM.getUserInterface().getButtonDictionary().Add(aFormationButton.GetComponent <Button>(), new GetFormationButtonHandler());
                    aFormationButton.GetComponent <Button>().onClick.AddListener(() => { ourGLM.buttonClicked(aFormationButton.GetComponent <Button>()); });
                }
            }
        }
예제 #5
0
        public void HandleResponse(ISFSObject anObjectIn, GameLobbyManager ourGLM)
        {
            //Define variables
            GameObject  chatBox      = GameObject.Find("ChatContent");
            List <Text> chatTextList = ourGLM.getUserInterface().getChatTextLabel();

            chatTextList.Add(ourGLM.createObject("UI/ChatText").GetComponent <Text>());
            chatBox.GetComponent <RectTransform>().sizeDelta = new Vector2(0, chatTextList.Count * 20);

            //Determine the Y-Position for the Chat Content rect to look at
            int posY;

            if (chatBox.GetComponent <RectTransform>().rect.height > 250)
            {
                posY = (int)chatBox.GetComponent <RectTransform>().rect.height - 250;
            }
            else
            {
                posY = 0;
            }

            //Update ChatContent position
            chatBox.GetComponent <RectTransform>().localPosition = new Vector2(0, posY);

            //Create new Chat Messag to display
            chatTextList.Last().name = "ChatTextLabel " + chatTextList.Count;
            chatTextList.Last().text = anObjectIn.GetUtfString("ChatText");
            chatTextList.Last().rectTransform.SetParent(chatBox.GetComponent <RectTransform>());

            //Update position of all chat messages
            for (int i = 0; i < chatTextList.Count; i++)
            {
                chatTextList[i].rectTransform.offsetMin = new Vector2(9, -25 + (chatTextList.Count - i) * 20);
                chatTextList[i].rectTransform.offsetMax = new Vector2(0, -5 + (chatTextList.Count - i) * 20);
            }
        }