public override UnitPosition Select(IEventArgs args)
        {
            if (tempPosition == null)
            {
                tempPosition = new UnitPosition();
            }

            if (MapConfigPoints.current != null)
            {
                int realType = FreeUtil.ReplaceInt(type, args);
                int mapId    = args.GameContext.session.commonSession.RoomInfo.MapId;
                var poss     = args.FreeContext.Poss;
                foreach (MapConfigPoints.ID_Point p in FreeMapPosition.GetPositions(mapId).IDPints)
                {
                    if (p.ID == realType)
                    {
                        RandomBit randomBit = poss.AddRandomBit(p.ID, p.points.Count);
                        Vector3   v         = Vector3.zero;
                        int       index     = -1;
                        bool      invalid   = false;
                        if (randomBit.index >= 0)
                        {
                            index = poss.GetRandomBit(p.ID, p.points.Count);
                            v     = p.points[index].pos;
                        }
                        else
                        {
                            invalid = true;
                        }
                        tempPosition.SetInvalid(invalid);
                        tempPosition.SetX(v.x);
                        tempPosition.SetY(v.y);
                        tempPosition.SetZ(v.z);
                        tempPosition.SetRandomindex(index);
                        return(tempPosition);
                    }
                }
            }
            return(tempPosition);
        }
示例#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);
        }