Example #1
0
        public void Update()
        {
            ghostImage = Art.GroundTexs;
            ghostCol   = Color.White;
            sqrEdited  = false;

            if (Input.WasLMBClicked)
            {
                canClick = true;
            }

            if (!sqrCoord.CoordEqual(GameManager.STARTPOINT))
            {
                if (rect.Contains(Input.MousePosition.ToPoint()))
                {
                    GameManager.mouseSqrCoords = new Coordinates(sqrCoord.x, sqrCoord.y);

                    if (GridManager.HasNeighbour(BuildingType.Trench, sqrCoord))
                    {
                        if (Building == BuildingType.None && GameManager.BuildState == GameManager.BuildStates.Trench)
                        {
                            ghostImage = Art.getTrenchTex(GameManager.grid.sqrTexDecider((int)sqrCoord.x, (int)sqrCoord.y));
                        }

                        if (Input.LMBDown && canClick && Building != BuildingType.Tower && Building != BuildingType.Trench && !WaveManager.WaveStarted)
                        {
                            BuildManager.Build();
                            sqrEdited = true;
                        }
                    }

                    if (Input.WasLMBClicked && (GameManager.BuildState == GameManager.BuildStates.Upgrade || GameManager.BuildState == GameManager.BuildStates.Destroy) && !WaveManager.WaveStarted)
                    {
                        BuildManager.Build();
                    }

                    highlight = 0.5f;
                }

                else
                {
                    highlight = 1;
                }
            }
        }
Example #2
0
        public void Update(Grid.gridFlags endPoint, GameTime gameTime)
        {
            time = (float)gameTime.ElapsedGameTime.TotalSeconds;

            //check for out of bounds, only really occurs when they are spawned from a destroyed vehicle as the vehicle is turning
            if (enemyVect.X >= 20)
            {
                enemyVect.X = 19;
            }
            if (enemyVect.Y >= 15)
            {
                enemyVect.Y = 14;
            }
            if (enemyVect.X < 0)
            {
                enemyVect.X = 0;
            }
            if (enemyVect.Y < 0)
            {
                enemyVect.Y = 0;
            }

            currentCoord = new Coordinates((int)enemyVect.X, (int)enemyVect.Y);

            if (enemyVect != null)
            {
                moving = PathMove(GameManager.grid.gridSquares, GameManager.HEIGHT, GameManager.WIDTH, ref enemyVect, ref ScreenPos, speed, time, Direction, EnemyType);
            }

            if (GameManager.ENDPOINT != null)
            {
                if (currentCoord.CoordEqual(GameManager.ENDPOINT))
                {
                    IsDestroyed             = true;
                    GameManager.BaseHealth -= damage;
                }
            }

            if (hitPoints <= 0)
            {
                IsDestroyed = true;
            }

            // Get screen pixel position from Grid Coordinates (enemyVect).
            if (moving)
            {
                ScreenPos = new Vector2((int)GameManager.grid.gridBorder.X + (enemyVect.X * GameManager.SQUARESIZE) + GameManager.SQUARESIZE / 2, (int)GameManager.grid.gridBorder.Y + (enemyVect.Y * GameManager.SQUARESIZE) + GameManager.SQUARESIZE / 2);
            }

            else
            {
                enemyVect.X = (float)Math.Round(enemyVect.X);
                enemyVect.Y = (float)Math.Round(enemyVect.Y);
            }


            if (EnemyType == "Tank" || EnemyType == "Jeep")
            {
                TurretDirection = TankTurret.Update(this);
            }

            Vector2 NextScreenPos = new Vector2((int)GameManager.grid.gridBorder.X + (nextCoord.x * GameManager.SQUARESIZE + 0.1f), (int)GameManager.grid.gridBorder.Y + (nextCoord.y * GameManager.SQUARESIZE));

            Direction = Movement;

            if (!towerInRange)
            {
                TurretDirection = Direction;
                //float nextTurretDirection = Direction.ToAngle();
                //// LERPING HERE
                //turretRotation = Extensions.CurveAngle(turretRotation, nextTurretDirection, 0.3f);
                //TurretDirection = turretRotation.ToVector();
            }

            if (usingSpriteSheet)
            {
                EffectManager.spriteSheetUpdate(ref spriteSheetNo, ref animElasped, targetElasped, sheetFrameTotal, gameTime);

                if (EnemyType == "Soldier")
                {
                    SourceRect = new Rectangle(0, spriteSheetNo * Art.Soldier.Height / (sheetFrameTotal + 1), Art.Soldier.Width, Art.Soldier.Height / (sheetFrameTotal + 1));
                }
                else if (EnemyType == "Helicopter")
                {
                    SourceRect = new Rectangle(spriteSheetNo * Art.Helicopter.Width / (sheetFrameTotal + 1), 0, Art.Helicopter.Width / (sheetFrameTotal + 1), Art.Helicopter.Height);
                }
            }
        }
