Esempio n. 1
0
 public Reproduce(Creature partner)
 {
     this.partner = partner;
 }
Esempio n. 2
0
 public FightCreature(Creature enemy)
 {
     this.enemy = enemy;
 }
Esempio n. 3
0
        public Entity ResourceInRadius(float radius, Creature c)
        {
            foreach (Entity ent in entities)
            {
                if ((ent.Position + ent.Origin - (c.Position + c.Origin)).Length() <= radius)
                {
                    if (c is Herbivore)
                    {
                        if (ent is Resource)
                            return ent;
                    }
                    else if (c is Carnivore)
                    {
                        if (ent is Herbivore || ent is Omnivore)
                            return ent;
                    }
                    else if (c is Omnivore)
                    {
                        if (ent is Herbivore || ent is Carnivore || ent is Resource)
                            return ent;
                    }
                }
            }

            return null;
        }
Esempio n. 4
0
        protected override void Update(GameTime gameTime)
        {
            if (Keyboard.GetState().IsKeyDown(Keys.Escape))
                Exit();

            if (Mouse.GetState().LeftButton == ButtonState.Pressed)
            {
                //world.ResourceManager.addResource(Mouse.GetState().X, Mouse.GetState().Y);
                Entity ent = world.EntityManager.AtPosition(new Vector2(Mouse.GetState().X, Mouse.GetState().Y));
                if (ent != null && ent is Creature) {
                    inspecting = (Creature)ent;
                }
                Game1.particleEffects["Heart"].Trigger(new Vector2(Mouse.GetState().X, Mouse.GetState().Y));
            }

            float deltaSeconds = (float)gameTime.ElapsedGameTime.TotalSeconds;

            foreach (KeyValuePair<string, ParticleEffect> particle in particleEffects)
            {
                ParticleEffect particleEffect = particle.Value;
                particleEffect.Update(deltaSeconds);
            }

            world.Update(gameTime);
            base.Update(gameTime);
        }
Esempio n. 5
0
        public void removeCreature(Creature creature)
        {
            if (creatures.Contains(creature))
                creatures.Remove(creature);

            gameWorld.EntityManager.RemoveEntity(creature);
        }
Esempio n. 6
0
 public void addCreature(Creature creature)
 {
     if (!creatures.Contains(creature))
         creatures.Add(creature);
     gameWorld.EntityManager.AddEntity(creature);
 }