public void performAction(GameTime time, Zombie target) { //base.performAction(); if (elapsedTime.Seconds > ATTACK_RATE) { elapsedTime = elapsedTime.Subtract(elapsedTime); target.doDamage(20); } elapsedTime += time.ElapsedGameTime; if (elapsedTime.Milliseconds > 900) { elapsedTime.Add(oneSecond); } }
private static void generateZombies(int numOfZombs) { Zombie curZombie; Rectangle range = new Rectangle(rand.Next(0, m_worldWidth), rand.Next(0, m_worldHeight), 100, 100); for (int i = 0; i < numOfZombs; i++) { curZombie = new Zombie(rand.Next((int)range.X, (int)range.X + range.Width), rand.Next((int)range.Y, (int)range.Y + range.Height), 25, 25); curZombie.setTexture(m_content.Load<Texture2D>("zombie")); curZombie.setFont(m_content.Load<SpriteFont>("displayInfoFont")); curZombie.setDisplayArea(new Rectangle(0, m_windowHeight - 100, m_windowWidth, 100)); curZombie.setDisplayText("Can't see this"); zombies.Add(curZombie); //units.Add(curZombie); //possibly add in to make zombies attack each other? Thread.Sleep(10); } }