예제 #1
0
파일: HUD.cs 프로젝트: R3coil/RTS_XNA_v2
        /// <summary>
        /// Checks whether the HUD should be hidden or not.
        /// Loads the objects to display according to selected units/buildings.
        /// </summary>
        /// <param name="ks">Default KeyboardState</param>
        /// <param name="ms">Default MouseState</param>
        public void Update(KeyboardState ks, MouseState ms)
        {
            if (!draw)
            {
                draw = true;
            }
            CountUnits();

            objects = new LinkedList<HUDObject>();

            foreach (HUDCommandObject co in commandObjects)
            {
                co.disabled = true;
            }

            if (loadForEngineer)
            {
                HUDObject resourceObject = new HUDObject(Game1.GetInstance().Content.Load<Texture2D>("HUD/HUDResources"), HUDObject.Type.Resources, startObjectX, startObjectY, color);
                objects.AddLast(resourceObject);
                IncrementStartObjectXY(startObjectX);

                HUDObject barracksObject = new HUDObject(Game1.GetInstance().Content.Load<Texture2D>("HUD/HUDBarracks"), HUDObject.Type.Barracks, startObjectX, startObjectY, color);
                objects.AddLast(barracksObject);
                IncrementStartObjectXY(startObjectX);

                HUDObject factoryObject = new HUDObject(Game1.GetInstance().Content.Load<Texture2D>("HUD/HUDFactory"), HUDObject.Type.Factory, startObjectX, startObjectY, color);
                objects.AddLast(factoryObject);
                IncrementStartObjectXY(startObjectX);

                HUDObject fortressObject = new HUDObject(Game1.GetInstance().Content.Load<Texture2D>("HUD/HUDFortress"), HUDObject.Type.Fortress, startObjectX, startObjectY, color);
                objects.AddLast(fortressObject);
                IncrementStartObjectXY(startObjectX);

                foreach (HUDCommandObject co in commandObjects)
                {
                    if (co.type == HUDCommandObject.Type.Repair)
                    {
                        co.disabled = false;
                    }
                }
            }
            if (loadForBarracks)
            {
                HUDObject meleeObject = new HUDObject(Game1.GetInstance().Content.Load<Texture2D>("HUD/HUDMelee"), HUDObject.Type.Melee, startObjectX, startObjectY, color);
                objects.AddLast(meleeObject);
                IncrementStartObjectXY(startObjectX);

                HUDObject rangedObject = new HUDObject(Game1.GetInstance().Content.Load<Texture2D>("HUD/HUDRanged"), HUDObject.Type.Ranged, startObjectX, startObjectY, color);
                objects.AddLast(rangedObject);
                IncrementStartObjectXY(startObjectX);

                HUDObject fastObject = new HUDObject(Game1.GetInstance().Content.Load<Texture2D>("HUD/HUDHorseman"), HUDObject.Type.Fast, startObjectX, startObjectY, color);
                objects.AddLast(fastObject);
                IncrementStartObjectXY(startObjectX);
            }
            if (loadForFortress)
            {
                HUDObject engineerObject = new HUDObject(Game1.GetInstance().Content.Load<Texture2D>("HUD/HUDEngineer"), HUDObject.Type.Engineer, startObjectX, startObjectY, color);
                objects.AddLast(engineerObject);
                IncrementStartObjectXY(startObjectX);
            }

            startObjectX = 278;
            startObjectY = 688;
        }
예제 #2
0
파일: HUD.cs 프로젝트: Wotuu/RTS_XNA_v2
        /// <summary>
        /// Checks whether the HUD should be hidden or not. (if the player this HUD belongs to is not the player that is watching)
        /// Loads the objects to display according to selected units/buildings.
        /// </summary>
        /// <param name="ks">Default KeyboardState</param>
        /// <param name="ms">Default MouseState</param>
        public void Update(KeyboardState ks, MouseState ms)
        {
            if (!draw)
            {
                draw = true;
            }
            CountUnits();

            objects = new CustomArrayList<HUDObject>();

            for (int i = 0; i < this.commandObjects.Count(); i++)
            {
                this.commandObjects.ElementAt(i).disabled = true;
            }

            if (loadForEngineer)
            {
                resourceObject = new HUDObject(TextureManager.GetInstance().GetTexture(HUDObject.Type.Resources), HUDObject.Type.Resources, startObjectX, startObjectY, color);
                objects.AddLast(resourceObject);
                IncrementStartObjectXY(startObjectX);

                barracksObject = new HUDObject(TextureManager.GetInstance().GetTexture(HUDObject.Type.Barracks), HUDObject.Type.Barracks, startObjectX, startObjectY, color);
                objects.AddLast(barracksObject);
                IncrementStartObjectXY(startObjectX);

                factoryObject = new HUDObject(TextureManager.GetInstance().GetTexture(HUDObject.Type.Factory), HUDObject.Type.Factory, startObjectX, startObjectY, color);
                objects.AddLast(factoryObject);
                IncrementStartObjectXY(startObjectX);

                sentryObject = new HUDObject(TextureManager.GetInstance().GetTexture(HUDObject.Type.Sentry), HUDObject.Type.Sentry, startObjectX, startObjectY, color);
                objects.AddLast(sentryObject);
                IncrementStartObjectXY(startObjectX);

                fortressObject = new HUDObject(TextureManager.GetInstance().GetTexture(HUDObject.Type.Fortress), HUDObject.Type.Fortress, startObjectX, startObjectY, color);
                objects.AddLast(fortressObject);
                IncrementStartObjectXY(startObjectX);

                for (int i = 0; i < this.commandObjects.Count(); i++)
                {
                    HUDCommandObject co = this.commandObjects.ElementAt(i);
                    if (co.type == HUDCommandObject.Type.Repair || co.type == HUDCommandObject.Type.Move || co.type == HUDCommandObject.Type.Stop || co.type == HUDCommandObject.Type.Defend)
                    {
                        co.disabled = false;
                    }
                }
            }
            if (loadForUnit)
            {
                for (int i = 0; i < this.commandObjects.Count(); i++)
                {
                    HUDCommandObject co = this.commandObjects.ElementAt(i);
                    if (co.type == HUDCommandObject.Type.Attack || co.type == HUDCommandObject.Type.Defend || co.type == HUDCommandObject.Type.Move || co.type == HUDCommandObject.Type.Stop)
                    {
                        co.disabled = false;
                    }
                }
            }
            if (loadForBarracks)
            {
                meleeObject = new HUDObject(TextureManager.GetInstance().GetTexture(HUDObject.Type.Melee), HUDObject.Type.Melee, startObjectX, startObjectY, color);
                objects.AddLast(meleeObject);
                IncrementStartObjectXY(startObjectX);

                rangedObject = new HUDObject(TextureManager.GetInstance().GetTexture(HUDObject.Type.Ranged), HUDObject.Type.Ranged, startObjectX, startObjectY, color);
                objects.AddLast(rangedObject);
                IncrementStartObjectXY(startObjectX);

                fastObject = new HUDObject(TextureManager.GetInstance().GetTexture(HUDObject.Type.Fast), HUDObject.Type.Fast, startObjectX, startObjectY, color);
                objects.AddLast(fastObject);
                IncrementStartObjectXY(startObjectX);
            }
            if (loadForFortress)
            {
                engineerObject = new HUDObject(TextureManager.GetInstance().GetTexture(HUDObject.Type.Engineer), HUDObject.Type.Engineer, startObjectX, startObjectY, color);
                objects.AddLast(engineerObject);
                IncrementStartObjectXY(startObjectX);
            }

            startObjectX = 278;
            startObjectY = 688;
        }