// Use this for initialization void Start() { if (isLocalPlayer) { s_username = GameSpark.getUsername(); game.localPlayer = this.gameObject; if (isClientOnly) { CmdAddPlayer(); P_pinger = new Ping(NetworkManager.singleton.networkAddress); } else { game.aP_players.Add(this); } } SR_renderer = GetComponent <SpriteRenderer>(); changeSprite(); //Random spawn position V_position = new Vector3(Random.Range(-(i_screensize * 0.8f), (i_screensize * 0.8f)), Random.Range(-(i_screensize * 0.8f), (i_screensize * 0.8f)), 0); V_cameraPos = Camera.main.transform.position; }
void Awake() { if (instance == null) // check to see if the instance has a reference { instance = this; // if not, give it a reference to this class... DontDestroyOnLoad(this.gameObject); // and make this object persistent as we load new scenes } else // if we already have a reference then remove the extra manager from the scene { Destroy(this.gameObject); } }
void RpcGameOver(string winner) { if (localPlayer.GetComponent <player>().s_username == winner) { T_WinLose.text = "WINNER"; GameSpark.UpdateWin(); } else { T_WinLose.text = "LOSER\n" + winner + " won"; } GameSpark.UpdateKills(localPlayer.GetComponent <player>().i_kills); NetworkManager.Shutdown(); SceneManager.LoadScene("EndGame"); }