Inheritance: MouseClickListener, MouseMotionListener
Exemple #1
0
        public Building(Player player)
        {
            this.p = player;
            this.p.buildings.AddLast(this);
            this.constructProgress = 0;

            this.progressBar = new ProgressBar(this);
            this.healthBar = new HealthBar(this);

            this.productionQueue = new LinkedList<ProductionUnit>();

            if (Game1.GetInstance().IsMultiplayerGame())
            {
                Boolean isLocal = this.p == Game1.CURRENT_PLAYER;
                this.multiplayerData = new BuildingMultiplayerData(this, isLocal);
                if (isLocal)
                {
                    this.multiplayerData.RequestServerID();
                    this.state = State.Preview;
                }
                else
                {
                    this.state = State.MultiplayerWaitingForLocation;
                }
            }
            else
            {
                this.state = State.Preview;
            }
        }
Exemple #2
0
        /// <summary>
        /// Sets the textures to use for the HUD.
        /// Creates new instances of needed components.
        /// Sets variables to their default values.
        /// </summary>
        /// <param name="p">The player this HUD belongs to</param>
        /// <param name="c">The desired color for this HUD</param>
        public HUD(Player p, Color c)
        {
            this.player = p;
            this.color = c;

            hudTex = Game1.GetInstance().Content.Load<Texture2D>("HUD/HUD");
            miniMapTex = Game1.GetInstance().Content.Load<Texture2D>("HUD/HUDMiniMap");
            sf = Game1.GetInstance().Content.Load<SpriteFont>("Fonts/SpriteFont1");

            loadForEngineer = false;
            loadForUnit = false;
            loadForResources = false;
            loadForSentry = false;
            loadForBarracks = false;
            loadForFactory = false;
            loadForFortress = false;
            draw = false;

            objects = new CustomArrayList<HUDObject>();

            LoadCommands();

            MouseManager.GetInstance().mouseClickedListeners += ((MouseClickListener)this).OnMouseClick;
            MouseManager.GetInstance().mouseReleasedListeners += ((MouseClickListener)this).OnMouseRelease;
        }
Exemple #3
0
        public Horseman(Player p, int x, int y)
            : base(p, x, y, 2f, 20f, 100f, 50f)
        {
            this.baseDamage = (int)Unit.Damage.Horseman;
            this.type = Type.Fast;
            this.texture = Game1.GetInstance().Content.Load<Texture2D>("Units/horseman");

            this.collisionRadius = texture.Width / 2;
        }
Exemple #4
0
        public Building(Player player)
        {
            this.p = player;
            this.p.buildings.AddLast(this);
            this.constructProgress = 0;

            this.state = BuildState.Preview;
            this.progressBar = new ProgressBar(this);
        }
Exemple #5
0
        public CombatUnit(Player p, int x, int y, float movementSpeed, float range, float rateOfFire)
            : base(p, x, y, movementSpeed)
        {
            this.range = range;
            this.rateOfFire = rateOfFire;
            this.enemiesInRange = new LinkedList<Unit>();

            this.projectiles = new LinkedList<Projectile>();
        }
Exemple #6
0
        /// <summary>
        /// Engineer Constructor.
        /// </summary>
        /// <param name="p"></param>
        /// <param name="cm"></param>
        /// <param name="startLocation"></param>
        /// <param name="c"></param>
        public Engineer(Player p, int x, int y)
            : base(p, x, y, 1f)
        {
            this.type = UnitType.Engineer;
            this.texture = Game1.GetInstance().Content.Load<Texture2D>("Units/Engineer");
            this.collisionRadiusTexture = Game1.GetInstance().Content.Load<Texture2D>("Misc/patternPreview");

            this.collisionRadius = texture.Width / 2;
        }
Exemple #7
0
        public ResourceGather(Player p, Color c)
            : base(p)
        {
            this.c = c;
            this.constructC = new Color(this.c.R, this.c.G, this.c.B, 0);
            this.type = BuildingType.Resources;
            this.constructDuration = 3;

            this.texture = Game1.GetInstance().Content.Load<Texture2D>("Buildings/Resources");
        }
Exemple #8
0
        public Fortress(Player p, Color c)
            : base(p)
        {
            this.c = c;
            this.constructC = new Color(this.c.R, this.c.G, this.c.B, 0);
            this.type = BuildingType.Fortress;
            this.constructDuration = 15;

            this.texture = Game1.GetInstance().Content.Load<Texture2D>("Buildings/Fortress");
        }