Example #3
0
        public void Update()
        {
            ghostImage = Art.GroundTexs;
            ghostCol   = Color.White;
            sqrEdited  = false;

            if (Input.WasLMBClicked)
            {
                canClick = true;
            }

            if (sqrCoord.counter == GameManager.DEFAULYDIST)
            {
                ghostImage = Art.BlockedSquare;
                squareInfo = "A blocked of square, solve this problem by building a trench or a tower here!";
            }

            if (Building != BuildingType.Base)
            {
                if (!QuestionPopUpManager.QuestionUp)
                {
                    if (!sqrCoord.CoordEqual(GameManager.STARTPOINT))
                    {
                        if (rect.Contains(Input.MousePosition.ToPoint()))
                        {
                            if (GameManager.HelpMode)
                            {
                                if (!HelpDialogManager.Hovering)
                                {
                                    HelpDialogManager.Hovering = true;
                                }
                            }

                            GameManager.mouseSqrCoords = new Coordinates(sqrCoord.x, sqrCoord.y);

                            if (Building == BuildingType.None && GameManager.BuildState == GameManager.BuildStates.Trench)
                            {
                                ghostImage = Art.getTrenchTex(GameManager.grid.sqrTexDecider((int)sqrCoord.x, (int)sqrCoord.y));
                                squareInfo = "A grass patch, build a trench here or concrete for tower foundations!";
                            }

                            if (Building == BuildingType.Concrete)
                            {
                                squareInfo = "Build a tower on this concrete!";
                            }

                            if (Building == BuildingType.Trench)
                            {
                                squareInfo = "A trench";
                            }

                            if (Building == BuildingType.Tower)
                            {
                                squareInfo = "A tower";
                            }

                            if (Input.WasLMBClicked && canClick && !WaveManager.WaveStarted)
                            {
                                BuildManager.Build();
                                sqrEdited = true;
                            }


                            if (GameManager.HelpMode)
                            {
                                HelpDialogManager.Add(new HelpDialog(squareInfo, Input.MousePosition));
                            }

                            highlight = 0.5f;
                        }

                        else
                        {
                            highlight = 1;
                        }
                    }
                }

                else
                {
                    highlight = 1;
                }
            }
        }
Example #4
0
        public void Update(Grid.gridFlags endPoint, GameTime gameTime)
        {
            time = (float)gameTime.ElapsedGameTime.TotalSeconds;

            //check for out of bounds, only really occurs when they are spawned from a destroyed vehicle as the vehicle is turning
            if (enemyVect.X >= 20)
                enemyVect.X = 19;
            if (enemyVect.Y >= 15)
                enemyVect.Y = 14;
            if (enemyVect.X < 0)
                enemyVect.X = 0;
            if (enemyVect.Y < 0)
                enemyVect.Y = 0;

            currentCoord = new Coordinates((int)enemyVect.X, (int)enemyVect.Y);

            if(enemyVect != null)
                moving = PathMove(GameManager.grid.gridSquares, GameManager.HEIGHT, GameManager.WIDTH, ref enemyVect, ref ScreenPos, speed, time, Direction, EnemyType);

            if (GameManager.ENDPOINT != null)
            {
                if (currentCoord.CoordEqual(GameManager.ENDPOINT))
                {
                    IsDestroyed = true;
                    GameManager.BaseHealth -= damage;
                }
            }

            if (hitPoints <= 0)
            {
                IsDestroyed = true;
            }

            // Get screen pixel position from Grid Coordinates (enemyVect).
            if (moving)
                ScreenPos = new Vector2((int)GameManager.grid.gridBorder.X + (enemyVect.X * GameManager.SQUARESIZE) + GameManager.SQUARESIZE / 2, (int)GameManager.grid.gridBorder.Y + (enemyVect.Y * GameManager.SQUARESIZE) + GameManager.SQUARESIZE / 2);

            else
            {
                enemyVect.X = (float)Math.Round(enemyVect.X);
                enemyVect.Y = (float)Math.Round(enemyVect.Y);
            }


            if (EnemyType == "Tank" || EnemyType == "Jeep")
            {
                TurretDirection = TankTurret.Update(this);
            }

            Vector2 NextScreenPos = new Vector2((int)GameManager.grid.gridBorder.X + (nextCoord.x * GameManager.SQUARESIZE + 0.1f), (int)GameManager.grid.gridBorder.Y + (nextCoord.y * GameManager.SQUARESIZE));
            Direction = Movement;

            if (!towerInRange)
            {
                TurretDirection = Direction;
                //float nextTurretDirection = Direction.ToAngle();
                //// LERPING HERE
                //turretRotation = Extensions.CurveAngle(turretRotation, nextTurretDirection, 0.3f);
                //TurretDirection = turretRotation.ToVector();
            }

            if (usingSpriteSheet)
            {
                EffectManager.spriteSheetUpdate(ref spriteSheetNo, ref animElasped, targetElasped, sheetFrameTotal, gameTime);

                if(EnemyType == "Soldier")
                    SourceRect = new Rectangle(0, spriteSheetNo * Art.Soldier.Height / (sheetFrameTotal + 1), Art.Soldier.Width, Art.Soldier.Height / (sheetFrameTotal + 1));
                else if (EnemyType == "Helicopter")
                    SourceRect = new Rectangle(spriteSheetNo * Art.Helicopter.Width / (sheetFrameTotal + 1) , 0, Art.Helicopter.Width / (sheetFrameTotal + 1), Art.Helicopter.Height); 
            }

        }