/*private int xtra = 0; * public void _switch() * { * xtra++; * if (xtra > 3) * xtra = 0; * ChangePhase(WorldState.CENTER, (WorldStateExtra)xtra); * }*/ public int Spawn(GOType type, Vector3 pos, int guid = -1, int extra = 0) { GameObject go; int _guid = -1; switch (type) { case GOType.GO_PLAYER: go = player_pool.Pop(pos, Quaternion.identity); _guid = ObjectMgr.Instance.Register(go, type, guid, extra); BomberController controller = go.GetComponent <BomberController>(); controller.ColorIndex = extra; break; case GOType.GO_BOMB: go = bomb_pool.Pop(pos, Quaternion.identity); _guid = ObjectMgr.Instance.Register(go, type, guid, extra); break; case GOType.GO_PWRUP: go = pwr_up_pool.Pop(pos, Quaternion.identity); PowerUpGOScript sc = go.GetComponent <PowerUpGOScript>(); sc.type = (Config.PowerType)extra; sc.Init(); _guid = ObjectMgr.Instance.Register(go, type, guid, extra); break; } if (_guid > 0 && ((GameMgr.Instance.Type & GameMgrType.SERVER) != 0)) { GameMgr.Instance.s.SendPacketBroadCast(PacketBuilder.BuildInstantiateObjPacket(ObjectMgr.Instance.DumpData(_guid))); } return(_guid); }
public void RegisterPlayer(TcpClient cl, int flags) { int _session = ++session; Maps maps = GameMgr.Instance.maps; SendPacketTo(cl, PacketBuilder.BuildSendMapPacket(maps)); byte[] data = ObjectMgr.Instance.DumpData(); if (data.Length > 0) { SendPacketTo(cl, PacketBuilder.BuildInstantiateObjPacket(data)); } int guid = GameMgr.Instance.Spawn(GOType.GO_PLAYER, GetInitPos(session - 1), -1, _session - 1); m_sessions[_session] = new ClientSession(_session, guid, cl); if ((flags & 4) != 0) {// hack lol ObjectMgr.Instance.Get(guid).GetComponent <BomberController>().m_IsPlayer = true; GameMgr.Instance.c.Guid = guid; } SendPacketTo(cl, PacketBuilder.BuildPlayerConnectPacket(_session, guid, 0, GameMgr.Instance.gameIntel)); }