Exemple #9
0
        public Bowman(Player p, int x, int y)
            : base(p, x, y, 1f, 100f, 60)
        {
            this.player = p;
            this.x = x;
            this.y = y;
            this.type = UnitType.Ranged;

            this.texture = Game1.GetInstance().Content.Load<Texture2D>("Units/bowman");
        }
Exemple #10
0
        public Bowman(Player p, int x, int y)
            : base(p, x, y, 1f, 100f, 100f, 60)
        {
            this.baseDamage = baseDamage;

            this.type = Type.Ranged;
            this.projectiles = new LinkedList<Projectile>();

            this.texture = Game1.GetInstance().Content.Load<Texture2D>("Units/bowman");
            // Console.Out.WriteLine("Constructed a bowman @ " + this.GetLocation() + " (" + x + ", " + y + ")");
        }
Exemple #11
0
        public Swordman(Player p, int x, int y)
            : base(p, x, y, 1.25f, 20f, 100f, 60)
        {
            this.baseDamage = (int)Unit.Damage.Swordman;
            this.player = p;
            this.x = x;
            this.y = y;
            this.type = Type.Melee;

            this.texture = Game1.GetInstance().Content.Load<Texture2D>("Units/melee");
        }
Exemple #12
0
        /// <summary>
        /// Engineer Constructor.
        /// </summary>
        /// <param name="p"></param>
        /// <param name="cm"></param>
        /// <param name="startLocation"></param>
        /// <param name="c"></param>
        public Engineer(Player p, int x, int y)
            : base(p, x, y, 1f, 1f, 1f, 1f)
        {
            this.baseDamage = (int) Unit.Damage.Engineer;
            this.type = Type.Engineer;
            this.texture = Game1.GetInstance().Content.Load<Texture2D>("Units/Engineer");
            this.collisionRadiusTexture = Game1.GetInstance().Content.Load<Texture2D>("Misc/patternPreview");

            // Console.Out.WriteLine("Constructed an engineer @ " + this.GetLocation() + " (" + x + ", " + y + ")");

            this.collisionRadius = texture.Width / 2;
        }
Exemple #13
0
        public Horseman(Player p, int x, int y)
            : base(p, x, y, 2f, 20f, 100f, 80)
        {
            this.baseDamage = (int)Damage.Horseman;
            this.type = Type.Fast;
            this.visionRange = (float)VisionRange.Horseman;
            this.texture = TextureManager.GetInstance().GetTexture(this.type);
            this.hitTexture = TextureManager.GetInstance().GetHitTexture(this.type);

            this.collisionRadius = texture.Width / 2;
            this.halfTextureWidth = this.texture.Width / 2;
            this.halfTextureHeight = this.texture.Height / 2;
        }
Exemple #14
0
        public Factory(Player p, Color c)
            : base(p)
        {
            this.c = c;
            this.constructC = new Color(this.c.R, this.c.G, this.c.B, 0);
            this.type = Type.Factory;
            this.constructDuration = 8;

            this.maxHealth = 3000f;
            this.currentHealth = 0f;

            this.texture = Game1.GetInstance().Content.Load<Texture2D>("Buildings/Factory");
        }
Exemple #15
0
        public Barracks(Player p, Color c)
            : base(p)
        {
            this.c = c;
            this.constructC = new Color(this.c.R, this.c.G, this.c.B, 0);
            this.type = Type.Barracks;
            this.constructDuration = 5;

            this.maxHealth = 2000f;
            this.currentHealth = 0f;

            this.texture = Game1.GetInstance().Content.Load<Texture2D>("Buildings/Barracks");
        }
