protected override void LoadContent() { Window.AllowUserResizing = true; spriteBatch = new SpriteBatch(GraphicsDevice); fontTexture = new GameFont(); fontTexture.Load(Content); plane = new Plane(Content, true, graphics.GraphicsDevice.Viewport.Width, graphics.GraphicsDevice.Viewport.Height); plane2 = new Plane(Content, false, graphics.GraphicsDevice.Viewport.Width, graphics.GraphicsDevice.Viewport.Height); viewportRect = new Rectangle(0, 0, graphics.GraphicsDevice.Viewport.Width, graphics.GraphicsDevice.Viewport.Height); backgroundTexture = Content.Load<Texture2D>("sky2"); Town = new WorldObj(); Town.Load(Content.Load<Texture2D>("basna")); tych = new cloud(); tych.Load(Content, graphics.GraphicsDevice.Viewport.Width, graphics.GraphicsDevice.Viewport.Height); Bonus = new bonusObj(Content); menu = new Menu1(); bang = new ColishunMeneger(); menu.Load(Content); }
public void Colishun(ref Plane Left, ref Plane Right, Rectangle Tower, ref bonusObj Bonus) { Rectangle RectanLeft, RectanRight; Rectangle RecTower; RecTower = new Rectangle(Tower.X + 8, Tower.Y + 5, Tower.Width-20, Tower.Height); Rectangle RecBonus = new Rectangle((int)Bonus.position.X- Bonus.SpriteObj[0].texture.Width/2, (int)Bonus.position.Y - Bonus.SpriteObj[0].texture.Height/2, Bonus.SpriteObj[0].RectangleSprite.Width, Bonus.SpriteObj[0].RectangleSprite.Height); RectanLeft = new Rectangle(Left.sprite.RectangleSprite.X - Left.sprite.RectangleSprite.Width / 2, Left.sprite.RectangleSprite.Y - Left.sprite.RectangleSprite.Height / 2, Left.sprite.RectangleSprite.Width, Left.sprite.RectangleSprite.Height - 10); RectanRight = new Rectangle(Right.sprite.RectangleSprite.X - Right.sprite.RectangleSprite.Width / 2, Right.sprite.RectangleSprite.Y - Right.sprite.RectangleSprite.Height / 2, Right.sprite.RectangleSprite.Width, Right.sprite.RectangleSprite.Height - 10); if (Intersection(RecBonus, 0, RectanLeft, Left.rotation) && Left.alive == true && Bonus.life == true)// лівий з бонусом { switch (Bonus.bonusNum) { case 0: Left.life += 50; break; case 1: Left.SetSpeedBonus(); break; case 2: Left.SetBulletHarm(); break; case 3: { Left.undead = true; Left.TimePrevBonus = 0; }; break; } Bonus.life = false; } if (Intersection(RecBonus, 0, RectanRight, Right.rotation) && Right.alive == true && Bonus.life == true) { switch (Bonus.bonusNum) { case 0: Right.life += 50; break; case 1: Right.SetSpeedBonus(); break; case 2: Right.SetBulletHarm(); break; case 3: { Right.undead = true; Right.TimePrevBonus = 0; }; break; } Bonus.life = false; } if (Left.alive == false) { Left.NormalizeBulletHarm(); } if (Right.alive == false) { Right.NormalizeBulletHarm(); } if (Intersection(RecTower, 0, RectanLeft, Left.rotation) && Left.alive == true) { Left.alive = false; } if (Intersection(RecTower, 0, RectanRight, Right.rotation) && Right.alive == true) { Right.alive = false; } for (int i = 0; i < Right.CoutBullet; i++) // червоний стріляє в зелений { if (Intersection(RecTower, 0, Right.AreaBalls[i].SpriteBulet.RectangleSprite, Right.AreaBalls[i].rotation) && Right.AreaBalls[i].alive == true) // кулі червоного в башню посеред карти { Right.AreaBalls[i].alive = false; } if (Intersection(RectanLeft, Left.rotation, Right.AreaBalls[i].SpriteBulet.RectangleSprite, Right.AreaBalls[i].rotation) && Right.AreaBalls[i].alive == true) { if (Left.undead == false) { Left.life -= Right.bulletKick; } Right.AreaBalls[i].alive = false; } } for (int i = 0; i < Left.CoutBullet; i++) // зелений стріляє в червоний { if (Intersection(RecTower, 0, Left.AreaBalls[i].SpriteBulet.RectangleSprite, Left.AreaBalls[i].rotation) && Left.AreaBalls[i].alive == true) // кулі зеленого в башню посеред карти { Left.AreaBalls[i].alive = false; } // зелений стріляє в червоний if (Intersection( RectanRight, Right.rotation,Left.AreaBalls[i].SpriteBulet.RectangleSprite, Left.AreaBalls[i].rotation) && Left.AreaBalls[i].alive == true) { if (Right.undead == false) { Right.life -= Left.bulletKick; } Left.AreaBalls[i].alive = false; } } if (Intersection(RectanLeft, Left.rotation, RectanRight, Right.rotation)) { if (Left.alive == true && Right.alive == true && this.OneColishinPlane == 0) { if (Left.undead == false) { Left.life -= 25; } if (Right.undead == false) { Right.life -= 25; } ++this.OneColishinPlane; } } else { this.OneColishinPlane = 0; } }