Esempio n. 1
0
 public void TakeProjectile(LSProjectile projectile)
 {
     if (Agent.IsActive && HealthAmount >= 0) {
         if (OnTakeProjectile .IsNotNull ())
         {
             OnTakeProjectile (projectile);
         }
         TakeRawDamage (projectile.CheckExclusiveDamage (Agent.Tag));
     }
 }
Esempio n. 2
0
        public static int GetStateHash()
        {
            int hash = 23;

            for (int i = 0; i < PeakCount; i++)
            {
                if (ProjectileActive[i])
                {
                    LSProjectile proj = ProjectileManager.ProjectileBucket[i];
                    hash ^= proj.GetStateHash();
                }
            }
            return(hash);
        }
Esempio n. 3
0
        public static int GetStateHash()
        {
            int hash = 23;

            for (int i = ProjectileBucket.PeakCount - 1; i >= 0; i--)
            {
                if (ProjectileBucket.arrayAllocation[i])
                {
                    LSProjectile proj = ProjectileManager.ProjectileBucket[i];
                    hash ^= proj.GetStateHash();
                }
            }
            return(hash);
        }
Esempio n. 4
0
        protected virtual void OnFire()
        {
            long         appliedDamage = Damage;
            LSProjectile projectile    = ProjectileManager.Create(
                ProjCode,
                this.Agent,
                this.ProjectileOffset,
                this.TargetAllegiance,
                (other) => this.Agent.Healther.IsNotNull(),
                (agent) => agent.Healther.TakeRawDamage(appliedDamage));

            projectile.InitializeHoming(this.Target);
            projectile.TargetPlatform = TargetPlatform;
            ProjectileManager.Fire(projectile);
        }
Esempio n. 5
0
        private void OnHit()
        {
            switch (this.DamageBehavior)
            {
            case DamageType.Single:
                this.DealDamage(Target);
                break;

            case DamageType.Area:
                LSProjectile.ApplyArea(this.TargetPosition, this.Radius, (this.AllButFriendlyAction), this.DealDamageAction);
                break;

            case DamageType.Cone:
                LSProjectile.ApplyCone(this.Position, this.Source.Body.Rotation, this.Radius, this.Angle, this.AllButFriendlyAction, DealDamageAction, this.TargetPlatform);
                break;
            }
        }
        public static void EndProjectile(LSProjectile projectile)
        {
            int id = projectile.ID;
            if (ProjectileActive[id] == false) {
                return;
            }
            if (ProjectileBucket[id] != projectile)
            {
                return;
            }
            ProjectileActive[id] = false;
            ProjectileBucket[id] = null;
            OpenSlots.Add (id);

            CacheProjectile (projectile);
            projectile.Deactivate ();
        }
 public static LSProjectile Create(string projCode, LSAgent source, LSAgent target, long damage)
 {
     FastStack<LSProjectile> pool = ProjectilePool[projCode];
     if (pool.Count > 0)
     {
         curProj = pool.Pop ();
     }
     else {
         curProj = NewProjectile (projCode);
     }
     int id = GenerateID ();
     ProjectileBucket[id] = curProj;
     ProjectileActive[id] = true;
     curProj.Initialize (id, source,target);
     curProj.Damage = damage;
     return curProj;
 }
Esempio n. 8
0
        public static LSProjectile Create(string projCode, LSAgent source, Vector3d offset, AllegianceType targetAllegiance, Func <LSAgent, bool> agentConditional, Action <LSAgent> hitEffect)
        {
            Vector2d        relativePos      = offset.ToVector2d();
            Vector2d        worldPos         = relativePos.Rotated(source.Body.Rotation) + source.Body.Position;
            Vector3d        pos              = new Vector3d(worldPos.x, worldPos.y, offset.z + source.Body.HeightPos);
            AgentController sourceController = source.Controller;
            LSProjectile    proj             = Create(
                projCode,
                pos,
                agentConditional,
                (bite) => {
                return((sourceController.GetAllegiance(bite) & targetAllegiance) != 0);
            }
                ,
                hitEffect);

            return(proj);
        }
        private static void CacheProjectile(LSProjectile projectile)
        {
            ProjectilePool[projectile.MyProjCode].Add(projectile);

            /*if (projectile.ID == PeakCount - 1)
             * {
             *      PeakCount--;
             *      for (int i = projectile.ID - 1; i >= 0; i--)
             *      {
             *              if (ProjectileActive[i] == false)
             *              {
             *                      PeakCount--;
             *              }
             *              else {
             *                      break;
             *              }
             *      }
             * }*/
        }
        public static void EndProjectile(LSProjectile projectile)
        {
            int id = projectile.ID;

            if (ProjectileActive[id] == false)
            {
                return;
            }
            if (ProjectileBucket[id] != projectile)
            {
                return;
            }
            ProjectileActive[id] = false;
            ProjectileBucket[id] = null;
            OpenSlots.Add(id);

            CacheProjectile(projectile);
            projectile.Deactivate();
        }
