Пример #1
0
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(gameObject);
            return;
        }

        gameObject.transform.parent = null;
        //DontDestroyOnLoad(gameObject);
        DontDestroyOnLoadManager.DontDestroyOnLoad(gameObject);

        foreach (Sound s in sounds)
        {
            s.source = gameObject.AddComponent <AudioSource>();

            s.source.clip = s.clip;

            s.source.volume      = s.volume;
            s.source.pitch       = s.pitch;
            s.source.playOnAwake = s.playOnAwake;
            s.source.loop        = s.loop;
        }
    }
Пример #2
0
    public void onUserConnected(List <string> names)
    {
        for (int i = 0; i < names.Count; i++)
        {
            list[i].gameObject.SetActive(true);
            list[i].nameText.text = names[i];
            Debug.Log(names[i]);
            if (names[i] == playerTemp.playerName)
            {
                curPlayer = list[i];
                //button0.gameObject.SetActive(true);
            }
        }

        if (names.Count == 2)
        {
            for (int i = 0; i < names.Count; i++)
            {
                if (names[i] != playerTemp.playerName)
                {
                    GameObject player = Instantiate(playerPrefab, new Vector3(), Quaternion.identity);
                    player.name = player.GetComponent <Player>().playerName = names[i];
                    DontDestroyOnLoadManager.DontDestroyOnLoad(player);
                }
            }
            Debug.Log("beres");
            StartCoroutine(gameStart());
        }
    }
Пример #3
0
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(gameObject);
            return;
        }
        GameEvents.SaveInitiated += Save;
        GameEvents.LoadInitiated += Load;

        gameObject.transform.parent = null;
        //DontDestroyOnLoad(gameObject);
        DontDestroyOnLoadManager.DontDestroyOnLoad(gameObject);

        /* if (instance != null)
         * {
         *   Debug.LogWarning("More than one instance of inventory");
         *   return;
         * }
         *
         * instance = this;*/
    }
Пример #4
0
 // Start is called before the first frame update
 void Start()
 {
     ClickControl.playerCode     = "";
     ClickControl.totalDigits    = 0;
     ClickControl.numOfTries     = 5;
     ClickControlLv2.playerCode  = "";
     ClickControlLv2.totalDigits = 0;
     ClickControlLv2.numOfTries  = 5;
     CheckPassword.numOfTries    = 5;
     DontDestroyOnLoadManager.DestroyAll();
 }
Пример #5
0
 void Start()
 {
     if (DontDestroyOnLoadManager.Objects.Count == 0)
     {
         GameObject creation = Instantiate(prefab) as GameObject;
         DontDestroyOnLoadManager.DontDestroyOnLoad(creation);
     }
     else if (DontDestroyOnLoadManager.Objects.Count > 1)
     {
         DontDestroyOnLoadManager.DestroyAll();
         Debug.LogError("FATAL ERROR : 뭔가 이상해!!");
         return;
     }
 }
Пример #6
0
    void Awake()
    {
        int GameStatusCount = FindObjectsOfType <InventoryUI>().Length;

        if (GameStatusCount > 1)
        {
            gameObject.SetActive(false);
            //Destroy(gameObject);
        }
        else
        {
            //DontDestroyOnLoad(gameObject);
            DontDestroyOnLoadManager.DontDestroyOnLoad(gameObject);
        }
    }
Пример #7
0
    public void onStartClick()
    {
        string name = nameInput.text;
        string IP   = IPInput.text;

        Debug.Log(name + " " + IP);
        PlayerPrefs.SetString("name", name);
        PlayerPrefs.SetString("ip", IP);
        GameObject player = Instantiate(playerPrefab, new Vector3(), Quaternion.identity);

        player.name = name;
        player.GetComponent <Player>().playerName = name;
        DontDestroyOnLoadManager.DontDestroyOnLoad(player);

        SceneManager.LoadScene("lobby");
    }
Пример #8
0
        public Timers()
        {
            _inst                = this;
            gameObject           = new GameObject("[FairyGUI.Timers]");
            gameObject.hideFlags = HideFlags.HideInHierarchy;
            gameObject.SetActive(true);
            //Object.DontDestroyOnLoad(gameObject);
            DontDestroyOnLoadManager.DontDestroyOnLoad(gameObject, 2, () => { _inst = null; }); //重启流程

            _engine = gameObject.AddComponent <TimersEngine>();

            _items    = new Dictionary <TimerCallback, Anymous_T>();
            _toAdd    = new Dictionary <TimerCallback, Anymous_T>();
            _toRemove = new List <Anymous_T>();
            _pool     = new List <Anymous_T>(100);
        }
Пример #9
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(gameObject);
         return;
     }
     gameObject.transform.parent = null;
     //DontDestroyOnLoad(gameObject);
     DontDestroyOnLoadManager.DontDestroyOnLoad(gameObject);
     GameEvents.SaveInitiated += Save;
     GameEvents.LoadInitiated += Load;
 }
