Esempio n. 1
0
    public void Begin()
    {
        if (!m_Rerun)
        {
            if (m_TrackSeed != -1)
            {
                Random.InitState(m_TrackSeed);
            }
            else
            {
                Random.InitState((int)System.DateTime.Now.Ticks);
            }

            m_CurrentSegmentDistance = k_StartingSegmentDistance;
            m_TotalWorldDistance     = 0.0f;

            characterController.gameObject.SetActive(true);

            // Spawn the player
            GameObject playerGO = Instantiate(characterPrefab, Vector3.zero, Quaternion.identity);
            player = playerGO.GetComponent <Character> ();
            player.transform.SetParent(characterController.characterCollider.transform, false);
            Camera.main.transform.SetParent(characterController.transform, true);

            characterController.character    = player;
            characterController.trackManager = this;

            characterController.Init();
            characterController.CheatInvincible(invincible);
            m_CurrentZone         = 0;
            m_CurrentZoneDistance = 0;

            skyMeshFilter.sharedMesh = m_CurrentThemeData.skyMesh;
            RenderSettings.fogColor  = m_CurrentThemeData.fogColor;
            RenderSettings.fog       = true;

            gameObject.SetActive(true);
            characterController.gameObject.SetActive(true);
            characterController.coins   = 0;
            characterController.premium = 0;

            m_Score      = 0;
            m_ScoreAccum = 0;

            m_SafeSegementLeft = k_StartingSafeSegments;

            Coin.coinPool = new Pooler(currentTheme.collectiblePrefab, k_StartingCoinPoolSize);

            PlayerData.instance.StartRunMissions(this);
        }

        characterController.Begin();
        StartCoroutine(WaitToStart());
    }
    public IEnumerator Begin()
    {
        if (!m_Rerun)
        {
            firstObstacle       = true;
            m_CameraOriginalPos = Camera.main.transform.position;

            if (m_TrackSeed != -1)
            {
                Random.InitState(m_TrackSeed);
            }
            else
            {
                Random.InitState((int)System.DateTime.Now.Ticks);
            }

            // Since this is not a rerun, init the whole system (on rerun we want to keep the states we had on death)
            m_CurrentSegmentDistance = k_StartingSegmentDistance;
            m_TotalWorldDistance     = 0.0f;

            characterController.gameObject.SetActive(true);

            //Addressables 1.0.1-preview
            // Spawn the player
            var op = Addressables.InstantiateAsync(PlayerData.instance.characters[PlayerData.instance.usedCharacter],
                                                   Vector3.zero,
                                                   Quaternion.identity);
            yield return(op);

            if (op.Result == null || !(op.Result is GameObject))
            {
                Debug.LogWarning(string.Format("Unable to load character {0}.", PlayerData.instance.characters[PlayerData.instance.usedCharacter]));
                yield break;
            }
            Character player = op.Result.GetComponent <Character>();

            player.SetupAccesory(PlayerData.instance.usedAccessory);

            characterController.character    = player;
            characterController.trackManager = this;

            characterController.Init();
            characterController.CheatInvincible(invincible);

            //Instantiate(CharacterDatabase.GetCharacter(PlayerData.instance.characters[PlayerData.instance.usedCharacter]), Vector3.zero, Quaternion.identity);
            player.transform.SetParent(characterController.characterCollider.transform, false);
            Camera.main.transform.SetParent(characterController.transform, true);

            if (m_IsTutorial)
            {
                m_CurrentThemeData = tutorialThemeData;
            }
            else
            {
                m_CurrentThemeData = ThemeDatabase.GetThemeData(PlayerData.instance.themes[PlayerData.instance.usedTheme]);
            }

            m_CurrentZone         = 0;
            m_CurrentZoneDistance = 0;

            skyMeshFilter.sharedMesh = m_CurrentThemeData.skyMesh;
            RenderSettings.fogColor  = m_CurrentThemeData.fogColor;
            RenderSettings.fog       = true;

            gameObject.SetActive(true);
            characterController.gameObject.SetActive(true);
            characterController.coins   = 0;
            characterController.premium = 0;

            m_Score      = 0;
            m_ScoreAccum = 0;

            m_SafeSegementLeft = m_IsTutorial ? 0 : k_StartingSafeSegments;

            Coin.coinPool = new Pooler(currentTheme.collectiblePrefab, k_StartingCoinPoolSize);

            PlayerData.instance.StartRunMissions(this);

#if UNITY_ANALYTICS
            AnalyticsEvent.GameStart(new Dictionary <string, object>
            {
                { "theme", m_CurrentThemeData.themeName },
                { "character", player.characterName },
                { "accessory", PlayerData.instance.usedAccessory >= 0 ? player.accessories[PlayerData.instance.usedAccessory].accessoryName : "none" }
            });
#endif
        }

        characterController.Begin();
        StartCoroutine(WaitToStart());
        isLoaded = true;
    }
    public void Begin()
    {
        if (!m_Rerun)
        {
            if (m_TrackSeed != -1)
            {
                Random.InitState(m_TrackSeed);
            }
            else
            {
                Random.InitState((int)System.DateTime.Now.Ticks);
            }

            // Since this is not a rerun, init the whole system (on rerun we want to keep the states we had on death)
            m_CurrentSegmentDistance = k_StartingSegmentDistance;
            m_TotalWorldDistance     = 0.0f;

            characterController.gameObject.SetActive(true);

            // Spawn the player
            Character player = Instantiate(CharacterDatabase.GetCharacter(PlayerData.instance.characters[PlayerData.instance.usedCharacter]), Vector3.zero, Quaternion.identity);
            player.transform.SetParent(characterController.characterCollider.transform, false);
            Camera.main.transform.SetParent(characterController.transform, true);


            player.SetupAccesory(PlayerData.instance.usedAccessory);

            characterController.character    = player;
            characterController.trackManager = this;

            characterController.Init();
            characterController.CheatInvincible(invincible);

            if (m_IsTutorial)
            {
                m_CurrentThemeData = tutorialThemeData;
            }
            else
            {
                m_CurrentThemeData = ThemeDatabase.GetThemeData(PlayerData.instance.themes[PlayerData.instance.usedTheme]);
            }

            m_CurrentZone         = 0;
            m_CurrentZoneDistance = 0;

            skyMeshFilter.sharedMesh = m_CurrentThemeData.skyMesh;
            RenderSettings.fogColor  = m_CurrentThemeData.fogColor;
            RenderSettings.fog       = true;

            gameObject.SetActive(true);
            characterController.gameObject.SetActive(true);
            characterController.coins   = 0;
            characterController.premium = 0;

            m_Score      = 0;
            m_ScoreAccum = 0;

            m_SafeSegementLeft = m_IsTutorial ? 0 : k_StartingSafeSegments;

            Coin.coinPool = new Pooler(currentTheme.collectiblePrefab, k_StartingCoinPoolSize);

            PlayerData.instance.StartRunMissions(this);

#if UNITY_ANALYTICS
            AnalyticsEvent.GameStart(new Dictionary <string, object>
            {
                { "theme", m_CurrentThemeData.themeName },
                { "character", player.characterName },
                { "accessory", PlayerData.instance.usedAccessory >= 0 ? player.accessories[PlayerData.instance.usedAccessory].accessoryName : "none" }
            });
#endif
        }

        characterController.Begin();
        StartCoroutine(WaitToStart());
    }
    public void Begin()
    {
        prevSectionLife = characterController.currentLife;
        numbSegsMade    = 0;
        segmentsPassed  = 0;

        keysPressed                      = new int[2];
        trippedThisSegment               = false;
        sectionStartCoinScore            = 0;
        numCoinsPerSection               = new List <int> ();
        segmentIDs                       = new List <int> ();
        previousCoinCollectionPercentage = 1f;
        prevSectionLife                  = 3;

        currentGame++;
        playerID   = idText.text == "" ? 999 : int.Parse(idText.text);
        gameType   = adaptiveText.text == "" ? 1 : int.Parse(adaptiveText.text);
        isAdaptive = gameType != 0;

        allDataOut     = playerID + "_" + gameType + "_all.csv";
        summaryDataOut = playerID + "_" + gameType + "_summary.csv";

        if (currentGame == 1)
        {
            using (System.IO.StreamWriter file =
                       new System.IO.StreamWriter((summaryDataOut), true)) {
                file.WriteLine("Game, Section, Current_Section_ID, PCG_Section_ID, PCG_NextID, UCTScore, ExploitScore, ExploreScore, Joy, Fear, Disgust, Sadness,Anger, Suprise, Contempt, Valence, Engagement, Game Score\n");
            }
            using (System.IO.StreamWriter file =
                       new System.IO.StreamWriter((allDataOut), true)) {
                file.WriteLine("Game, Section, Current_Section_ID, Joy, Fear, Disgust, Sadness,Anger, Suprise, Contempt, Valence, Engagement\n");
            }
        }


        if (!m_Rerun)
        {
            if (m_TrackSeed != -1)
            {
                Random.InitState(m_TrackSeed);
            }
            else
            {
                Random.InitState((int)System.DateTime.Now.Ticks);
            }

            // Since this is not a rerun, init the whole system (on rerun we want to keep the states we had on death)
            m_CurrentSegmentDistance = k_StartingSegmentDistance;
            m_TotalWorldDistance     = 0.0f;

            characterController.gameObject.SetActive(true);

            // Spawn the player
            Character player = Instantiate(characterPreFab, Vector3.zero, Quaternion.identity);
            player.transform.SetParent(characterController.characterCollider.transform, false);
            Camera.main.transform.SetParent(characterController.transform, true);

            characterController.character    = player;
            characterController.trackManager = this;

            characterController.Init();
            characterController.CheatInvincible(invincible);

            m_CurrentThemeData    = theme;
            m_CurrentZone         = 0;
            m_CurrentZoneDistance = 0;

            skyMeshFilter.sharedMesh = m_CurrentThemeData.skyMesh;
            RenderSettings.fogColor  = m_CurrentThemeData.fogColor;
            RenderSettings.fog       = true;

            gameObject.SetActive(true);
            characterController.gameObject.SetActive(true);
            characterController.coins   = 0;
            characterController.premium = 0;

            m_Score      = 0;
            m_ScoreAccum = 0;

            m_SafeSegementLeft = k_StartingSafeSegments;

            Coin.coinPool = new Pooler(currentTheme.collectiblePrefab, k_StartingCoinPoolSize);
        }

        characterController.Begin();
        StartCoroutine(WaitToStart());
    }
