예제 #1
0
        private void UpdateBullets(AoeObj aoeObj)
        {
            //离开的演员
            List <BulletObj> leaveBullets = new List <BulletObj>();

            for (int i = 0; i < aoeObj.bulletInRange.Count; i++)
            {
                BulletObj bullet = aoeObj.bulletInRange[i];
                if (!Sensor.CheckBulletInRange(aoeObj, bullet))
                {
                    leaveBullets.Add(bullet);
                }
            }
            for (int a = 0; a < leaveBullets.Count; a++)
            {
                aoeObj.bulletInRange.Remove(leaveBullets[a]);
            }
            ExecuteBulletLeaveFunc(aoeObj, leaveBullets);

            //新进入的演员
            List <BulletObj> enterBullets = new List <BulletObj>();

            foreach (var item in Sensor.GetBulletsInRange(aoeObj))
            {
                if (aoeObj.bulletInRange.IndexOf(item) < 0)
                {
                    enterBullets.Add(item);
                }
            }
            ExecuteBulletEnterFunc(aoeObj, enterBullets);
            for (int a = 0; a < enterBullets.Count; a++)
            {
                aoeObj.bulletInRange.Add(enterBullets[a]);
            }
        }
예제 #2
0
 private void UpdateHitRecords(BulletObj bulletObj, float timePassed)
 {
     for (int i = 0; i < bulletObj.hitRecords.Count; i++)
     {
         BulletHitRecord record = bulletObj.hitRecords[i];
         record.timeToCanHit -= timePassed;
         if (record.timeToCanHit <= 0 || record.target == null)
         {
             bulletObj.hitRecords.RemoveAt(i);
         }
     }
 }
예제 #3
0
 private void ExecuteHitActorFunc(BulletObj bulletObj, ActorObj actor)
 {
     if (bulletObj.model.onHitFunc == null || bulletObj.model.onHitFunc.Count <= 0)
     {
         return;
     }
     for (int i = 0; i < bulletObj.model.onHitFunc.Count; i++)
     {
         BulletHitFunc func = bulletObj.model.onHitFunc[i];
         func.Execute(bulletObj, actor);
     }
 }
예제 #4
0
 private void ExecuteRemoveFunc(BulletObj bulletObj)
 {
     if (bulletObj.model.onRemovedFunc == null || bulletObj.model.onRemovedFunc.Count <= 0)
     {
         return;
     }
     for (int i = 0; i < bulletObj.model.onRemovedFunc.Count; i++)
     {
         BulletLifeCycleFunc func = bulletObj.model.onRemovedFunc[i];
         func.Execute(bulletObj);
     }
 }
예제 #5
0
 private bool CheckInHitRecord(BulletObj bulletObj, ActorObj actor)
 {
     for (int i = 0; i < bulletObj.hitRecords.Count; i++)
     {
         BulletHitRecord record = bulletObj.hitRecords[i];
         if (record.target != null && record.target.Equals(actor))
         {
             return(true);
         }
     }
     return(false);
 }
예제 #6
0
 /// <summary>
 /// 检测子弹是否在范围内
 /// </summary>
 /// <param name="bulletObj"></param>
 /// <param name="actor"></param>
 /// <returns></returns>
 public abstract bool CheckBulletInRange(AoeObj aoeObj, BulletObj bullet);
