Ejemplo n.º 1
0
 /// <summary>
 /// 获取与碰撞器的关系:-1无关 0相交或包括碰撞器 1在碰撞器内部
 /// </summary>
 /// <param name="self"></param>
 /// <param name="trigger"></param>
 /// <param name="position"></param>
 /// <param name="rotation"></param>
 /// <returns></returns>
 public static int GetRelationshipWithTrigger(this AOICell self, AOITriggerComponent trigger, Vector3 position, Quaternion rotation)
 {
     if (trigger.TriggerType == TriggerShapeType.Cube)
     {
         var obb = trigger.GetComponent <OBBComponent>();
         return(AOIHelper.GetGridRelationshipWithOBB(position, rotation, obb.Scale, self.xMax - self.xMin, self.posx, self.posy));
     }
     else
     {
         return(AOIHelper.GetGridRelationshipWithSphere(position, trigger.Radius, self.xMax - self.xMin, self.posx, self.posy));
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 添加触发器监视
 /// </summary>
 /// <param name="self"></param>
 /// <param name="trigger"></param>
 /// <returns></returns>
 public static void AddTriggerListener(this AOICell self, AOITriggerComponent trigger)
 {
     if (Define.Debug)
     {
         if (!trigger.DebugMap.ContainsKey(self))
         {
             trigger.DebugMap[self] = 0;
         }
         trigger.DebugMap[self]++;
         trigger.LogInfo.Add("AddTriggerListener " + self.posx + "," + self.posy + "  " + trigger.GetRealPos() + "  " +
                             DateTime.Now.ToString("HH:mm:ss fff:ffffff") + "\r\n" + new StackTrace());
     }
     trigger.FollowCell.Add(self);
     self.Triggers.Add(trigger);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 获取所有指定类型单位的碰撞器
        /// </summary>
        /// <param name="self"></param>
        /// <param name="types"></param>
        /// <param name="except"></param>
        /// <returns></returns>
        public static ListComponent <AOITriggerComponent> GetAllCollider(this AOICell self, List <UnitType> types, AOITriggerComponent except)
        {
            var res = ListComponent <AOITriggerComponent> .Create();

            if (self.IsDisposed)
            {
                return(res);
            }
            var isAll = types.Contains(UnitType.ALL);

            for (int i = self.Triggers.Count - 1; i >= 0; i--)
            {
                var item = self.Triggers[i];
                if (item.IsDisposed)
                {
                    self.Triggers.RemoveAt(i);
                    Log.Warning("自动移除不成功");
                    continue;
                }
                if (!item.IsCollider || item == except)
                {
                    continue;
                }

                if (isAll || types.Contains(item.GetParent <AOIUnitComponent>().Type))
                {
                    // Log.Info("GetAllUnit key:"+item.Key);
                    res.Add(item);
                }
            }
            return(res);
        }