Esempio n. 1
0
        public MapInstance GetDefaultMapInstance(PlanesInstance planes)
        {
            MapInstance map;
            ulong       mapId = 0;

            if (mInstanceMaps.TryGetValue(mapId, out map))
            {
                return(map);
            }
            for (UInt16 i = 0; i < UInt16.MaxValue; i++)
            {
                if (mAllMaps[i] == null)
                {
                    var info = MapInstanceManager.GetMapInitBySourceId(GameSet.Instance.DefaultMapId);
                    if (info == null)
                    {
                        continue;
                    }
                    ;

                    map = new WolrdMap();
                    if (map.InitMap(planes, i, 0, info, null))
                    {
                        mAllMaps[i] = map;
                        LogicProcessorManager.Instance.PushMap(map);
                        return(map);
                    }
                }
            }

            return(null);
        }
Esempio n. 2
0
        public MapInstance CreateMapInstance(PlanesInstance planes, ulong mapInstanceId, ushort mapSourceId, PlayerInstance creater)
        {
            for (UInt16 i = 0; i < UInt16.MaxValue; i++)
            {
                if (mAllMaps[i] == null)
                {
                    var info = MapInstanceManager.GetMapInitBySourceId(mapSourceId);
                    if (info == null)
                    {
                        return(new NullMapInstance());
                    }
                    var         mapType = (CSCommon.eMapType)info.MapData.mapType;
                    MapInstance map     = null;
                    switch (mapType)
                    {
                    case CSCommon.eMapType.World:
                        map = new WolrdMap();
                        break;

                    case CSCommon.eMapType.NULL:
                        map = new NullMapInstance();
                        break;

                    case CSCommon.eMapType.InstanceStart:
                        map = new NullMapInstance();
                        break;

                    case CSCommon.eMapType.Master:
                        map = new MasterInstance();
                        break;

                    case CSCommon.eMapType.Arena:
                        map = new ArenaInstance();
                        break;

                    case CSCommon.eMapType.Challenge:
                        map = new ChallengeInstance();
                        break;

                    case CSCommon.eMapType.BattelStart:
                        break;

                    default:
                        map = new NullMapInstance();
                        break;
                    }
                    if (map == null)
                    {
                        return(new NullMapInstance());
                    }

                    if (map.InitMap(planes, i, mapInstanceId, info, creater))
                    {
                        mAllMaps[i] = map;
                        LogicProcessorManager.Instance.PushMap(map);
                        return(map);
                    }
                    else
                    {
                        Log.FileLog.WriteLine("CreateMapInstance {0} Failed", mapSourceId);
                        return(null);
                    }
                }
            }
            return(null);
        }