예제 #7
0
        private void DealBullet(BulletCom bulletCom)
        {
            float timePassed = SkillLocate.DeltaTime;

            if (bulletCom.Bullets == null || bulletCom.Bullets.Count <= 0)
            {
                return;
            }
            for (int i = 0; i < bulletCom.Bullets.Count; i++)
            {
                BulletObj bulletObj = bulletCom.Bullets[i];

                //创建函数
                if (bulletObj.timeElapsed <= 0)
                {
                    ExecuteCreateFunc(bulletObj);
                }

                //处理命中纪录
                UpdateHitRecords(bulletObj, timePassed);

                //移动
                if (bulletObj.duration > 0 && bulletObj.model.moveFunc != null)
                {
                    BulletMoveInfo bulletMoveInfo = bulletObj.model.moveFunc.Execute(bulletObj, bulletObj.timeElapsed, bulletObj.followActor);
                    bulletObj.SetMoveInfo(bulletMoveInfo);
                }

                //碰撞
                if (bulletObj.canHitAfterCreated > 0)
                {
                    bulletObj.canHitAfterCreated -= timePassed;
                }
                else
                {
                    List <ActorObj> hitActors = Sensor.GetHitActors(bulletObj);
                    for (int a = 0; a < hitActors.Count; a++)
                    {
                        if (CheckInHitRecord(bulletObj, hitActors[a]))
                        {
                            continue;
                        }
                        //次数减一
                        bulletObj.model.hitTimes -= 1;

                        //执行击中函数
                        ActorObj hitActor = hitActors[a];
                        ExecuteHitActorFunc(bulletObj, hitActor);

                        //记录击中记录
                        bulletObj.hitRecords.Add(new BulletHitRecord(hitActor, bulletObj.model.sameTargetDelay));
                    }
                }

                //生命周期计算
                bulletObj.duration    -= timePassed;
                bulletObj.timeElapsed += timePassed;
                if (bulletObj.duration <= 0 || bulletObj.model.hitTimes <= 0)
                {
                    ExecuteRemoveFunc(bulletObj);
                    bulletCom.RemoveBullet(bulletObj);
                    DestroyBullet(bulletObj);
                }
            }
        }
예제 #8
0
 private void DestroyBullet(BulletObj bulletObj)
 {
     Debug.LogWarning("目前bulletObj直接销毁》》》》!!!!");
 }
예제 #9
0
 public override void Execute(BulletObj bullet, ActorObj actor)
 {
     SkillLocate.Skill.CreateAoe(bullet.ower, addAoe);
 }
예제 #10
0
        public override void Execute(BulletObj bullet, ActorObj actor)
        {
            SkillCom targetCom = LCECS.ECSLocate.ECS.GetEntity(actor.Uid).GetCom <SkillCom>();

            SkillLocate.Damage.AddDamage(bullet.ower, targetCom, damage);
        }
예제 #11
0
 /// <summary>
 /// 执行函数
 /// </summary>
 /// <param name="bullet">bullet对象</param>
 /// <param name="actor">击中的对象</param>
 public abstract void Execute(BulletObj bullet, ActorObj actor);
예제 #12
0
 /// <summary>
 /// 执行函数
 /// </summary>
 /// <param name="bullet">bullet对象</param>
 public abstract ActorObj Execute(BulletObj bullet);
예제 #13
0
 /// <summary>
 /// 执行函数
 /// </summary>
 /// <param name="bullet">bullet对象</param>
 /// <param name="moveTime">bullet移动时间</param>
 /// <param name="target">bullet跟踪对象,如果不是跟踪不使用</param>
 public abstract BulletMoveInfo Execute(BulletObj bullet, float moveTime, ActorObj target = null);
예제 #14
0
 /// <summary>
 /// 执行函数
 /// </summary>
 /// <param name="bullet">aoe对象</param>
 public abstract void Execute(BulletObj bullet);
예제 #15
0
        public override void Execute(BulletObj bullet, ActorObj actor)
        {
            SkillCom targetCom = LCECS.ECSLocate.ECS.GetEntity(actor.Uid).GetCom <SkillCom>();

            SkillLocate.Skill.CreateBuff(bullet.ower, targetCom, addBuff);
        }
예제 #16
0
 /// <summary>
 /// 获得Bullet击中的演员
 /// </summary>
 /// <param name="bulletObj"></param>
 /// <returns></returns>
 public abstract List <ActorObj> GetHitActors(BulletObj bulletObj);