Пример #1
0
 public static void simulateActions()
 {
     for (int i = 0; i < Scene.AllPlanets.Count(); i++)
     {
         for (int m = 0; m < Scene.AllPlanets[i].citizens.Count() - 1; m++)
         {
             if (Scene.AllPlanets[i].citizens[m] != null && Scene.AllPlanets[i].citizens[m + 1] != null)
             {
                 if (Distance(Scene.AllPlanets[i].citizens[m].Location, Scene.AllPlanets[i].citizens[m + 1].Location) <= inRangeOfAttackDistance)
                 {
                     if (RandomG.RandomNumbers(-100, 100) < 0)
                     {
                         Console.WriteLine("{0} attacked {1}", Scene.AllPlanets[i].citizens[m], Scene.AllPlanets[i].citizens[m + 1]);
                         Scene.AllPlanets[i].citizens[m].Attack(Scene.AllPlanets[i].citizens[m + 1]);
                     }
                     else
                     {
                         if (Scene.AllPlanets[i].citizens[m].GetType() == Scene.AllPlanets[i].citizens[m + 1].GetType())
                         {
                             Entity q = new Entity(RandomG.RandomName());
                             mPlayer.AddCitizen(Scene.AllPlanets[i], q);
                             Console.WriteLine("{0} and {1} have baby-{2}", Scene.AllPlanets[i].citizens[m], Scene.AllPlanets[i].citizens[m + 1], q.Name);
                         }
                         else
                         {
                             Console.WriteLine("{0} and {1} tried to have baby but are diferent types", Scene.AllPlanets[i].citizens[m], Scene.AllPlanets[i].citizens[m + 1]);
                         }
                     }
                     Thread.Sleep(5000);
                 }
             }
         }
     }
 }
Пример #2
0
        // Create a creatute on a planet.
        public static void CreateEntity(EntityType creature, Planet planet)
        {
            switch (creature)
            {
            case EntityType.animal:
                Animal a = new Animal(RandomG.RandomName());
                planet.AddCitizen(a);
                break;

            case EntityType.entity:
                Entity e = new Entity(RandomG.RandomName());
                planet.AddCitizen(e);
                break;

            case EntityType.god:
                God g = new God(RandomG.RandomName());
                planet.AddCitizen(g);
                break;

            case EntityType.human:
                Human h = new Human(RandomG.RandomName());
                planet.AddCitizen(h);
                break;

            case EntityType.unknown:
                Entity u = new Entity(RandomG.RandomName());
                planet.AddCitizen(u);
                break;

            default:
                throw new ArgumentOutOfRangeException("there is no such type of creature");
                break;
            }
        }
Пример #3
0
 public AEntity()
 {
     this.Name     = RandomG.RandomName();
     this.Energy   = 10;
     this.Power    = 10;
     this.Size     = 10;
     this.Weight   = 10;
     this.Location = new Point2D();
     this.State    = State.Unknown;
 }