Example #1
0
 public void Add(NpcCar npc)
 {
     npc.OnWantsCollisionCheck = OnCollisionCheck;
     npcs.Add(npc);
     FireOnAdd(npc);
     currentCount++;
 }
Example #2
0
 public void FireOnRemove(NpcCar npc)
 {
     if (OnRemove != null)
     {
         NpcMangerEventArg arg = new NpcMangerEventArg(npc);
         OnRemove(this, arg);
     }
 }
Example #3
0
 public void FireOnAdd(NpcCar npc)
 {
     if (OnAdd != null)
     {
         NpcManagerEventArg arg = new NpcManagerEventArg(npc);
         OnAdd(this, arg);
     }
 }
Example #4
0
        public void Update(float deltaTime)
        {
            Random random = Game1.Singleton.Random;

            currentTime += deltaTime;

            if (currentTime >= Interval)
            {
                if (MaxCount != currentCount)
                {
                    NpcCar car = new NpcCar();

                    int rand = random.Next(0, 4);

                    if (rand == 0)
                    {
                        car.CopyCat(CarGarage.Singleton.Get("Yellow"));
                    }
                    else if (rand == 1)
                    {
                        car.CopyCat(CarGarage.Singleton.Get("Bus_Blue"));
                    }
                    else if (rand == 2)
                    {
                        car.CopyCat(CarGarage.Singleton.Get("Bus_Green"));
                    }
                    car.Y = -300;
                    Add(car);
                }
                currentTime = 0;
            }
        }
Example #5
0
 public void Remove(NpcCar npc)
 {
     npcs.Remove(npc);
     FireOnRemove(npc);
     currentCount--;
 }
Example #6
0
 public NpcMangerEventArg(NpcCar npcCar)
 {
     NpcCar = npcCar;
 }
Example #7
0
        public void Update(float deltaTime)
        {
            Random random = Game1.Singleton.Random;

            currentTime += deltaTime;

            if (currentTime >= Interval)
            {
                if (MaxCount != currentCount)
                {
                    NpcCar car = new NpcCar();

                    int rand = random.Next(0, 6);

                    if (rand == 0 || rand == 2 || rand == 3)
                    {
                        car.CopyCat(CarGarage.Singleton.Get("Orange"));
                    }
                    else if (rand == 4)
                    {
                        car.CopyCat(CarGarage.Singleton.Get("Bus_Blue"));
                    }
                    else
                    {
                        car.CopyCat(CarGarage.Singleton.Get("Bus_Green"));
                    }
                    car.Y = -300;
                    Add(car);
                }
                currentTime = 0;
            }

            if (npcs != null)
            {
                NpcCar[] arr = npcs.ToArray();

                for (int i = 0; i < arr.Count(); i++)
                {
                    for ( int j = 0; j < arr.Count(); j++)
                    {
                        if ( i != j )
                        {
                            this.ParseCarsCollisionCheck(arr[i], arr[j], deltaTime);
                        }
                    }
                }
            }
        }