예제 #1
0
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     using (Game1 game = new Game1())
     {
         game.Run();
     }
 }
예제 #2
0
        public void findClosestCreep(GameTime gameTime, Tower tower, Game1 game)
        {
            //search the path and choose the closest creep to the towers position
            int xDiff = 1000;
            int yDiff = 1000;
            int tempX = 0;
            int tempY = 0;
            int crPos = 0;
            if (gameTime.TotalGameTime.TotalSeconds > tower.seconds)
            {

                for (int x = 0; x < game.Creeps.Count; x++)
                {
                    tempX = Math.Abs((int)(tower.pos.X - game.Creeps.ElementAt(x).pos.X));
                    tempY = Math.Abs((int)(tower.pos.Y - game.Creeps.ElementAt(x).pos.Y));
                    if ((tempX <= xDiff) && (tempY <= yDiff))
                    {
                        xDiff = tempX;
                        yDiff = tempY;
                        crPos = x;
                        System.Diagnostics.Debug.WriteLine("JONO!");
                        System.Diagnostics.Debug.WriteLine(tempX);
                        System.Diagnostics.Debug.WriteLine(tempY);
                    }

                }
                tower.seconds = (int)(gameTime.TotalGameTime.TotalSeconds + tower.Speed);
                Shoot(game.Creeps.ElementAt(crPos), game, tower);

            }
        }
예제 #3
0
        //making a random path at the start of the game for creeps to run down
        public void drawRandomTiles(Game1 game)
        {
            int var = RandomNumber(0, backWidth);//same as backbufferedwidth
            //System.Diagnostics.Debug.WriteLine(Game1.SCALE);
            Vector2 tempPos;
            //Creep cr;
            for (int y = 0; y < backHeight; y++)
            {
                tempPos = new Vector2(var*Game1.SCALE ,y*Game1.SCALE);
                game.Path.Add(tempPos);
                this.tile = new Tile(tempPos, game.texTile, game);
                game.Tiles.Add(this.tile);

                //cr = new Creep(tempPos, game.texCreep, game);
                //game.Creeps.Add(cr);
                //System.Diagnostics.Debug.WriteLine("start");
                //System.Diagnostics.Debug.WriteLine(var);
                //System.Diagnostics.Debug.WriteLine(y);
            }
        }
예제 #4
0
 public User(Game1 game)
     : base(game)
 {
     //this.camera = camera;
 }
예제 #5
0
 public void spawnCreep(GameTime gameTime, Vector2 vec, Game1 game)
 {
     if (gameTime.TotalGameTime.TotalSeconds > spawnSeconds)
     {
         Creep cr = new Creep(vec, game.texCreep, game);
         game.Creeps.Add(cr);
         spawnSeconds = (int)(gameTime.TotalGameTime.TotalSeconds + 5);
     }
 }
예제 #6
0
 public void Shoot(Creep cr,Game1 game,Tower tower)
 {
     System.Diagnostics.Debug.WriteLine("HERE!");
     Projectile p = new Projectile(tower.pos, game.texProj, game);
     //p.Damage = this.Damage;
     //p.Speed = this.Speed;
     p.Damage = 5;
     p.Speed = 2;
     p.setCreep(cr);
     game.Projs.Add(p);
 }
예제 #7
0
 public void moveCreep(GameTime gameTime, Game1 game)
 {
     if (creepMoveCount < backHeight)
     {
         if (gameTime.TotalGameTime.TotalSeconds > seconds)
         {
             //Getting Vector2 of path
             int x = (int)game.Path.ElementAt(creepMoveCount).X;
             int y = (int)game.Path.ElementAt(creepMoveCount).Y;
             creepMoveCount++;//Kinda of an iterator to know where abouts in the path we are
             Vector2 temp;
             seconds = (int)(gameTime.TotalGameTime.TotalSeconds + game.Creeps[0].Speed);
             temp = new Vector2(x, y);
             for (int z = 0; z < game.Creeps.Count; z++)
             {
                 game.Creeps[z].setPos(temp);
             }
         }
     }
 }