//public override Fire New(int width, int height, Vector2 startpos, Vector2 endpos) //{ // return new BlasterFire(startpos, endpos, true); //} //public override void Shoot(World world, GameTime gameTime, Vector2 startPos) //{ // MouseState ms = Mouse.GetState(); // ellapsedClickTime += (float)gameTime.ElapsedGameTime.TotalMilliseconds; // if (ms.LeftButton == ButtonState.Pressed && mouseStatePast.LeftButton == ButtonState.Released && ellapsedClickTime > reload) // { // ellapsedClickTime = 0; Vector2 endPos = new Vector2((int)startPos.X + (-WinWIDTH / 2) + ms.Position.X, startPos.Y + ms.Position.Y + (-WinHEIGHT / 2)); // BlasterFire bul = new BlasterFire(130, 15, startPos, endPos); // bul.isEn = false; // world.ToAdd.Add(bul); // } // mouseStatePast = ms; //} public object Clone() { // BlasterFire b = new BlasterFire(startPosition, direction, isEnemy); BlasterFire b = (BlasterFire)MemberwiseClone(); b.rec = new RectangleV3(new Vector2(rec.r.X, rec.r.Y), rec.kx, rec.ky, rec.direction, rec.r.Width, rec.r.Height); return(b); }
public override void Shoot(World world, Vector2 startPosition, Vector2 direction) { //if (ellapsedTimeFromLastShoot > physicalFrequencyShooting) if ((mouseStatePast.LeftButton == ButtonState.Released || isEnemy) && ellapsedTimeFromLastShoot > physicalFrequencyShooting) { if (!isEnemy) { blasterSound.Play(); } BlasterFire b = new BlasterFire(startPosition, direction, isEnemy); b.fl = 1; world.ToAdd.Add(b); ellapsedTimeFromLastShoot = 0; } }
public override void Update(World world, GameTime gameTime) { foreach (Entity e in world.entities) { if (e is Wall) { Wall wall = (Wall)e; if (rec.Intersect(wall.rectangle)) { world.ToKill.Add(this); } } else if (isEnemy) { if (e is MainHero) { MainHero h = (MainHero)e; if (rec.Intersect(h.rectangle)) { h.health -= damage; damageHeroSound.Play(0.8f, 0f, 0f); //world.ToKill.Add(this); } } } else { if (e is Enemy) { Enemy en = (Enemy)e; if (rec.Intersect(en.rectangle)) { en.health -= damage; damageMonSound.Play(0.8f, 0f, 0f); //world.ToKill.Add(this); } } } } position += direction * speed; currentExistingTime += (float)gameTime.ElapsedGameTime.TotalMilliseconds; rec.r.X = (int)position.X; rec.r.Y = (int)position.Y; if (currentExistingTime >= existingTime) { world.ToKill.Add(this); } //else //{ // rec2 = new RectangleV2(velocity, width, height, position); // rectangle.X = (int)position.X; // rectangle.Y = (int)position.Y; //} if (fl == 1) { mrelc += (float)gameTime.ElapsedGameTime.TotalMilliseconds; if (currentExistingTime < existingTime && mrelc > mrel) { mrelc = 0; BlasterFire bl = (BlasterFire)Clone(); fl = 0; bl.position = startPosition; bl.rec.r.X = (int)startPosition.X; bl.rec.r.Y = (int)startPosition.Y; //КЛОНИРОВАТЬ!!!! world.ToAdd.Add(bl); } } }