Esempio n. 11
0
 public static void EndProjectile(LSProjectile projectile)
 {
     if (projectile.Deterministic)
     {
         int id = projectile.ID;
         if (!ProjectileBucket.SafeRemoveAt(id, projectile))
         {
             Debug.Log("BOO! This is a terrible bug.");
         }
     }
     else
     {
         if (!NDProjectileBucket.SafeRemoveAt(projectile.ID, projectile))
         {
             Debug.Log("BOO! This is a terrible bug.");
         }
     }
     CacheProjectile(projectile);
     projectile.Deactivate();
 }
        private static LSProjectile RawCreate(string projCode)
        {
            if (ProjectilePool.ContainsKey(projCode) == false)
            {
                Debug.Log(projCode + " fired by " + Scan.LastFire + " Caused boom");
                return(null);
            }
            FastStack <LSProjectile> pool    = ProjectilePool[projCode];
            LSProjectile             curProj = null;

            if (pool.Count > 0)
            {
                curProj = pool.Pop();
            }
            else
            {
                curProj = NewProjectile(projCode);
            }
            return(curProj);
        }
 public static LSProjectile Create(ProjectileCode projCode, LSAgent source, LSAgent target, long damage)
 {
     if (Enum.IsDefined(typeof (ProjectileCode), projCode) == false) {
         throw new System.MissingMemberException("The specified ProjectileCode does not exist");
     }
     FastStack<LSProjectile> pool = ProjectilePool[projCode];
     if (pool.Count > 0)
     {
         curProj = pool.Pop ();
     }
     else {
         curProj = NewProjectile (projCode);
     }
     int id = GenerateID ();
     ProjectileBucket[id] = curProj;
     ProjectileActive[id] = true;
     curProj.Initialize (id, source,target);
     curProj.Damage = damage;
     return curProj;
 }
Esempio n. 14
0
        public LSProjectile FireProjectile(Vector3d projOffset, LSAgent target)
        {
            LSProjectile currentProjectile = ProjectileManager.Create(
                ProjCode,
                this.Agent,
                projOffset,
                this.TargetAllegiance,
                (other) =>
            {
                Health healther = other.GetAbility <Health>();
                return(healther.IsNotNull() && healther.HealthAmount > 0);
            },
                CachedOnHit);

            switch (currentProjectile.TargetingBehavior)
            {
            case TargetingType.Homing:
                currentProjectile.InitializeHoming(target);
                break;

            case TargetingType.Timed:
                currentProjectile.InitializeTimed(Agent.Body.Forward);
                break;

            case TargetingType.Positional:
                currentProjectile.InitializePositional(target.Body.Position.ToVector3d(target.Body.HeightPos));
                break;

            case TargetingType.Free:
                //TODO
                throw new System.Exception("Not implemented yet.");
                //break;
            }
            if (onPrepareProjectile != null)
            {
                onPrepareProjectile(currentProjectile);
            }
            ProjectileManager.Fire(currentProjectile);
            return(currentProjectile);
        }
Esempio n. 15
0
        protected virtual void OnFire()
        {
            long appliedDamage = Damage;

            LSProjectile projectile = ProjectileManager.Create(
                ProjCode,
                this.Agent,
                this.ProjectileOffset,
                this.TargetAllegiance,
                (other) =>
            {
                Health healther = other.GetAbility <Health>();
                return(healther.IsNotNull() && healther.HealthAmount > 0);
            },
                CachedOnHit);

            switch (projectile.TargetingBehavior)
            {
            case TargetingType.Homing:
                projectile.InitializeHoming(this.Target);
                break;

            case TargetingType.Timed:
                projectile.InitializeTimed();
                break;

            case TargetingType.Positional:
                projectile.InitializePositional(Target.Body.Position.ToVector3d(Target.Body.HeightPos));
                break;

            case TargetingType.Free:
                //TODO
                throw new System.Exception("Not implemented yet.");
                break;
            }
            ProjectileManager.Fire(projectile);
        }
        private void Fire()
        {
            if (this.ShootType == ShootType.Single)
            {
                this.IsFiring = false;
            }
            this.FireCount = FirePeriod;

            FPSTurn      turn       = Agent.GetAbility <FPSTurn>();
            int          bodyID     = Agent.Body.ID;
            LSProjectile projectile = ProjectileManager.Create(this.ProjCode, Agent, ProjectileStartPosition, AllegianceType.All, (agent) => true, (agent) => agent.Body.TestFlash());

            projectile.InitializeFree(turn.Forward, (body) => body.ID != bodyID);
            ProjectileManager.Fire(projectile);

            if (this.PassedFrames > 0)
            {
                Vector3d delta = projectile.Velocity;
                delta.Mul((int)PassedFrames);
                projectile.RaycastMove(delta);

                PassedFrames = 0;
            }
        }
Esempio n. 17
0
 public void FireProjectile(LSProjectile projectile)
 {
     ProjectileManager.Fire(projectile);
 }
 private static void CacheProjectile(LSProjectile projectile)
 {
     ProjectilePool[projectile.MyProjCode].Add (projectile);
     /*if (projectile.ID == PeakCount - 1)
     {
         PeakCount--;
         for (int i = projectile.ID - 1; i >= 0; i--)
         {
             if (ProjectileActive[i] == false)
             {
                 PeakCount--;
             }
             else {
                 break;
             }
         }
     }*/
 }
Esempio n. 19
0
 protected virtual void OnPrepareProjectile(LSProjectile projectile)
 {
 }
Esempio n. 20
0
 void OnTakeDamage(LSProjectile projectile)
 {
     if (IsShielding) {
         TakeRawDamage ( projectile.CheckExclusiveDamage (Agent.Tag));
         projectile.Damage = 0;
     }
     timeUntilRegeneration = RegenerationDelay;
 }
 private static LSProjectile NewProjectile(string projCode)
 {
     ProjectileDataItem projData = CodeDataMap[projCode];
     curProj = ((GameObject)GameObject.Instantiate<GameObject> (projData.Prefab)).GetComponent<LSProjectile> ();
     curProj.Setup (projData);
     return curProj;
 }
 public static void Fire(LSProjectile projectile)
 {
     projectile.LateInit ();
 }
 public static void Fire(LSProjectile projectile)
 {
     projectile.LateInit();
 }