Exemple #16
0
        public Unit(Player p, int x, int y, float movementSpeed, float attackRange, float aggroRange, float rateOfFire)
        {
            this.player = p;
            this.x = x;
            this.y = y;
            this.z = 1f - ( this.player.units.Count() + 1) * 0.0001f;
            this.movementSpeed = movementSpeed;
            this.attackRange = attackRange;
            this.aggroRange = aggroRange;
            this.rateOfFire = rateOfFire;

            this.rotation = 0f;
            this.previousRotation = 0f;

            this.hitting = false;
            this.hitFrame = 0;

            this.color = player.color;
            this.waypoints = new CustomArrayList<Point>();

            this.repelsOthers = true;
            this.collisionWith = new CustomArrayList<Unit>();
            this.enemiesInRange = new CustomArrayList<Unit>();
            this.friendliesProtectingMe = new CustomArrayList<Unit>();

            this.job = Job.Idle;

            healthBar = new HealthBar(this);

            this.currentHealth = 100;
            this.maxHealth = 100;

            this.player.units.AddLast(this);

            if (Game1.GetInstance().IsMultiplayerGame())
            {
                Boolean isLocal = this.player == Game1.CURRENT_PLAYER;
                this.multiplayerData = new UnitMultiplayerData(this, isLocal);
                if (isLocal)
                {
                    this.multiplayerData.RequestServerID();
                }

                if (this.multiplayerData != null)
                {
                    // Make sure everyone knows of this unit
                    Synchronizer.GetInstance().QueueUnit(this);
                }
            }
        }
Exemple #17
0
        public Sentry(Player p, Color c)
            : base(p)
        {
            this.c = c;
            this.constructC = new Color(this.c.R, this.c.G, this.c.B, 0);
            this.type = Type.Sentry;
            this.constructDuration = 10;

            this.visionRange = 50f;

            this.maxHealth = 500f;
            this.currentHealth = 0f;

            this.texture = TextureManager.GetInstance().GetTexture(this.type);
        }
Exemple #18
0
        public Command(Texture2D texture, Player player, Type type, float x, float y, Color color)
        {
            this.texture = texture;
            this.player = player;
            this.type = type;
            this.x = x;
            this.y = y;
            this.color = color;

            // Was false
            Game1.GetInstance().IsMouseVisible = true;

            //MouseManager.GetInstance().mouseClickedListeners += ((MouseClickListener)this).OnMouseClick;
            MouseManager.GetInstance().mouseReleasedListeners += ((MouseClickListener)this).OnMouseRelease;
        }
Exemple #19
0
        public Unit(Player p, int x, int y, float movementSpeed)
        {
            this.player = p;
            this.x = x;
            this.y = y;
            this.movementSpeed = movementSpeed;
            (this.quad = Game1.GetInstance().quadTree.GetQuadByPoint(this.GetLocation())).highlighted = true;

            this.color = player.color;
            this.waypoints = new LinkedList<Point>();
            this.player.units.AddLast(this);

            this.repelsOthers = true;
            this.collisionWith = new LinkedList<Unit>();

            healthBar = new HealthBar(this);

            this.currentHealth = 100;
            this.maxHealth = 100;
        }
Exemple #20
0
        /// <summary>
        /// HUD Constructor.
        /// </summary>
        /// <param name="p"></param>
        /// <param name="cm"></param>
        /// <param name="c"></param>
        public HUD(Player p, Color c)
        {
            this.player = p;
            this.color = c;

            hudTex = Game1.GetInstance().Content.Load<Texture2D>("HUD/HUD");
            hudResourcesTex = Game1.GetInstance().Content.Load<Texture2D>("HUD/HUDResources");
            hudBarracksTex = Game1.GetInstance().Content.Load<Texture2D>("HUD/HUDBarracks");
            hudFactoryTex = Game1.GetInstance().Content.Load<Texture2D>("HUD/HUDFactory");
            hudFortressTex = Game1.GetInstance().Content.Load<Texture2D>("HUD/HUDFortress");

            hudItemDetails = Game1.GetInstance().Content.Load<Texture2D>("HUD/HUDItemDetails");

            sf = Game1.GetInstance().Content.Load<SpriteFont>("Fonts/SpriteFont1");

            loadForEngineer = false;
            draw = false;

            MouseManager.GetInstance().mouseClickedListeners += ((MouseClickListener)this).OnMouseClick;
            MouseManager.GetInstance().mouseReleasedListeners += ((MouseClickListener)this).OnMouseRelease;
        }
Exemple #21
0
        /// <summary>
        /// Sets the textures to use for the HUD.
        /// Creates new instances of needed components.
        /// Sets variables to their default values.
        /// </summary>
        /// <param name="p">The player this HUD belongs to</param>
        /// <param name="c">The desired color for this HUD</param>
        public HUD(Player p, Color c)
        {
            this.player = p;
            this.color = c;

            hudTex = Game1.GetInstance().Content.Load<Texture2D>("HUD/HUD");
            hudItemDetails = Game1.GetInstance().Content.Load<Texture2D>("HUD/HUDItemDetails");
            sf = Game1.GetInstance().Content.Load<SpriteFont>("Fonts/SpriteFont1");

            loadForEngineer = false;
            loadForBarracks = false;
            loadForFactory = false;
            loadForFortress = false;
            draw = false;

            objects = new LinkedList<HUDObject>();

            LoadCommands();

            MouseManager.GetInstance().mouseClickedListeners += ((MouseClickListener)this).OnMouseClick;
            MouseManager.GetInstance().mouseReleasedListeners += ((MouseClickListener)this).OnMouseRelease;
        }
