Example #1
0
    private string _activeStageName;    // 現在のステージ名

    // Start is called before the first frame update
    void Start()
    {
        Debug.Log("TimeAttackStart");
        _activeStageName = SceneManager.GetActiveScene().name;

        FindInfoByScene.Instance.EntryPlayerName();

        int lapMax = FindInfoByScene.Instance.GetLapMax(_activeStageName);

        Debug.Log("lapMax:" + lapMax);

        GameObject[] racingCars = GameObject.FindGameObjectsWithTag("RacingCar");
        for (int idx = 0; idx < FindInfoByScene.Instance.GetPlayerNum; idx++)
        {
            racingCars[idx].GetComponent <LapCount>().SetUp();
            racingCars[idx].GetComponent <CheckPointCount>().SetUp();
        }

        timeRanking = timeRanking.GetComponent <TimeRanking>();
        // 第一引数をコース名にする
        timeRanking.SetUpTimeRanking(_activeStageName, 6, lapMax);

        dispRanking = dispRanking.GetComponent <DispRanking>();

        goalFlag = goalFlag.GetComponent <GoalFlag>();

        timeCounter = timeCounter.GetComponent <TimeCount>();

        startCounter = startCounter.GetComponent <StartStopController>();
    }
Example #2
0
    public void PlayerWin(GoalFlag gf)
    {
        goalFlag = gf;
        Won      = true;

        Grid?.PlayerWon();

        int bi = SceneHelpers.GetCurrentLevelBuildIndex();

        SceneHelpers.GetWorldAndLevelFromBuildIndex(bi, out int world, out int level);

        // don't save data for tutorial levels
        if (world > 0 && level > 0)
        {
            timeInfo      = new TimeInfo();
            timeInfo.Time = ElapsedTime;

            LevelData[,] allLevelData = GameManager.Instance.SaveData.LevelData;
            LevelData ld = allLevelData[world - 1, level - 1];
            if (collectedStars > ld.MaxStarsCollected)
            {
                ld.MaxStarsCollected = collectedStars;
            }
            if (collectedStars >= 3)
            {
                if (ld.ThreeStarCompletionTime < 0 || ElapsedTime < ld.ThreeStarCompletionTime)
                {
                    ld.ThreeStarCompletionTime = ElapsedTime;
                    timeInfo.Record            = true;

                    // check for 3 star achievement, otherwise player would need
                    //  to visit world complete screen to get credit for 3 starring all levels
                    bool allThreeStar = true;
                    for (int i = 0; i < 10; i++)
                    {
                        LevelData other = allLevelData[world - 1, i];
                        if (other.MaxStarsCollected < 3)
                        {
                            allThreeStar = false;
                        }
                    }
                    if (allThreeStar)
                    {
                        GameManager.Instance.StoreCommunicator.AddAchievement($"World{world}AllStars");
                    }
                }
            }
            if (ld.AnyStarCompletionTime < 0 || ElapsedTime < ld.AnyStarCompletionTime)
            {
                ld.AnyStarCompletionTime = ElapsedTime;
                timeInfo.Record          = true;
            }
        }

        GameManager.Instance.SaveLevelCompleteData(bi + 1);
    }
        private GoalFlag CreateGoalFlag(string textureName)
        {
            GoalFlag newFlag = new GoalFlag();
            newFlag.FlagTextureName = textureName;

            return newFlag;
        }