public void performAction(GameTime time, Material mat) { //base.performAction(); if (elapsedTime.Seconds > WORK_RATE) { elapsedTime = elapsedTime.Subtract(elapsedTime); mat.doDamage(20); m_rotation = (float)Math.Atan2(m_position.X - mat.X, mat.Y - m_position.Y); } elapsedTime += time.ElapsedGameTime; if (elapsedTime.Milliseconds > 900) { elapsedTime.Add(oneSecond); } }
private static void generateWater(int numOfWater) { Material curMat; Rectangle range = new Rectangle(rand.Next(0, m_worldWidth), rand.Next(0, m_worldHeight), 100, 100); for (int i = 0; i < numOfWater; i++) { curMat = new Material(rand.Next((int)range.X, (int)range.X + range.Width), rand.Next((int)range.Y, (int)range.Y + range.Height), 50, 50, Material.type.Water); curMat.setTexture(m_content.Load<Texture2D>("water")); curMat.setFont(m_content.Load<SpriteFont>("displayInfoFont")); curMat.setDisplayArea(new Rectangle(0, m_windowHeight - 100, m_windowWidth, 100)); curMat.setDisplayText("Can't see this"); worldResources.Add(curMat); units.Add(curMat); } }