// Use this for initialization void Awake() { player = GameObject.FindWithTag("Player"); if (instance != null && instance != this) // If there is an existing music player //GetComponent<Transform> ().position = new Vector3 (0.3f, 8.85f, 23.2f); //GetComponent<Transform> ().position = new Vector3 (-21.5f, -13.9f, 27.6f); { Destroy(this.gameObject); // Destroy this one, don't need to //player.GetComponent<Transform>().position = new Vector3 (-21.5f, -13.9f, 27.6f); //player.GetComponent<Transform>().position = new Vector3 (-21.5f, -13.9f, 27.6f); SetPosition(); return; // skip the rest } else // Otherwise { instance = this; // There is no music player, use this //player.GetComponent<Transform>().position = new Vector3 (-21.5f, -13.9f, 27.6f); SetPosition(); } DontDestroyOnLoad(this.gameObject); // Don't destroy when the scene loads (object script is attached to) Debug.Log("Test"); //SetPosition (); //level2Position = false; //level3Position = false; }
public PlayerData(PlayerSingleton player) { playerName = player.PlayerName; playerLevel = player.PlayerLevel; experiencePoints = player.ExperiencePoints; playerPrereqStatus = player.GetPrereqStatus().GetCriteria(); }
public void LoginOnClick() { string userid = inputField.text; string url = "http://107.21.13.205/api/values/" + userid; CasinoWarPlayer player = new CasinoWarPlayer(); if ((player = JsonUtility.FromJson <CasinoWarPlayer>(Get(url))) != null) { // you know that the parsing attempt // was successful //PlayerSingleton.SetPlayer(userid, credit); Debug.Log(Get(url) + "\n" + JsonUtility.ToJson(player)); PlayerPrefs.SetString("userid", userid); PlayerPrefs.SetString("username", player.getUserName()); SceneManager.LoadScene(sceneName: "TestScene"); PlayerSingleton.SetPlayer(player); Debug.Log("login as " + player.getUserName() + "credit: " + player.getNewCredit()); } else { Debug.Log("invalid userid"); } }
private void Awake() { if (Instance == null) { Instance = this; } }
void UpdateResultGui(CasinoWarPlayer player) { Hashtable table = (Hashtable)PhotonNetwork.CurrentRoom.CustomProperties["table"]; Text actorField; for (int seat = 1; seat <= 5; seat++) { if ((int)table[seat] == player.getActorID()) { actorField = Seats.transform.GetChild(ComputeSlot(seat)).GetChild(1).gameObject.GetComponent <Text>(); actorField.text = "Card: " + player.getMycard().ToString() + "\nWin Result: " + player.getResult(); } } if (player.getActorID() == PhotonNetwork.LocalPlayer.ActorNumber) { if (player.getResult() == 2) { WarButton.gameObject.SetActive(true); } PlayerSingleton.GetPlayer().setCredit(player.getNewCredit()); PhotonNetwork.SetPlayerCustomProperties(new Hashtable() { { "credit", player.getNewCredit() } }); UpdatePlayerGui(PhotonNetwork.LocalPlayer); UpdateUserInfoText(); // UpdatePlayerGui(PhotonNetwork.LocalPlayer); } }
public void DoBet() { if ((int)PhotonNetwork.LocalPlayer.CustomProperties["bet"] != 0 || (int)PhotonNetwork.CurrentRoom.CustomProperties["phase"] == 2 || (int)PhotonNetwork.CurrentRoom.CustomProperties["phase"] == 4) { return; } byte evCode = 66; CasinoWarPlayer player = PlayerSingleton.GetPlayer(); player.setBet(100); player.setActorNumber(PhotonNetwork.LocalPlayer.ActorNumber); PhotonNetwork.SetPlayerCustomProperties(new Hashtable() { { "bet", 100 } }); string playerString = JsonUtility.ToJson(player); UpdatePlayerGui(PhotonNetwork.LocalPlayer); Debug.Log(playerString); RaiseEventOptions raiseEventOptions = new RaiseEventOptions { Receivers = ReceiverGroup.All }; // You would have to set the Receivers to All in order to receive this event on the local client as well SendOptions sendOptions = new SendOptions { Reliability = true }; PhotonNetwork.RaiseEvent(evCode, playerString, raiseEventOptions, sendOptions); }
private void Start() { player = FindObjectOfType <PlayerSingleton>(); rigidBody = GetComponent <Rigidbody2D>(); SetEquipment(); SetMovementBoundaries(); }
IEnumerator LoadLevel(string sceneName) { SceneTransAnimator.SetTrigger("Start"); yield return(new WaitForSeconds(TransitionTime)); PlayerSingleton.instance.state = PlayerSingleton.nextState(PlayerSingleton.instance.state); SceneManager.LoadScene(exitScene, LoadSceneMode.Single); }
void Update() { if (transform.position.y <= -100.0f) { PlayerSingleton.EndManager(); Application.LoadLevel(Application.loadedLevel); } }
private void Awake() { if (instance) { return; } instance = this; }
void UpdateUserInfoText() { CasinoWarPlayer player = PlayerSingleton.GetPlayer(); UserInfoText.text = "User ID: " + player.getID() + "\nUser Name: " + player.getUserName() + "\nCredit: " + player.getNewCredit(); }
private void OnEnable() { player = FindObjectOfType <PlayerSingleton>(); hull.text = player.GetStat(StatType.Hull).GetCalcValue().ToString(); shield.text = player.GetStat(StatType.Shield).GetCalcValue().ToString(); engine.text = player.GetStat(StatType.Engine).GetCalcValue().ToString(); weapon.text = player.GetStat(StatType.Weapon).GetCalcValue().ToString(); aux.text = player.GetStat(StatType.Aux).GetCalcValue().ToString(); }
private void Awake() { if (S == null) { S = this; } PlayerTransform = this.transform; }
public void SwitchGirl() { PlayerSingleton.player = girl; Destroy(boy); _selected = girl; PlayerSingleton.ChosenType(girl); DontDestroyOnLoad(girl); this.gameObject.SetActive(false); CheckDuplicates(1); }
public override void GenerateIncome() { float income = 0; for (int i = 0; i < resources.Length; i++) { income += 100; } PlayerSingleton.AddMoney(income); }
private void Start() { session = FindObjectOfType <GameSession>(); if (!session) { sceneLoader.GoToPreload(); } player = FindObjectOfType <PlayerSingleton>(); FinalizeResults(session.IsRunSuccessful); }
public override void GenerateIncome() { float incomePerPerson = 12.5f; float income = (population * incomePerPerson); for (int i = 0; i < resources.Length; i++) { income += 80; } PlayerSingleton.AddMoney(income); }
IEnumerator OnAllTaskFinished() { Debug.Log("all task finished"); // exit scene SceneTransAnimator.SetTrigger("Start"); yield return(new WaitForSeconds(TransitionTime)); Cursor.lockState = CursorLockMode.Locked; PlayerSingleton.instance.state = PlayerSingleton.nextState(PlayerSingleton.instance.state); SceneManager.LoadScene("Demo_Real_Office", LoadSceneMode.Single); }
void Awake() { if (m_Instance == null) { m_Instance = this; } else { Debug.LogWarning("Player instance already exists. Deleting..."); } }
private void Awake() { if (instance != null && instance != this) { Destroy(this.gameObject); return; } else { instance = this; } }
private void Awake() { if (_instance != null && _instance != this) { Destroy(this.gameObject); } else { _instance = this; DontDestroyOnLoad(this.gameObject); } }
private void Awake() { // Only let there be one instance of the player if (singleton == null) { singleton = this; } else if (singleton != this) { Destroy(gameObject); } }
void Awake() { if (Instance == null) { Instance = this; DontDestroyOnLoad(this.gameObject); } else { Destroy(gameObject); } player = FindObjectOfType <Player>(); }
void Start() { var userid = PlayerPrefs.GetString("userid"); PhotonNetwork.AuthValues = new AuthenticationValues(userid); PhotonNetwork.LocalPlayer.NickName = PlayerSingleton.GetPlayer().getUserName(); UpdateUserInfoText(); PhotonNetwork.ConnectUsingSettings(); WarButton.gameObject.SetActive(false); // PhotonNetwork.JoinLobby("casinowarlobby", new TypedLobby { }); }
private void Awake() { // if the singleton hasn't been initialized yet if (instance != null && instance != this) { Destroy(this.gameObject); return;//Avoid doing anything else } instance = this; Instance = instance; }
// Use this for initialization void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); DontDestroyOnLoad(gameObject); } }
private void Awake() { if (playerInstance != null && playerInstance != this) { Destroy(this.gameObject); return; } else { playerInstance = this; } DontDestroyOnLoad(this.gameObject); StateManager.singletons.Add(this.gameObject); }
// Use this for initialization void Awake() { if (Instance == null) { Instance = this; } else { Instance.transform.position = transform.position; Instance.transform.rotation = transform.rotation; Destroy(gameObject); return; } DontDestroyOnLoad(gameObject); }
void Awake() { // Initialized singleton if (instance == null) { instance = this; DontDestroyOnLoad(gameObject); } else { Destroy(gameObject); } // init other miscs SceneManager.sceneLoaded += OnSceneLoaded; }
public void Awake() { if (!plr) { DontDestroyOnLoad(gameObject); plr = this; } else { if (plr != this) { plr.transform.position = transform.position; Destroy(gameObject); } } }