public void Init(int mapId) { mResSvc = ResSvc.Instance; mAudioSvc = AudioSvc.Instance; mCfgSvc = CfgSvc.Instance; mSkillMgr = gameObject.AddComponent <SkillMgr>(); mSkillMgr.Init(); mStateMgr = gameObject.AddComponent <StateMgr>(); mStateMgr.Init(); mAudioSvc.PlayBgAudio(Constant.Audio_BgHuangYe); CfgMap cfg = mCfgSvc.GetCfgMap(mapId); if (cfg == null) { Debug.LogError("╪сть╣ьм╪й╖╟э: " + mapId); return; } mResSvc.AsyncLoadScene(cfg.sceneName, () => { GameObject mapGo = GameObject.FindGameObjectWithTag("MapRoot"); mMapMgr = mapGo.AddComponent <MapMgr>(); mMapMgr.Init(); InitScene(cfg); }); }
private void Awake() { Instance = this; _mapCells = GetComponentsInChildren <MapCell> (); MapCellCount = _mapCells.Length; }
private static void StartMatchGame(ProxyRoom red, ProxyRoom blue) { try { int mapId = MapMgr.GetMapIndex((red.AvgLevel + blue.AvgLevel) / 2, ProxyRoomMgr.m_serverId); eGameType gameType = eGameType.Free; if (red.GameType == blue.GameType) { gameType = red.GameType; } else { if ((red.GameType == eGameType.ALL && blue.GameType == eGameType.Guild) || (blue.GameType == eGameType.ALL && red.GameType == eGameType.Guild)) { gameType = eGameType.Guild; } } BaseGame game = GameMgr.StartBattleGame(red.GetPlayers(), red, blue.GetPlayers(), blue, mapId, eRoomType.Match, gameType, 3); if (game != null) { blue.StartGame(game); red.StartGame(game); } } catch (Exception e) { ProxyRoomMgr.log.Error("Start Match Game Error:", e); } }
public static void InitInst() { if (m_Inst == null) { m_Inst = new MapMgr(); } }
public void Init(int mapId) { resSvc = ResSvc.instance; audioSvc = AudioSvc.instance; timerSvc = TimerSvc.instance; stateMgr = this.gameObject.AddComponent <StateMgr>(); stateMgr.Init(); skillMgr = this.gameObject.AddComponent <SkillMgr>(); skillMgr.Init(); mapCfg = resSvc.GetMapCfgData(mapId); resSvc.AsyncLoadScene(mapCfg.sceneName, () => { GameObject mapObj = GameObject.FindWithTag("MapRoot"); mapMgr = mapObj.GetComponent <MapMgr>(); mapMgr.Init(); audioSvc.PlayBgMusic(Constants.BGHuangye); mapObj.transform.position = Vector3.zero; mapObj.transform.localScale = Vector3.one; Camera.main.transform.position = mapCfg.mainCamPos; Camera.main.transform.localEulerAngles = mapCfg.mainCamRote; LoadPlayer(mapCfg); SetActiveCurrentBatchMonsters(); }); }
public static BattleGame StartBattleGame(List <IGamePlayer> red, ProxyRoom roomRed, List <IGamePlayer> blue, ProxyRoom roomBlue, int mapIndex, eRoomType roomType, eGameType gameType, int timeType) { try { int index = MapMgr.GetMapIndex(mapIndex, (byte)roomType, m_serverId); Map map = MapMgr.CloneMap(index); if (map != null) { BattleGame game = new BattleGame(m_gameId++, red, roomRed, blue, roomBlue, map, roomType, gameType, timeType); lock (m_games) { m_games.Add(game.Id, game); } game.Prepare(); SendStartMessage(game); return(game); } else { return(null); } } catch (Exception e) { log.Error("Create battle game error:", e); return(null); } }
public void initModel(HeroMgr hMgr, MapMgr mMgr) { MapConfig cfg = _cfg; _randomMonsterModels = new List <HeroModel> (); int monsterSize = cfg.monsterData.Length; for (int i = 0; i < monsterSize; i += 2) { int id = Convert.ToInt32(cfg.monsterData[i]); int level = Convert.ToInt32(cfg.monsterData[i + 1]); HeroModel model = hMgr.createHero(id, level, 1); _randomMonsterModels.Add(model); } _canAtkModels = new List <MapModel> (); int canAtkSize = cfg.canAtkIds.Length; for (int i = 0; i < canAtkSize; i++) { int canAtkId = Convert.ToInt32(cfg.canAtkIds[i]); MapModel mapModel = mMgr.getMapModel(canAtkId); _canAtkModels.Add(mapModel); } }
public void Clear() { m_Inited = false; RemoveMessage(); m_Instance = null; }
public void Init(int mapId) { resSev = ResSev.Instance; audioSev = AudioSev.Instance; stateMgr = gameObject.AddComponent <StateMgr>(); skillMgr = gameObject.AddComponent <SkillMgr>(); stateMgr.Init(); skillMgr.Init(); mapCfg = resSev.GetMapCfgData(mapId); resSev.AsyncLoadScene(mapCfg.sceneName, () => { GameObject map = GameObject.FindGameObjectWithTag("MapRoot"); mapMgr = map.GetComponent <MapMgr>(); mapMgr.Init(this); map.transform.localPosition = Vector3.zero; map.transform.localScale = Vector3.one; Camera.main.transform.position = mapCfg.mainCamPos; Camera.main.transform.localEulerAngles = mapCfg.mainCamRote; LoadPlayer(mapCfg); audioSev.PlayBGM(Constans.HuangYeBGM); ActiveCurrentBatchMonsters(); }); }
public static List <Vector2> GetPoints(Vector2 start, Vector2 end) { for (int i = 0; i < width; ++i) { for (int j = 0; j < height; ++j) { int id = JsonTest.getMe().GetStopPoint(i, j); // [i, j]; MapMgr.getMe().mRoadPointArr[i][j] = MapMgr.canThroughByID(id); } } List <APoint> _ret = Astar.SearchRoad(GetAPointByPosition(start, TILEDMAP_TYPE.START), GetAPointByPosition(end, TILEDMAP_TYPE.END), MapMgr.getMe().mRoadPointArr); List <Vector2> retex = new List <Vector2>(); foreach (var data in _ret) { Vector2 pos = GetVec2ByApoint(data); retex.Add(pos); } return(retex); }
public static BaseGame StartPVPGame(int roomId, List <IGamePlayer> red, List <IGamePlayer> blue, int mapIndex, eRoomType roomType, eGameType gameType, int timeType) { try { int index = MapMgr.GetMapIndex(mapIndex, (byte)roomType, m_serverId); Map map = MapMgr.CloneMap(index); if (map != null) { PVPGame game = new PVPGame(m_gameId++, roomId, red, blue, map, roomType, gameType, timeType); game.GameOverLog += new BaseGame.GameOverLogEventHandle(LogMgr.LogFightAdd); lock (m_games) { m_games.Add(game); } game.Prepare(); return(game); } else { return(null); } } catch (Exception e) { log.Error("Create game error:", e); return(null); } }
public void Init(int mapID) { resSvc = ResSvc.Instance; audioSvc = AudioSvc.Instance; //初始化各个管理器 stateMgr = gameObject.AddComponent <StateMgr>(); stateMgr.Init(); skillMgr = gameObject.AddComponent <SkillMgr>(); skillMgr.Init(); MapCfg mapData = resSvc.GetMapCfgData(mapID); resSvc.AsyncLoadScene(mapData.sceneName, () => { audioSvc.PlayBGMusic(Constants.BGHuangYe); GameObject map = GameObject.FindGameObjectWithTag("MapRoot"); mapMgr = map.GetComponent <MapMgr>(); mapMgr.Init(); Camera.main.transform.position = mapData.mainCamPos; Camera.main.transform.eulerAngles = mapData.mainCamRote; LoadPlayer(mapData); }); }
public static BaseGame StartGame(List <GamePlayer> red, List <GamePlayer> blue, int mapIndex, eRoomType roomType, eTeamType teamType, eGameType gameType, int timeType) { try { int index = MapMgr.GetMapIndex(mapIndex, (byte)roomType); Map map = MapMgr.CloneMap(index); if (map != null) { BaseGame game = new BaseGame(red, blue, map, roomType, teamType, gameType, timeType); lock (m_games) { m_games.Add(game); } game.Prepare(); return(game); } else { return(null); } } catch (Exception e) { log.Error("Create game error:", e); return(null); } }
public void Init(int mapID) { resSvc = ResSvc.Instance; audioSvc = AudioSvc.Instance; //初始化各个管理器 stateMgr = gameObject.AddComponent <StateMgr>(); stateMgr.Init(); skillMgr = gameObject.AddComponent <SkillMgr>(); skillMgr.Init(); //加载战场地图 MapCfgs mapData = resSvc.GetMapCfgData(mapID); resSvc.AsyncLoadScene(mapData.sceneName, () => { //初始化地图数据 GameObject map = GameObject.FindGameObjectWithTag("MapRoot"); mapMgr = map.GetComponent <MapMgr>(); mapMgr.Init(); //初始化地图位置和摄像机位置 map.transform.localPosition = Vector3.zero; map.transform.localScale = Vector3.zero; Camera.main.transform.position = mapData.mainCamPos; Camera.main.transform.localEulerAngles = mapData.mainCamRote; LoadPlayer(mapData); audioSvc.PlayBGMusic(Constants.BGHuangYe); entityPlayer.Idle(); }); }
public void Init(int mapid, Action cb = null) { TriggerCheck = true; IsPauseGame = false; //初始化各管理器 m_StateMgr.Init(); m_SkillMgr.Init(); //加载战场地图 m_MapCfg = GameEntry.Res.GetMapCfg(mapid); //初始化地图数据 //GameObject map = GameObject.FindGameObjectWithTag("MapRoot"); m_MapMgr = GameObject.FindObjectOfType <MapMgr>(); m_MapMgr.Init(this); monsterDic.Clear(); Camera.main.transform.position = m_MapCfg.mainCamPos; Camera.main.transform.localEulerAngles = m_MapCfg.mainCamRote; LoadPlayer(); //GameEntry.Sound.PlayUISound(Constants.BGHuangYe); if (cb != null) { cb(); } }
public void ExitMap() { Game.DataManager.MyPlayer.Data.Gold = m_MyMapPlayer.Data.Gold; Game.DataManager.MyPlayer.Data.Food = m_MyMapPlayer.Data.Food; SceneMgr.ChangeScene(3); Clear(); m_Instance = null; }
public static MapMgr getMe() { if (_instance == null) { _instance = new MapMgr(); } return(_instance); }
public World(WorldSession _s) { _session = _s; _mapId = 0; _mapmgr = null; _movemgr = null; _mapmgr = new MapMgr(); }
public List <Box> CreateBox() { int total = m_players.Count + 2; int itemCount = 0; List <MapGoodsInfo> list = new List <MapGoodsInfo>(); if (CurrentTurnTotalDamage > 0) { itemCount = m_random.Next(1, 3); if (m_tempBox.Count + itemCount > total) { itemCount = total - m_tempBox.Count; } if (itemCount > 0) { list.AddRange(MapMgr.GetRandomGoodsByNumber(m_map.Info.ID, itemCount, (int)m_mapType)); } } int ghostCount = GetGhostCount(); int propCount = 0; if (ghostCount > 0) { propCount = m_random.Next(ghostCount); } if (m_tempBox.Count + itemCount + propCount > total) { propCount = total - m_tempBox.Count - itemCount; } if (propCount > 0) { MapMgr.GetRandomFightPropByCount(m_map.Info.ID, propCount, list); } List <Box> box = new List <Box>(); if (list.Count > 0) { for (int i = 0; i < m_tempPoints.Count; i++) { int index = m_random.Next(m_tempPoints.Count); Point p = m_tempPoints[index]; m_tempPoints[index] = m_tempPoints[i]; m_tempPoints[i] = p; } int count = Math.Max(list.Count, m_tempPoints.Count); for (int i = 0; i < count; i++) { box.Add(AddBox(list[i], m_tempPoints[i])); } } m_tempPoints.Clear(); return(box); }
public void Awake() { if (_instance == null) { _instance = this; } Init(); }
private void Start() { if (mapMgr == null) { mapMgr = FindObjectOfType <MapMgr>(); } if (EventMgr.Instance.onPathfindRequesterCountZero == null) { Debug.LogError("[Pathfinder] e_pathfindRequesterCountZero == null"); } }
void Awake() { CardConfigData.Instance.Init(); SkillConfigData.Instance.Init(); ZombieCardResource.Instance.Init(); ZombieResource.Instance.Init(); BulletResource.Instance.Init(); TipsManager.Instance.Init(GameObject.Find("Canvas").transform); MapMgr.getMe().init();// }
public static BaseGame StartPVPGame(int roomId, List <IGamePlayer> red, List <IGamePlayer> blue, int mapIndex, eRoomType roomType, eGameType gameType, int timeType) { BaseGame result; try { int totalLevel = 0; foreach (IGamePlayer player in red) { totalLevel += player.PlayerCharacter.Grade; } foreach (IGamePlayer player in blue) { totalLevel += player.PlayerCharacter.Grade; } int averageLevel = totalLevel / (red.Count + blue.Count); int mapId = MapMgr.GetMapIndex(averageLevel, GameMgr.m_serverId); if (mapIndex == 0) { mapIndex = mapId; } Map map = MapMgr.AllocateMapInstance(mapIndex); if (map != null) { PVPGame game = new PVPGame(GameMgr.m_gameId++, roomId, red, blue, map, roomType, gameType, timeType, 0); //game.GameOverLog += new BaseGame.GameOverLogEventHandle(LogMgr.LogFightAdd); List <BaseGame> games; Monitor.Enter(games = GameMgr.m_games); try { GameMgr.m_games.Add(game); } finally { Monitor.Exit(games); } game.Prepare(); result = game; } else { result = null; } } catch (Exception e) { GameMgr.log.Error("Create game error:", e); result = null; } return(result); }
void Awake() { Instance = this; mapData = new MapData(); mapItemPrefab = new Dictionary <MapItemType, GameObject>(); mapItemPrefab.Add(MapItemType.InnerWall, Resources.Load("Prefabs/InnerWall") as GameObject); mapItemPrefab.Add(MapItemType.OutWall, Resources.Load("Prefabs/OutWall") as GameObject); emptyItemList = new List <Vector3>(); CreateMap(); }
private void Awake() { Instance = this; rows = radius * 2 + 1; cols = radius * 2 + 1; blockArray = new BlockCtrl[rows, cols]; //blockDict.Add("Floor1", new Floor1Ctrl()); //blockDict.Add("Floor2", new Floor2Ctrl()); //blockDict.Add("Floor3", new Floor3Ctrl()); //blockDict.Add("Floor4", new Floor4Ctrl()); //blockDict.Add("Floor5", new Floor5Ctrl()); //blockDict.Add("Start", new StartBlockCtrl()); //blockDict.Add("End", new EndBlockCtrl()); }
public bool TakeCard(Player player, int index) { if (player.CanTakeOut == false) { return(false); } if (player.IsActive == false || index < 0 || index > 7 || player.HasTakeCard || Cards[index] > 0) { return(false); } MapGoodsInfo info = MapMgr.GetRandomAward(m_map.Info.ID, m_map.Info.Type); bool isItem = false; int value = 100; if (info != null) { if (info.GoodsID > 0) { ItemTemplateInfo temp = ItemMgr.GetSingleGoods(info.GoodsID); if (temp != null) { isItem = true; value = info.GoodsID; player.PlayerDetail.TempInventory.AddItemTemplate(temp, info); } } else if (info.GoodsID == -1) { value = info.Value; } } if (isItem == false) { value = player.PlayerDetail.AddGold(value); } player.HasTakeCard = true; Cards[index] = 1; GSPacketIn pkg = player.PlayerDetail.Out.SendGamePlayerTakeCard(player, index, isItem, value); SendToAll(pkg, player.PlayerDetail); return(true); }
void Start() { backBtn.onClicked += _onBackClicked; SolaEngine engine = SolaEngine.getInstance(); MapMgr mMgr = (MapMgr)engine.getMgr(typeof(MapMgr)); for (int i = 0; i < mapItems.Length; i++) { MapItem mapItem = mapItems[i]; MapModel mapModel = mMgr.getMapModel(i + 1); mapItem.setMapModel(mapModel, toBattleDialog, this); } }
public static void Start() { lock (thisLock) { m_IsRunning = false; } Stopwatch allWatch = new Stopwatch(); allWatch.Start(); { Stopwatch stopwatch = new Stopwatch(); //加载配置 stopwatch.Start(); AttrMgr.Init(); ConfigMgr.Inst().InitConfigMgr(); stopwatch.Stop(); TraceLog.ReleaseWrite("加载游戏execl配置文件完成,共花费时间 {0} ms", stopwatch.Elapsed.TotalMilliseconds); } { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); MapMgr.Inst().Init(); stopwatch.Stop(); TraceLog.ReleaseWrite("加载游戏地图数据完成,共花费时间 {0} ms", stopwatch.Elapsed.TotalMilliseconds); } { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); SceneMgr.Inst().Init(); stopwatch.Stop(); TraceLog.ReleaseWrite("创建场景完成,共花费时间 {0} ms", stopwatch.Elapsed.TotalMilliseconds); } allWatch.Stop(); TraceLog.ReleaseWrite("加载全部配置,共花费时间 {0} ms", allWatch.Elapsed.TotalMilliseconds); lock (thisLock) { m_IsRunning = true; } }
public void StartGame() { if (GameState == eGameState.Loading) { GameState = eGameState.Playing; ClearWaitTimer(); if (m_teamType == eTeamType.Leader) { m_redLeader = SelectLeader(m_redTeam); m_redLeader.SetCaptain(true); m_blueLeader = SelectLeader(m_blueTeam); m_blueLeader.SetCaptain(true); } Player[] list = GetAllFightPlayersSafe(); MapPoint mapPos = MapMgr.GetMapRandomPos(m_map.Info.ID); GSPacketIn pkg = new GSPacketIn((byte)ePackageType.GAME_START); pkg.WriteInt(list.Length); foreach (Player p in list) { Point pos = GetPlayerPoint(mapPos, p.Team); p.SetXY(pos); m_map.AddPhysical(p); p.StartMoving(); p.StartGame(); pkg.WriteInt(p.Id); pkg.WriteInt(p.X); pkg.WriteInt(p.Y); pkg.WriteInt(p.Direction); pkg.WriteInt(p.Blood); pkg.WriteBoolean(p.IsCaptain); } SendToAll(pkg); WaitTime(list.Length * 1000); OnGameStarted(); } }
public void init() { mRoadPointArr = new TILEDMAP_TYPE[width][]; for (int i = 0; i < width; ++i) { this.mRoadPointArr[i] = new TILEDMAP_TYPE[height]; } for (int i = 0; i < width; ++i) { for (int j = 0; j < height; ++j) { int id = JsonTest.getMe().GetStopPoint(i, j); // [i, j]; this.mRoadPointArr[i][j] = MapMgr.canThroughByID(id); } } }
public void Init(int fbid, Action cb) { resSvc = ResSvc.Instance; audioSvc = AudioSvc.Instance; //初始化各状态管理器 stateMgr = gameObject.AddComponent <StateMgr>(); stateMgr.Init(); skillMgr = gameObject.AddComponent <SkillMgr>(); skillMgr.Init(); //加载战斗的地图 mapCfg = resSvc.GetMapCfg(fbid); resSvc.AsyncLoadScene(mapCfg.sceneName, () => { //地图初始化 GameObject map = GameObject.FindGameObjectWithTag("MapRoot"); mapMgr = map.GetComponent <MapMgr>(); mapMgr.Init(this); audioSvc.PlayBGMusic(Constant.BGOrge, true); map.transform.localPosition = Vector3.zero; map.transform.localScale = Vector3.one; Camera.main.transform.position = mapCfg.mainCamPos; Camera.main.transform.localEulerAngles = mapCfg.mainCamRote; LoadPlayer(mapCfg); BattleSys.Instance.SetPlayerCtrlWindow(true); //激活第一批怪物 ActiveCurrentBatchMonster(); if (cb != null) { cb(); } }); PECommon.Log("BattleMgr Init Done"); }