Exemple #1
0
 public override UnitPosition GetCenter(IEventArgs arg1)
 {
     foreach (MapConfigPoints.ID_Point p in MapConfigPoints.current.IDPints)
     {
         if (p.ID == FreeUtil.ReplaceInt(type, arg1))
         {
             UnitPosition unitPosition = new UnitPosition();
             if (p.points.Count > 0)
             {
                 unitPosition.SetX(p.points[0].pos.x);
                 unitPosition.SetY(p.points[0].pos.y);
                 unitPosition.SetZ(p.points[0].pos.z);
                 unitPosition.SetYaw(p.points[0].dir);
                 unitPosition.SetCylinderVolR(p.points[0].cylinderVolR);
                 unitPosition.SetCylinderVolH(p.points[0].cylinderVolH);
                 return(unitPosition);
             }
         }
     }
     return(null);
 }
Exemple #2
0
        public override UnitPosition Select(IEventArgs args)
        {
            if (tempPosition == null)
            {
                tempPosition = new UnitPosition();
                bitDic       = new Dictionary <int, RandomBit>();
            }

            if (MapConfigPoints.current != null)
            {
                int realType  = FreeUtil.ReplaceInt(type, args);
                int realIndex = FreeUtil.ReplaceInt(index, args);

                int mapId = args.GameContext.session.commonSession.RoomInfo.MapId;

                foreach (MapConfigPoints.ID_Point p in FreeMapPosition.GetPositions(mapId).IDPints)
                {
                    if (p.ID == realType)
                    {
                        if (!bitDic.ContainsKey(p.ID))
                        {
                            bitDic.Add(p.ID, new RandomBit(p.points.Count));
                        }

                        Vector3 v = Vector3.zero;
                        if (realIndex == 0)
                        {
                            v = p.points[Random(p.ID, p.points.Count)].pos;
                            if (birth)
                            {
                                if (HasPlayerNearBy(v, args))
                                {
                                    for (int i = 0; i < p.points.Count; i++)
                                    {
                                        realIndex = Random(p.ID, p.points.Count);
                                        v         = p.points[realIndex].pos;
                                        if (!HasPlayerNearBy(v, args))
                                        {
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (realIndex < 0 || realIndex >= p.points.Count)
                            {
                                realIndex = Math.Min(0, p.points.Count - 1);
                            }
                            v = p.points[realIndex].pos;
                        }
                        tempPosition.SetX(v.x);
                        tempPosition.SetY(v.y);
                        tempPosition.SetZ(v.z);
                        tempPosition.SetYaw(p.points[realIndex].dir);
                        tempPosition.SetCylinderVolR(p.points[realIndex].cylinderVolR);
                        tempPosition.SetCylinderVolH(p.points[realIndex].cylinderVolH);
                        break;
                    }
                }
            }

            return(tempPosition);
        }