public void OnPlayerFinishLoading(int clientId) { Character character = new Character(new Vector2(0, 0), clientId); CharacterSpawnEvent characterSpawnEvent = new CharacterSpawnEvent(clientId, character.id, new Vector2(0, 0)); players[clientId].character = character; pushEvent(characterSpawnEvent); characters.Add(character.id, character); Log.debug("Player finished loading. Spawning character."); }
private void OnCharacterSpawn(EventObject evnt) { CharacterSpawnEvent characterSpawnEvent = (CharacterSpawnEvent)evnt; UnityEngine.GameObject gameObject; CharacterBase character; if (characterSpawnEvent.owningPlayerId == thisPlayerId) { gameObject = Instantiate(localCharacterPrefab, new Vector2(characterSpawnEvent.position.X, characterSpawnEvent.position.Y), Quaternion.Euler(Vector3.forward)); character = gameObject.GetComponent <LocalCharacter>(); } else { gameObject = Instantiate(characterPrefab, new Vector2(characterSpawnEvent.position.X, characterSpawnEvent.position.Y), Quaternion.Euler(Vector3.forward)); character = gameObject.GetComponent <Character>(); } characters.Add(characterSpawnEvent.gameObjectId, character); players[characterSpawnEvent.owningPlayerId].setCharacter(character); Log.debug("[GameModelManager] Character spawned: id: " + characterSpawnEvent.gameObjectId + ", parent player id: " + characterSpawnEvent.owningPlayerId); }