Esempio n. 5
0
    public void Begin()
    {
        Debug.Log("Track Manager 1");
        if (!m_Rerun)
        {
            Debug.Log("Track Manager 2");
            if (m_TrackSeed != -1)
            {
                Debug.Log("Track Manager 3.1");
                Random.InitState(m_TrackSeed);
            }
            else
            {
                Debug.Log("Track Manager 3.2");
                Random.InitState((int)System.DateTime.Now.Ticks);
            }

            Debug.Log("Track Manager 4");
            // Since this is not a rerun, init the whole system (on rerun we want to keep the states we had on death)
            m_CurrentSegmentDistance = k_StartingSegmentDistance;
            Debug.Log("Track Manager 5");
            m_TotalWorldDistance = 0.0f;
            Debug.Log("Track Manager 6");

            characterController.gameObject.SetActive(true);
            Debug.Log("Track Manager 7");

            // Spawn the player
            Character player = Instantiate(MyPlayer.transform.GetChild(5).GetComponent <Character>() /*CharacterDatabase.GetCharacter(PlayerData.instance.characters[PlayerData.instance.usedCharacter])*/, Vector3.zero, Quaternion.identity);
            Debug.Log("Track Manager 8");
            player.transform.SetParent(characterController.characterCollider.transform, false);
            Debug.Log("Track Manager 9");
            Camera.main.transform.SetParent(characterController.transform, true);
            Debug.Log("Track Manager 10");


            player.SetupAccesory(PlayerData.instance.usedAccessory);
            Debug.Log("Track Manager 11");

            characterController.character = player;
            Debug.Log("Track Manager 12");
            characterColl.character = player;
            Debug.Log("Track Manager 13");
            characterController.trackManager = this;
            Debug.Log("Track Manager 14");

            characterController.Init();
            Debug.Log("Track Manager 15");
            characterController.CheatInvincible(invincible);
            Debug.Log("Track Manager 16");

            m_CurrentThemeData = MyTheme; //ThemeDatabase.GetThemeData(PlayerData.instance.themes[PlayerData.instance.usedTheme]);

            foreach (var th in PlayerData.instance.themes)
            {
                Debug.Log(th);
            }

            Debug.Log("Track Manager 17");
            m_CurrentZone = 0;
            Debug.Log("Track Manager 18");
            m_CurrentZoneDistance = 0;
            Debug.Log("Track Manager 19");

            skyMeshFilter.sharedMesh = m_CurrentThemeData.skyMesh; //MySky.mesh;
            Debug.Log("Track Manager 20");
            RenderSettings.fogColor = m_CurrentThemeData.fogColor; //Color.black;
            Debug.Log("Track Manager 21");
            RenderSettings.fog = true;
            Debug.Log("Track Manager 22");

            gameObject.SetActive(true);
            Debug.Log("Track Manager 23");
            characterController.gameObject.SetActive(true);
            Debug.Log("Track Manager 24");
            characterController.coins = 0;
            Debug.Log("Track Manager 25");
            characterController.premium = 0;
            Debug.Log("Track Manager 26");

            m_Score = 0;
            Debug.Log("Track Manager 27");
            m_ScoreAccum = 0;
            Debug.Log("Track Manager 28");

            m_SafeSegementLeft = k_StartingSafeSegments;
            Debug.Log("Track Manager 29");

            Coin.coinPool = new Pooler(MyTheme.collectiblePrefab /*currentTheme.collectiblePrefab*/, k_StartingCoinPoolSize);
            Debug.Log("Track Manager 30");

            PlayerData.instance.StartRunMissions(this);
            Debug.Log("Track Manager 31");

/*#if UNITY_ANALYTICS
 *          AnalyticsEvent.GameStart(new Dictionary<string, object>
 *          {
 *              { "theme", m_CurrentThemeData.themeName},
 *              { "character", player.characterName },
 *              { "accessory",  PlayerData.instance.usedAccessory >= 0 ? player.accessories[PlayerData.instance.usedAccessory].accessoryName : "none"}
 *          });
 #endif
 *          Debug.Log("Track Manager 32");*/
        }
        Debug.Log("Track Manager 33");

        characterController.Begin();
        Debug.Log("Track Manager 34");
        StartCoroutine(WaitToStart());
        Debug.Log("Track Manager 35");
    }