Exemple #22
0
        public Unit(Player p, int x, int y, float movementSpeed, float attackRange, float aggroRange, float rateOfFire)
        {
            this.player = p;
            this.x = x;
            this.y = y;
            this.movementSpeed = movementSpeed;
            this.attackRange = attackRange;
            this.aggroRange = aggroRange;
            this.rateOfFire = rateOfFire;
            (this.quad = Game1.GetInstance().quadTree.GetQuadByPoint(this.GetLocation())).highlighted = true;

            this.color = player.color;
            this.waypoints = new LinkedList<Point>();

            this.repelsOthers = true;
            this.collisionWith = new LinkedList<Unit>();
            this.enemiesInRange = new LinkedList<Unit>();
            this.friendliesProtectingMe = new LinkedList<Unit>();

            healthBar = new HealthBar(this);

            this.currentHealth = 100;
            this.maxHealth = 100;

            this.player.units.AddLast(this);

            if (Game1.GetInstance().IsMultiplayerGame())
            {
                Boolean isLocal = this.player == Game1.CURRENT_PLAYER;
                this.multiplayerData = new UnitMultiplayerData(this, isLocal);
                if (isLocal)
                {
                    this.multiplayerData.RequestServerID();
                }
            }
        }
Exemple #23
0
        public ResourceGather(Player p, Color c)
            : base(p)
        {
            this.c = c;
            this.constructC = new Color(this.c.R, this.c.G, this.c.B, 0);
            this.type = Type.Resources;
            this.constructDuration = 3;

            this.maxHealth = 1000f;
            this.currentHealth = 0f;

            this.texture = TextureManager.GetInstance().GetTexture(this.type);
            this.animationFont = Game1.GetInstance().Content.Load<SpriteFont>("Fonts/ResourceFont");

            this.visionRange = 50f;

            this.resourceRange = new Circle(100, this, c);
            this.generationBarrier = 12;
            this.resourcesAdded = false;
            this.secondAdded = false;
            this.secondsPast = 0;
            this.previousSecond = -1;

            this.drawAnimation = false;
            this.animationCounter = 0;

            for (int i = 0; i < p.buildings.Count(); i++)
            {
                Building b = p.buildings.ElementAt(i);
                if (b is ResourceGather)
                {
                    ResourceGather rg = (ResourceGather)b;
                    rg.drawRange = true;
                }
            }
        }
Exemple #24
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            drawLineTexture = this.Content.Load<Texture2D>("Misc/solid");
            font = Content.Load<SpriteFont>("Fonts/Arial");
            (collision = new RTSCollisionMap(this, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight)).PlaceNodesAroundEdges();
            graphics.PreferMultiSampling = true;

            (quadTree = new QuadRoot(new Rectangle(0, 0,
                graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight)
                )).CreateTree(5);

            players = new LinkedList<Player>();

            Alliance redAlliance = new Alliance();
            Player humanPlayer = new Player(redAlliance, Color.Red);
            players.AddLast((CURRENT_PLAYER = humanPlayer));
            humanPlayer.SpawnStartUnits(new Point((int)Game1.GetInstance().graphics.PreferredBackBufferWidth / 2,
                (int)Game1.GetInstance().graphics.PreferredBackBufferWidth / 2));

            Alliance greenAlliance = new Alliance();
            Player aiPlayer = new Player(greenAlliance, Color.Green);
            players.AddLast(aiPlayer);
            aiPlayer.SpawnStartUnits(new Point((int)Game1.GetInstance().graphics.PreferredBackBufferWidth / 2, 200));

            //SaveManager.GetInstance().SaveNodes("C:\\Users\\Wouter\\Desktop\\test.xml");
            MouseManager.GetInstance().mouseClickedListeners += ((MouseClickListener)this).OnMouseClick;
            MouseManager.GetInstance().mouseReleasedListeners += ((MouseClickListener)this).OnMouseRelease;
            MouseManager.GetInstance().mouseMotionListeners += ((MouseMotionListener)this).OnMouseMotion;
            MouseManager.GetInstance().mouseDragListeners += ((MouseMotionListener)this).OnMouseDrag;

            /*XNAPanel panel = new XNAPanel(null, new Rectangle(
                this.graphics.PreferredBackBufferWidth / 2 - 200,
                this.graphics.PreferredBackBufferHeight / 2 - 200,
                400, 400));
            XNAButton button = new XNAButton(panel, new Rectangle(10, 10, 100, 40), "");*/

            base.Initialize();
        }
