public void OnDestroy()
 {
     if (_instance == this)
     {
         _instance = null;
     }
 }
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
     if (!PlayerPrefs.HasKey("HighScore"))
     {
         PlayerPrefs.SetInt("Music", 1);
         PlayerPrefs.SetInt("HighScore", 0);
     }
 }
示例#3
0
    /*  General Code  */

    void Start()
    {
        PhotonView    = GetComponent <PhotonView>();
        mapProperties = MapManager.Instance.GetMapProperties();
        if (PhotonNetwork.player.IsLocal)
        {
            GetComponent <Entity>().team = PhotonView.owner.GetTeam();
            gameUIHandler = GameObject.Find("GameManager").GetComponent <GameUIHandler>();

            // Tell other players to rename this player's character to be the name of the champion
            gameObject.name = PhotonNetwork.player.CustomProperties["championName"].ToString();
            PhotonView.RPC("Rename", PhotonTargets.AllBuffered, PhotonNetwork.player.CustomProperties["championName"].ToString());
            usernameText.text = PhotonView.owner.NickName;

            // Create a new champion class for this player so that we can store their details
            Champion = ScriptableObject.CreateInstance <Champion>();
            Champion.Init(ChampionRoster.Instance.GetChampion(gameObject.name), PhotonNetwork.player.NickName);
            Champion.health = oldHealth = Champion.maxHealth;
            Champion.mana   = Champion.maxMana;

            // Update UI to show full health and mana, etc
            if (PhotonView.isMine)
            {
                // Hide username/healthbar if in third person
                if (mapProperties.display == PlayerCamera.CameraDisplays.ThirdPerson)
                {
                    canvas.SetActive(false);
                }

                Entity.onEntityDeath += OnEntityDeath;

                // Set up ability indicators and particle effects
                AbilityHandler.Instance.SetupAbilityIndicators(gameObject);
                EffectsHandler.Instance.SetupEffects(gameObject, PhotonView);

                gameUIHandler.UpdateAbilities(Champion);
                gameUIHandler.UpdateStats(Champion);
                gameUIHandler.SetCharacterIcon(Champion);
                Respawn();
                UIHandler.Instance.HideLobbyUI();
            }

            // Tell other players to update the health and mana bar of this player
            PhotonView.RPC("UpdatePlayerHealth", PhotonTargets.AllBuffered, new object[] { Champion.health, Champion.maxHealth });
            PhotonView.RPC("UpdatePlayerMana", PhotonTargets.AllBuffered, new object[] { Champion.mana, Champion.maxMana });
        }
    }
    public void Awake()
    {
        //Instance handling and creation
        if (_instance != null)
        {
            Destroy(gameObject);
            return;
        }

        _instance = this;

        //Disable all elements
        m_resourceCanvas.gameObject.SetActive(false);
        m_progressBars.gameObject.SetActive(false);
        m_gameTime.gameObject.SetActive(false);
        m_notificationLayout.gameObject.SetActive(false);
        m_InteractNotification.gameObject.SetActive(false);
        m_minimap.gameObject.SetActive(false);
        m_WaitingDialog.gameObject.SetActive(true);
    }
 void DeathUI()
 {
     GameUIHandler.DeathScreen();
 }
示例#6
0
 // Allows the script to be accessed by other players, called at the start of the game.
 void Awake()
 {
     Instance = this;
 }