public void Game_OnGameUpdate() { //Even if it doesnt consume a lot of resources with 20 updatest second works k if (SkillshotData.CollisionObjects.Count() > 0 && SkillshotData.CollisionObjects != null && Environment.TickCount - _lastCollisionCalc > 50) { _lastCollisionCalc = Environment.TickCount; _collisionEnd = Collision.GetCollisionPoint(this); } //Update the missile position each time the game updates. if (SkillshotData.Type == SkillShotType.SkillshotMissileLine) { Rectangle = new SkillshotGeometry.Rectangle(GetMissilePosition(0), CollisionEnd, SkillshotData.Radius); UpdatePolygon(); } //Spells that update to the Caster position. if (SkillshotData.MissileFollowsUnit) { if (Caster.IsVisible) { EndPosition = Caster.ServerPosition.To2D(); Direction = (EndPosition - StartPosition).Normalized(); UpdatePolygon(); } } }
public Skillshot(DetectionType detectionType, SkillshotData skillshotData, int startT, Vector2 startPosition, Vector2 endPosition, Obj_AI_Base caster) { DetectionType = detectionType; SkillshotData = skillshotData; StartTick = startT; StartPosition = startPosition; EndPosition = endPosition; MissilePosition = startPosition; Direction = (endPosition - startPosition).Normalized(); Caster = caster; //Create the spatial object for each type of skillshot. switch (skillshotData.Type) { case SkillShotType.SkillshotCircle: Circle = new SkillshotGeometry.Circle(CollisionEnd, skillshotData.Radius); break; case SkillShotType.SkillshotLine: Rectangle = new SkillshotGeometry.Rectangle(StartPosition, CollisionEnd, skillshotData.Radius); break; case SkillShotType.SkillshotMissileLine: Rectangle = new SkillshotGeometry.Rectangle(StartPosition, CollisionEnd, skillshotData.Radius); break; case SkillShotType.SkillshotCone: Sector = new SkillshotGeometry.Sector(startPosition, CollisionEnd - startPosition, skillshotData.Radius * (float)Math.PI / 180, skillshotData.Range); break; case SkillShotType.SkillshotRing: Ring = new SkillshotGeometry.Ring(CollisionEnd, skillshotData.Radius, skillshotData.RingRadius); break; } UpdatePolygon(); // Create the polygon }