Exemplo n.º 1
0
        public void Update(float step_time)
        {
            spatialGrid.ClearAll();

            // checkPickupsCollisionEachOther(step_time);

            this.checkBulletVsEntityCollisions(step_time);


            treeMonsters.Clear();

            //treeBullets.Clear();


            //update bullets
            int bulletCount = bullets.Count;

            for (int i = 0; i < bulletCount; i++)
            {
                if (bullets[i].isActive())
                {
                    bullets[i].Update(step_time);
                    //treeBullets.AddEntity(bullets[i]);
                }
                else
                {
                    bullets.RemoveAt(i);
                    i--;
                    bulletCount = bullets.Count;
                }
            }

            //update monsters
            int monsterCount = monsters.Count;

            for (int i = 0; i < monsterCount; i++)
            {
                if (monsters[i].isActive())
                {
                    monsters[i].Update(step_time);
                    treeMonsters.AddEntity(monsters[i]);
                }
                else
                {
                    monsters.RemoveAt(i);
                    i--;
                    monsterCount = monsters.Count;
                }
            }

            // update pickups
            List <int> keysToRemove = new List <int>();

            foreach (var item in pickups)
            {
                cPickupAble pickup = item.Value;
                if (pickup.isActive())
                {
                    pickup.Update(step_time);
                }
                else
                {
                    //pickups.Remove(item.Key);
                    keysToRemove.Add(item.Key);
                }
            }

            foreach (int key in keysToRemove)
            {
                pickups.Remove(key);
            }

            this.checkPlayerCanUseOrPickupOrInteract();

            /*
             * int pickupCount = pickups.Count;
             * for (int i = 0; i < pickupCount; i++)
             * {
             *  if (pickups[i].isActive())
             *  {
             *      pickups[i].Update(step_time);
             *  }
             *  else
             *  {
             *      pickups.RemoveAt(i);
             *      i--;
             *      pickupCount = pickups.Count;
             *  }
             * }
             */
        }
Exemplo n.º 2
0
 public comPlacePickup(cGameScene scene, cPickupAble item) : base(scene)
 {
     this.item = item;
 }
Exemplo n.º 3
0
 public void AddPickup(cPickupAble item)
 {
     pickups.Add(item.ID, item);
 }