예제 #1
0
    // 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;
    }
예제 #2
0
 public PlayerData(PlayerSingleton player)
 {
     playerName         = player.PlayerName;
     playerLevel        = player.PlayerLevel;
     experiencePoints   = player.ExperiencePoints;
     playerPrereqStatus = player.GetPrereqStatus().GetCriteria();
 }
예제 #3
0
    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");
        }
    }
예제 #4
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
 }
예제 #5
0
    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);
        }
    }
예제 #6
0
    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();
    }
예제 #8
0
    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);
    }
예제 #9
0
 void Update()
 {
     if (transform.position.y <= -100.0f)
     {
         PlayerSingleton.EndManager();
         Application.LoadLevel(Application.loadedLevel);
     }
 }
예제 #10
0
 private void Awake()
 {
     if (instance)
     {
         return;
     }
     instance = this;
 }
예제 #11
0
    void UpdateUserInfoText()
    {
        CasinoWarPlayer player = PlayerSingleton.GetPlayer();

        UserInfoText.text = "User ID: " + player.getID() +
                            "\nUser Name: " + player.getUserName() +
                            "\nCredit: " + player.getNewCredit();
    }
예제 #12
0
 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();
 }
예제 #13
0
    private void Awake()
    {
        if (S == null)
        {
            S = this;
        }

        PlayerTransform = this.transform;
    }
예제 #14
0
 public void SwitchGirl()
 {
     PlayerSingleton.player = girl;
     Destroy(boy);
     _selected = girl;
     PlayerSingleton.ChosenType(girl);
     DontDestroyOnLoad(girl);
     this.gameObject.SetActive(false);
     CheckDuplicates(1);
 }
예제 #15
0
        public override void GenerateIncome()
        {
            float income = 0;

            for (int i = 0; i < resources.Length; i++)
            {
                income += 100;
            }
            PlayerSingleton.AddMoney(income);
        }
예제 #16
0
    private void Start()
    {
        session = FindObjectOfType <GameSession>();
        if (!session)
        {
            sceneLoader.GoToPreload();
        }

        player = FindObjectOfType <PlayerSingleton>();
        FinalizeResults(session.IsRunSuccessful);
    }
예제 #17
0
        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);
        }
예제 #18
0
    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);
    }
예제 #19
0
 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);
     }
 }
예제 #23
0
 void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
         DontDestroyOnLoad(this.gameObject);
     }
     else
     {
         Destroy(gameObject);
     }
     player = FindObjectOfType <Player>();
 }
예제 #24
0
    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 { });
    }
예제 #25
0
    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;
    }
예제 #26
0
    // Use this for initialization
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }

        else if (instance != this)
        {
            Destroy(gameObject);
            DontDestroyOnLoad(gameObject);
        }
    }
예제 #27
0
 private void Awake()
 {
     if (playerInstance != null && playerInstance != this)
     {
         Destroy(this.gameObject);
         return;
     }
     else
     {
         playerInstance = this;
     }
     DontDestroyOnLoad(this.gameObject);
     StateManager.singletons.Add(this.gameObject);
 }
예제 #28
0
 // 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);
 }
예제 #29
0
    void Awake()
    {
        // Initialized singleton
        if (instance == null)
        {
            instance = this;
            DontDestroyOnLoad(gameObject);
        }
        else
        {
            Destroy(gameObject);
        }

        // init other miscs
        SceneManager.sceneLoaded += OnSceneLoaded;
    }
예제 #30
0
 public void Awake()
 {
     if (!plr)
     {
         DontDestroyOnLoad(gameObject);
         plr = this;
     }
     else
     {
         if (plr != this)
         {
             plr.transform.position = transform.position;
             Destroy(gameObject);
         }
     }
 }