Пример #1
0
 public void loadcontent(ContentManager content)
 {
     this.content = content;
     texture = content.Load<Texture2D>("default");
     texturebullet = content.Load<Texture2D>("bullet");
     bullets.loadcontent(this);
     players.loadcontent(this);
     for (int i = 0; i < towersmash.maxnumplayers; i++)
     {
         if (towersmash.players[i])
         {
             Iid id = new Iid(i, UnitID.player);
             switch (towersmash.characters[i])
             {
                 case playertype.bashy:
                     this.players[i] = new p_bashy(id);
                     break;
                 case playertype.shifty:
                     this.players[i] = new p_shifty(id);
                     break;
                 case playertype.tanky:
                     this.players[i] = new p_tanky(id);
                     break;
                 default:
                     break;
             }
             this.players[i].loadcontent(this);                    
             // NOTE: WARNING IMPROPER USAGE OF UNITPOOL HERE MAJOR HACK THIS SHOULD ONLY BE USED FOR THE PLAYERS NOTHING ELSE
             players.unitpool.active[i] = true;
             players.unitpool.CheckedOut.AddLast(i);
             // END HACK
             players[i].add(this.physics);
         }
     }
     towers.loadcontent(this);
     obstacles.loadcontent(this);
     if (!SoundManager.IsInitialized)
         SoundManager.Initialize(this.game);
     if (!SoundManager.IsLoaded)
     {
         SoundManager.LoadSound("bulletsound");
         //PUT MORE SOUNDS HERE
     }
     particles.loadcontent();
 }
Пример #2
0
        //private double pickuptimer = 0;
        //private int interval = 2000;
        //Random random;
        //Vector2 position = new Vector2();
        //public void createpickups(GameTime gameTime, Rectangle arenarect)
        //{
        //    if (pickups.unitpool.ActiveCount < 8)
        //    {
        //        //increment counter
        //        pickuptimer += gameTime.ElapsedGameTime.TotalMilliseconds;
        //        //if we've gone past the interval
        //        if (pickuptimer > interval)
        //        {
        //            //reset the time
        //            pickuptimer = 0;
        //            interval = random.Next(1000, 3000);
        //            int i = random.Next(0, pickupdefinitions.unitpool.ActiveCount);
        //            //get a pickup to instantiate from the pool
        //            pickup pickupdefinition = pickupdefinitions[i];
        //            pickup newpickup = pickups.unitpool.Retrieve().Item;
        //            //clone the pick-up with a pre-existing definition
        //            newpickup.clone(pickupdefinition);
        //            //add to the physics simulator
        //            newpickup.add(physics);
        //            //create a random location which is on the field
        //            position.X = random.Next(arenarect.X + 100, arenarect.X + arenarect.Width - 100);
        //            position.Y = random.Next(arenarect.Y + 100, arenarect.Y + arenarect.Height - 100);
        //            //todo: maybe make sure a pick-up isn't too close to any player?
        //            newpickup.body.Position = position;
        //        }
        //    }
        //}

        public void remove(Iid id)
        {
            switch (id.UnitID)
            {
                case (UnitID.bullet):
                    bullets.remove(id);
                    break;
                case (UnitID.tower):
                    towers.remove(id);
                    break;
                case(UnitID.obstacle):
                    obstacles.remove(id);
                    break;
                case (UnitID.player):
                    players.remove(id);
                    towersmash.players[id.NodeID] = false;
                    towersmash.numberofplayers--;
                    //todo: impliment something cool
                    break;
                default:
                    throw new NotImplementedException();
            }
        }
Пример #3
0
 public p_bashy(Iid id)
     : base()
 {
     base.id = id;
 }
Пример #4
0
 public p_shifty(Iid id)
     : base()
 {
     base.id = id;
 }
Пример #5
0
 public p_tanky(Iid id)
     : base()        
 {
     base.id = id;
 }