public void HeroChange(int connectionId, ushort val) { MobileAgent _ma = agents.Find(x => ((x.user != null) ? x.user.connectionId : x.customId) == connectionId); if (_ma != null) { if (val < 0 || val >= ServerManager.playerHeroes.Count || isStarted) { return; } /* * IF YOU WANT TO MAKE SOME 'UNLOCK HEROES' THING. THIS IS THE PLACE * */ _ma.LoadHero(ServerManager.playerHeroes[val].clientPrefab, true); Update(true); _ma.agentLevel.UpdateLevel(); } }
public MobileAgent JoinGame(NetworkConnection conn, Callipso.GameSession _gameSession, string alias, string clientPrefab = null, bool isHero = false, ushort mapId = 0) { if (conn != null) { SendHeroInfo(conn); // Send hero list } if (_gameSession == null) { // No game found creating session Debug.Log("Creating game session"); _gameSession = new Callipso.GameSession(); _gameSession.id = createdSessions++; _gameSession.map = mapId; int cSpawns = MapLoader.maps[_gameSession.map].creatureSpawns.Count; _gameSession.creatureSpawns = new float[cSpawns]; _gameSession.round = 1; _gameSession.time = Time.time + MapLoader.maps[_gameSession.map].lobbyTime; _gameSession.teamsize = MapLoader.maps[_gameSession.map].teamsize; sessions.Add(_gameSession); } else { Debug.Log("Joining game session"); } GameObject _player = new GameObject("Player"); MobileAgent _ma = _player.AddComponent <MobileAgent>(); _ma.agentLevel = _player.AddComponent <MobileAgent_Leveling>(); _ma.agentLevel.myAgent = _ma; _ma.agentBuff = _player.AddComponent <MobileAgent_Buffs>(); _ma.agentBuff.myAgent = _ma; _ma.session = _gameSession; _ma.user = conn; if (_ma.user != null) { _ma.session.users.Add(conn); } if (_ma.user == null) { _ma.customId = (short)(-(_gameSession.agentCreated++) - 1); } _ma.alias = alias; // set user alias SpamController.obj.SpamFor(_ma, 10); // client can send this per two seconds or the spammer will be increased (10/5) _gameSession.agents.Add(_ma); _ma.LoadHero(clientPrefab, isHero); // for bots if (_ma._hero.heroType == Callipso.HeroType.Player && _gameSession.time < Time.time + 10) { // New player joined _gameSession.time = Time.time + Mathf.Clamp(10, 0, MapLoader.maps [_gameSession.map].lobbyTime); } _gameSession.Update(true); _ma.agentLevel.UpdateLevel(); // send the level info return(_ma); }