Exemple #25
0
        /// <summary>
        /// Should be called when the map is finished with loading.
        /// </summary>
        public void FinishedLoadingMap()
        {
            Game1 game = Game1.GetInstance();
            if (game.IsMultiplayerGame())
            {
                // Do nothing, used to be something here
            }
            else
            {
                Alliance redAlliance = new Alliance();
                Player humanPlayer = new Player(redAlliance, Color.Blue, this.tempPlayerLocations[0]);
                Game1.CURRENT_PLAYER = humanPlayer;
                humanPlayer.SpawnStartUnits();

                Alliance greenAlliance = new Alliance();
                Player aiPlayer = new Player(greenAlliance, Color.Purple,
                    new Point((int)Game1.GetInstance().graphics.PreferredBackBufferWidth / 2, 200));
                aiPlayer.SpawnStartUnits();

                StateManager.GetInstance().gameState = StateManager.State.GameRunning;
                //SaveManager.GetInstance().SaveNodes("C:\\Users\\Wouter\\Desktop\\test.xml");
            }

            game.map.miniMap = new MiniMap(game.map);
            game.map.miniMap.CreateMiniMap(true);

            game.drawOffset = new Vector2(Game1.CURRENT_PLAYER.startLocation.X - ( game.graphics.PreferredBackBufferWidth / 2 ),
                Game1.CURRENT_PLAYER.startLocation.Y - ( game.graphics.PreferredBackBufferHeight / 2 ));

            MouseManager.GetInstance().mouseClickedListeners += ((MouseClickListener)game).OnMouseClick;
            MouseManager.GetInstance().mouseReleasedListeners += ((MouseClickListener)game).OnMouseRelease;
            MouseManager.GetInstance().mouseMotionListeners += ((MouseMotionListener)game).OnMouseMotion;
            MouseManager.GetInstance().mouseDragListeners += ((MouseMotionListener)game).OnMouseDrag;
        }
Exemple #26
0
        /// <summary>
        /// Prepares the multiplayer game
        /// </summary>
        public void PrepareMultiplayerGame()
        {
            GameLobby lobby = (GameLobby)MenuManager.GetInstance().GetCurrentlyDisplayedMenu();
            if (ChatServerConnectionManager.GetInstance().user.username == "Testy")
            {
                // Wait 5 seconds, this is purely for debugging to prevent I/O exceptions when
                // 2 local clients are accessing the same files.
                Thread.Sleep(2000);
            }
            foreach (User user in UserManager.GetInstance().users)
            {
                Game1.GetInstance().multiplayerGame.AddUser(user);
            }

            Alliance[] alliances = new Alliance[8];
            for (int i = 0; i < alliances.Length; i++)
            {
                alliances[i] = new Alliance();
            }

            for (int i = 0; i < lobby.GetDisplayPanelCount(); i++)
            {
                UserDisplayPanel panel = lobby.GetDisplayPanel(i);
                Alliance alli = alliances[Int32.Parse(panel.teamDropdown.GetSelectedOption()) - 1];
                Player player = new Player(alli, panel.GetSelectedColor(),
                    lobby.mapPreviewPanel.playerLocationGroup.GetMapLocationByButtonTextNumber(i + 1));
                player.multiplayerID = panel.user.id;
                if (panel.user.id == ChatServerConnectionManager.GetInstance().user.id)
                {
                    Game1.CURRENT_PLAYER = player;
                }
                alli.members.AddLast(player);
            }
        }
Exemple #27
0
 public FastStore(Player player)
 {
     this.player = player;
 }
Exemple #28
0
 public MeleeStore(Player player)
 {
     this.player = player;
 }
Exemple #29
0
 public RangedStore(Player player)
 {
     this.player = player;
 }