예제 #1
0
 public void Execute(Entity entity, int index, [ReadOnly] ref Player player, [ReadOnly] ref AABBCollider collider)
 {
     for (int i = index + 1; i < Colliders.Length; i++)
     {
         var otherCollider = Colliders[i];
         if (ECSPhysics.Intersect(collider.MinMaxBox, otherCollider.MinMaxBox))
         {
             collider.CollideCount += 1;
             EntityCommandBuffer.DestroyEntity(Entities[i]);
             break;
         }
     }
 }
예제 #2
0
 public void Execute(Entity entity, int index, ref Enemy enemy, ref Airplane airplane, [ReadOnly] ref AABBCollider collider)
 {
     for (int i = index + 1; i < Colliders.Length; i++)
     {
         //击中
         if (ECSPhysics.Intersect(collider.MinMaxBox, Colliders[i].MinMaxBox) && Colliders[i].Box.Center.z < collider.Box.Center.z)
         {
             collider.CollideCount += 1;
             airplane.Hp            = math.max(0f, airplane.Hp - Bullets[i].Damage);
             if (enemy.SpeedScale >= 1.0f)
             {
                 enemy.SpeedScale *= 0.85f; //受到攻击后减速
             }
             EntityCommandBuffer.DestroyEntity(Entities[i]);
             Entity e = EntityCommandBuffer.CreateEntity(ECSWorld.BlastEntityArchetype);
             EntityCommandBuffer.SetComponent(e, new Blast
             {
                 Pos      = Colliders[i].Box.Center,
                 Duration = Bullets[i].BlastDuration
             });
             break;
         }
     }
 }