예제 #1
0
        //Both units and buildings tostrings have been added to the rich text box to display stats
        private void Display()
        {
            battleInfo = "";
            foreach (Unit temp in ge.MapTracker.unitArray)
            {
                string   typeCheck  = temp.GetType().ToString();
                string[] splitArray = typeCheck.Split('.');
                typeCheck = splitArray[splitArray.Length - 1];

                if (typeCheck == "MeleeUnit")
                {
                    MeleeUnit obj = (MeleeUnit)temp;
                    battleInfo += obj.ToString();
                }
                else
                {
                    RangedUnit obj = (RangedUnit)temp;
                    battleInfo += obj.ToString();
                }
            }

            foreach (Building temp in ge.MapTracker.buildingArray)
            {
                string   typeCheck  = temp.GetType().ToString();
                string[] splitArray = typeCheck.Split('.');
                typeCheck = splitArray[splitArray.Length - 1];

                if (typeCheck == "ResourceBuilding")
                {
                    ResourceBuilding obj = (ResourceBuilding)temp;
                    battleInfo += obj.ToString();
                }
                else
                {
                    FactoryBuilding obj = (FactoryBuilding)temp;
                    battleInfo += obj.ToString();
                }
            }

            rtxProgress.Text = battleInfo;
        }
예제 #2
0
파일: Form1.cs 프로젝트: JadeyOlivier/Task1
        private void frmBattlefield_Load(object sender, EventArgs e)
        {
            GameEngine ge = new GameEngine();

            lblMap.Text = ge.MapTracker.drawMap();
            foreach (Unit temp in ge.MapTracker.mapArray)
            {
                string   typeCheck  = temp.GetType().ToString();
                string[] splitArray = typeCheck.Split('.');
                typeCheck = splitArray[splitArray.Length - 1];

                if (typeCheck == "MeleeUnit")
                {
                    MeleeUnit obj = (MeleeUnit)temp;
                    rtxProgress.AppendText(obj.ToString());
                }
                else
                {
                    RangedUnit obj = (RangedUnit)temp;
                    rtxProgress.AppendText(obj.ToString());
                }
            }
        }