Пример #10
0
        private void OnConsoleCommand(IConsole console, string cmd, params string[] args)
        {
            if (cmd == "launch")
            {
                TestGameInitArgs gameInitArgs = new TestGameInitArgs();
                if (args.Length > 2)
                {
                    gameInitArgs.MapName = args[2];
                }
                else
                {
                    console.Echo("launch <playersCount> <botsCount> <mapname>");
                    return;
                }

                if (args.Length > 0)
                {
                    int.TryParse(args[0], out gameInitArgs.PlayersCount);
                    gameInitArgs.PlayersCount = Mathf.Clamp(gameInitArgs.PlayersCount, 0, GameConstants.MaxLocalPlayers);
                }
                else
                {
                    console.Echo("launch <playersCount> <botsCount> <mapname>");
                    return;
                }

                if (args.Length > 1)
                {
                    int.TryParse(args[1], out gameInitArgs.BotsCount);
                    gameInitArgs.BotsCount = Mathf.Clamp(gameInitArgs.BotsCount, 0, GameConstants.MaxPlayers - gameInitArgs.BotsCount);
                }
                else
                {
                    console.Echo("launch <playersCount> <botsCount> <mapname>");
                    return;
                }

                if (Dependencies.Navigation != null)
                {
                }
                DontDestroyOnLoadManager.DestroyAll();
                Dependencies.State.SetValue("Battlehub.VoxelGame.TestGameInitArgs", gameInitArgs);
                Dependencies.Navigation.Navigate("Game");
            }
        }
Пример #11
0
    //private static MoveLetter letterInstance;

    /*
     * public string GetLetterStatus()
     * { return letterStatus; }
     *
     * public void SetLetterStatus(string value)
     * {
     *  letterStatus = value;
     * }
     */
    // Start is called before the first frame update
    void Start()
    {
        //DontDestroyOnLoad(this.gameObject);
        DontDestroyOnLoadManager.DontDestroyOnLoad(this.gameObject);

        /*if (letterInstance == null)
         * {
         *  letterInstance = this;
         * }
         * else
         * {
         *  DestroyObject(gameObject);
         * }
         */

        if (FindObjectsOfType(GetType()).Length > 9)
        {
            Destroy(gameObject);
        }
    }
Пример #12
0
        static void Init()
        {
            _inited = true;
            if (Application.isPlaying)
            {
                GameObject gameObject = new GameObject("[FairyGUI.TweenManager]");
                gameObject.hideFlags = HideFlags.HideInHierarchy;
                gameObject.SetActive(true);
                //Object.DontDestroyOnLoad(gameObject);
                DontDestroyOnLoadManager.DontDestroyOnLoad(gameObject, 2, () =>
                {
                    _inited       = false;
                    _activeTweens = new GTweener[30];
                    _tweenerPool.Clear();
                    _totalActiveTweens = 0;
                }
                                                           ); //重启流程

                gameObject.AddComponent <TweenEngine>();
            }
        }
Пример #13
0
    void Start()
    {
        Countdown.onCountdownEnd.AddListener(EnableBoard);
        onGameReset.AddListener(Reset);
        onGameStart.AddListener(StartGame);
        difficultySettingsData = new DifficultySettingsData();
        InitialiseStatPlayerPrefs();
        onGameReset.Invoke();

        customSettingInfo = difficultySettingsData.Difficulties.CustomPlayerPref;
        if (!PlayerPrefs.HasKey(customSettingInfo.Col.Name))
        {
            PlayerPrefs.SetInt(customSettingInfo.Col.Name, customSettingInfo.Col.InitialValue);
        }
        if (!PlayerPrefs.HasKey(customSettingInfo.Row.Name))
        {
            PlayerPrefs.SetInt(customSettingInfo.Row.Name, customSettingInfo.Row.InitialValue);
        }

        Difficulty currentGameDifficulty = GameDifficulty.gameDifficulty.GetCurrentGameDifficulty();

        onGameStart.Invoke(GetDifficultyInfo(currentGameDifficulty));
        DontDestroyOnLoadManager.RemoveObj(GameDifficulty.gameDifficulty.gameObject);
    }
Пример #14
0
 public void LoadSaveScene()
 {
     FindObjectOfType <PlayerControlsManager>().ToggleOnGenericUI();
     DontDestroyOnLoadManager.DestroyAll();
     SceneManager.LoadScene("Savefile Menu");
 }
Пример #15
0
 public void DestroyOnLoad()
 {
     DontDestroyOnLoadManager.RemoveObj(gameObject);
 }
Пример #16
0
 // Start is called before the first frame update
 void Start()
 {
     DontDestroyOnLoadManager.AddObj(gameObject);
     gameDifficulty = this;
 }
Пример #17
0
 private void Awake()
 {
     DontDestroyOnLoadManager.DontDestroyOnLoad(transform.gameObject);
 }