X-Git-Url: https://git.r.bdr.sh/rbdr/super-polarity/blobdiff_plain/4fc09567c557a1110180940cca40fd7144921026..8ae8ea0d77ec654dd693b3912562b07a2b539b0f:/SuperPolarity/ActorManager.cs?ds=sidebyside diff --git a/SuperPolarity/ActorManager.cs b/SuperPolarity/ActorManager.cs index f5587b9..3a9b0db 100644 --- a/SuperPolarity/ActorManager.cs +++ b/SuperPolarity/ActorManager.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -47,6 +47,11 @@ namespace SuperPolarity foreach (Actor actor in Actors) { actor.Draw(spriteBatch); + + if (actor.GetType ().IsAssignableFrom (typeof(MainShip))) { + var mainActor = (MainShip)actor; + mainActor.ResetEnemyModification (); + } } } @@ -68,7 +73,9 @@ namespace SuperPolarity { Actor other = Actors[j]; - CheckCollision(actor, other); + if (actor.Collides && other.Collides) { + CheckCollision(actor, other); + } if (actor.GetType().IsSubclassOf(typeof(Ship)) && other.GetType().IsSubclassOf(typeof(Ship))) { @@ -100,6 +107,16 @@ namespace SuperPolarity var angle = (float) Math.Atan2(dy, dx); var otherAngle = (float)Math.Atan2(-dy, -dx); + if (actor.GetType ().IsAssignableFrom (typeof(MainShip))) { + var mainActor = (MainShip)actor; + mainActor.UpdateEnemyModification (other); + } + + if (other.GetType ().IsAssignableFrom (typeof(MainShip))) { + var mainOther = (MainShip)other; + mainOther.UpdateEnemyModification (actor); + } + if (linearDistance < actor.MagneticRadius || linearDistance < other.MagneticRadius) { actor.Magnetize(other, (float)linearDistance, angle);