예제 #1
0
 /// <summary>
 /// 部件逻辑
 /// </summary>
 public void RunPartsAI()
 {
     for (int i = 0; i < Ship.PartsList.Count; ++i)
     {
         var part      = Ship.PartsList[i];
         var enemyList = TargetSelector.FindTarget(part, CampType);
         if (enemyList.Count == 0)
         {
             part.PartState = PartState.Idle;
             continue;
         }
         part.PartState = PartState.Guard;
         proto.PartFireEvent partFireEvent = new proto.PartFireEvent();
         partFireEvent.partid = part.Id;
         for (int enemyIndex = 0; enemyIndex < enemyList.Count; ++enemyIndex)
         {
             EnemyInfo enemyInfo = enemyList[enemyIndex];
             if (enemyInfo.InAttackRange)
             {
                 part.PartState = PartState.Attack;
             }
             if (!part.IsCoolDownFinished())
             {
                 continue;
             }
             part.StartCoolDown();
             partFireEvent.add_fireinfo(PartFire(part, enemyInfo.EnemyShip));
         }
         if (partFireEvent.fireinfo_size() != 0)
         {
             BehaviorMsg_.add_partfireevent(partFireEvent);
         }
     }
 }