Example #1
0
		public bool Intersects(Rect b)
		{
			return !(b.Left > Right ||
				b.Right < Left ||
				b.Top > Bottom ||
				b.Bottom < Top);
		}
Example #2
0
		void TestRectSides(Rect r, float left, float right, float top, float bottom, string message)
		{
			Assert.AreEqual(left, r.Left, message + " left");
			Assert.AreEqual(right, r.Right, message + " right");
			Assert.AreEqual(top, r.Top, message + " top");
			Assert.AreEqual(bottom, r.Bottom, message + " bottom");
		}
Example #3
0
		void TestCtor(Rect r, float x, float y, float width, float height, string message)
		{
			Assert.AreEqual(x, r.X, message + " x");
			Assert.AreEqual(y, r.Y, message + " y");
			Assert.AreEqual(width, r.Width, message + " width");
			Assert.AreEqual(height, r.Height, message + " height");
		}
		public DrawableRectangle(Rect rect, Color tint) 
			: this(new Rectangle(
				(int)rect.X, (int)rect.Y, (int)rect.Width, (int)rect.Height),
			       tint)
		{
		}
Example #5
0
		bool CheckForSpellPlayerCollisions(LinearSpell spell, Rect spellRect, Teams enemyTeam)
		{
			foreach (ServerClient client in Clients.Values) { // check for collisions with players
				// With ennemies
				if (client.ChampStats.Alive && // not a dead target
				    spell.Info.Kind == SpellKind.OffensiveSkillshot && // offensive spell
				    client.Champion.Team == enemyTeam && // against an ennemy
				    client.Champion.CreateCollisionRectangle().Intersects(spellRect)) { // we hit him

					client.ChampStats.Hurt(spell.Info.Value); // we hurt him
					if (spell.Owner != null) {
						client.ChampStats.GoInCombat(spell.Owner.ID);
					}
					if (spell.Info.OnActivation != null)
						spell.Info.OnActivation(
							new WorldInfoForSpell(client.Champion, spell.Velocity));
					return true;
				}
				// With allies
				else if (client.ChampStats.Alive && // not a dead target
				         spell.Info.Kind == SpellKind.DefensiveSkillshot && // deffensive spell
				         client.Champion.Team == spell.Team &&  // on an ally
				         (spell.Owner == null || client.Champion.ID != spell.Owner.ID) && // that is NOT us
				         client.Champion.CreateCollisionRectangle().Intersects(spellRect)) { // we hit him

					client.ChampStats.Heal(spell.Info.Value); // we heal him
					return true;
				}
			}
			return false;
		}
Example #6
0
		bool CheckForSpellStructuresCollisions(LinearSpell spell, Rect spellRect, TeamStructures enemyStructures)
		{
			foreach (IStructure structure in enemyStructures.Structures) {
				if (structure.Alive && // not a destroyed target
				    enemyStructures.IsDestructible(structure.Type) && // not an indestructible target
					spell.Info.Kind == SpellKind.OffensiveSkillshot && // offensive spell
					structure.Rectangle.Intersects(spellRect)) { // we hit it

					structure.Hurt(spell.Info.Value); // we hurt it

					return true;
				}
			}

			return false;
		}
Example #7
0
		public static Vec2 Center(Rect r)
		{
			return new Vec2(r.Left + r.Width / 2f,
			                r.Top + r.Height / 2f);
		}
Example #8
0
		public static bool Intersects(Rect a, Rect b)
		{
			return a.Intersects(b);
		}