Esempio n. 1
0
        public override object Clone()
        {
            LinearSpell s = new LinearSpell(ID, Team, Position, Position + Velocity, Type, Owner);

            s.Clone(this);
            return(s);
        }
Esempio n. 2
0
        public override void Clone(IEntity e)
        {
            LinearSpell s = (LinearSpell)e;

            base.Clone(s);
            Type = s.Type;
        }
Esempio n. 3
0
		public override object Clone()
		{
			LinearSpell s = new LinearSpell(ID, Team, Position, Position + Velocity, Type, Owner);
			s.Clone(this);
			return s;
		}
Esempio n. 4
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;
		}
Esempio n. 5
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;
		}
Esempio n. 6
0
		void CastTowerSpell(Teams team, Vec2 origin, Vec2 target)
		{
			LinearSpell spell = new LinearSpell(
                IDGenerator.GenerateID(),
                team,
                origin,
                target,
                SpellTypes.Tower_Shot,
                null);

			CastSpell(spell, target);
		}
Esempio n. 7
0
		void CastSpell(LinearSpell spell, Vec2 target)
		{
			Match.CurrentState.AddEntity(spell);
			ActiveSpells.Add(spell);

			float castTime = (float)Server.Instance.GetTime().TotalSeconds;
			LinearSpell copy = (LinearSpell)spell.Clone();

			AddRemarkableEvent(ServerCommand.SpellCast,
			                   (NetBuffer msg) => {
				ulong id = copy.ID;
				ulong owner = copy.Owner != null ? copy.Owner.ID : IDGenerator.NO_ID;
				byte type = (byte)copy.Type;
				float time = castTime;
				float px = copy.Position.X;
				float py = copy.Position.Y;
				float vx = copy.Velocity.X;
				float vy = copy.Velocity.Y;
				float cd = (float)copy.Info.Cooldown.TotalSeconds;
				float range = copy.Info.Range;
				float width = copy.CollisionWidth;

				msg.Write(id);
				msg.Write(owner);
				msg.Write(type);
				msg.Write(time);
				msg.Write(px);
				msg.Write(py);
				msg.Write(vx);
				msg.Write(vy);
				msg.Write(cd);
				msg.Write(range);
				msg.Write(width);
			});
		}
Esempio n. 8
0
		const double RADIANS_BETWEEN_PROJECTILES = Math.PI / 36.0; // ~5 degrees
		void CastChampionSpell(ICharacter champ, PlayerAction action)
		{
			Debug.Assert(action.Target != null);

			// aim in the direction of the spell
			champ.FacingLeft = action.Target.X < champ.Position.X + champ.CollisionWidth / 2f;

			SpellTypes type = ChampionTypesHelper.GetSpellFromAction(champ.Type, action.Type);
			int projectiles = SpellsHelper.Info(type).Projectiles;
			Vec2 spawn = champ.GetHandsPosition();

			double angle = 0.0;
			if (action.Target != null) {
				Vec2 dir = action.Target - spawn;
				angle = Math.Atan2(dir.Y, dir.X); // current angle
				double completeArc = RADIANS_BETWEEN_PROJECTILES * (projectiles - 1); // complete arc that we'll cover
				angle -= completeArc / 2f; // start from the lowest angle
			}

			for (int i = 0; i < projectiles; ++i) {
				Vec2 dir = Vec2.Zero;
				if (action.Target != null) {
					double current = angle + i * RADIANS_BETWEEN_PROJECTILES;
					dir = new Vec2((float)Math.Cos(current), (float)Math.Sin(current));
				}

				LinearSpell spell = new LinearSpell(
					                   IDGenerator.GenerateID(),
					                   champ.Team,
									   spawn,
									   spawn + dir,
					                   type,
					                   champ);

				CastSpell(spell, action.Target);
			}
		}