예제 #1
0
    public Dictionary <int, Field> CreateField(ref MapData data)
    {
        Dictionary <int, Field> map = new Dictionary <int, Field>();
        Vector3 startPosition       = _parentGameObject.transform.position;
        Vector3 FieldPosition       = startPosition;
        int     index    = 0;
        int     mapIndex = 0;

        for (int y = 0; y < 4; y++)
        {
            for (int x = 0; x < 4; x++)
            {
                FieldPosition = startPosition + Vector3.right * GameMetrics.SpriteWidth * x + Vector3.up * GameMetrics.SpriteHeight * y + Vector3.forward / 1000 * y;
                data.AddPosition(FieldPosition);
                mapIndex = GameMetrics.VectorToIndex(FieldPosition - startPosition);
                Field      tempField      = new Field(FieldPosition);
                Ingredient tempIngredient = CreateIngredient();
                _parentGameObject.GetChild(index).transform.position = FieldPosition;
                if (tempIngredient != null)
                {
                    _parentGameObject.GetChild(index).transform.GetChild(0).GetComponent <SpriteRenderer>().sprite = SetSprite(tempIngredient.ingredientType);
                }
                data.AddWorldRepresenation(new WorldRepresentation(_parentGameObject.GetChild(index).GetChild(0).transform, _parentGameObject.GetChild(index).GetChild(0).GetComponent <SpriteRenderer>(), index));
                tempField.SetIngredient(tempIngredient);
                map.Add(mapIndex, tempField);
                index++;
            }
        }
        data.ChangeRect(startPosition.x - GameMetrics.SpriteWidth / 2, startPosition.y - GameMetrics.SpriteHeight / 2, 4 * GameMetrics.SpriteWidth, 4 * GameMetrics.SpriteHeight);
        return(map);
    }
    // Update is called once per frame
    void Update()
    {
        if (!m_active)
        {
            return;
        }

        if ((int)m_currentTopSpeed < (int)m_targetTopSpeed)
        {
            m_currentTopSpeed += m_speedBarSpeed * Time.deltaTime;

            m_topSpeed.text  = ((int)m_currentTopSpeed).ToString();
            m_topSpeed.text += " kph";

            float barWidth = 0;
            if (m_currentTopSpeed > 100)
            {
                barWidth = (m_currentTopSpeed - 100) * 390 / 300;
            }

            if (m_currentTopSpeed > GameMetrics.GetRecordSpeed())
            {
                m_topSpeedRecord.text           = m_topSpeed.text;
                m_topSpeedRecord.material.color = Color.green;
                m_topSpeed.material.color       = Color.green;
            }

            Rect pixelInset = m_speedBar.pixelInset;
            pixelInset.width      = barWidth;
            m_speedBar.pixelInset = pixelInset;
        }
    }
예제 #3
0
 private void Awake()
 {
     if (get == null)
     {
         get = this;
     }
 }
예제 #4
0
    void UpdateSpeed()
    {
        float m_changeSpeed;

        float speedGain = 0f;

        if (m_controlsEnabled)
        {
            if (currentSpeed < 400)
            {
                speedGain = 2f * m_accelerationBias;
            }
            else
            {
                speedGain = 0.5f * m_accelerationBias;
            }
            m_targetSpeed += speedGain / 30f * Time.deltaTime;
        }

        if (m_targetSpeed > m_currentSpeed)
        {
            m_changeSpeed = m_accelSpeed;
        }
        else
        {
            m_changeSpeed = m_deaccelSpeed;
        }

        m_currentSpeed = Mathf.Lerp(m_currentSpeed, m_targetSpeed, m_changeSpeed * Time.deltaTime);

        GameMetrics.UpdateSpeed(currentSpeed);
        //m_currentSpeed = m_targetSpeed;
        //print("speed updated "+m_currentSpeed);
    }
예제 #5
0
    public void ObstacleHit()
    {
        m_lastObstacleHitTime = Time.time;

        m_currentComboCount = 0;

        GameMetrics.UpdateObstacle(true);
    }
예제 #6
0
        private void SetGameMetricData()
        {
            GameMetrics metrics = new GameMetrics();

            metrics.Metrics = new Dictionary <string, int>();
            metrics.Metrics.Add(GameMetricsList.TOTAL_MISSIONS_DONE, GetTotalMissionsCompleted());

            IntegrationTestUtils.SetReadOnlyData(IntegrationTestUtils.SAVE_KEY_METRICS, JsonConvert.SerializeObject(metrics));
        }
예제 #7
0
        private void VerifyGameMetricsIsDefault(string i_saveData)
        {
            GameMetrics metrics = JsonConvert.DeserializeObject <GameMetrics>(i_saveData);

            if (metrics.Metrics.Count != 0)
            {
                IntegrationTest.Fail("Game metrics was not empty");
            }
        }
예제 #8
0
 public override void InitGame()
 {
     playerOneMetrics = new GameMetrics(0,0,0);
     playerTwoMetrics = new GameMetrics(0,0,0);
     model = new FourInLineModel(AppController.GetController().GetCurrentLevel());
     model.StartGame();
     view.WithController(this);
     view.GameStart(model.GetGrid());
 }
예제 #9
0
        private void CheckForUnitUnlock()
        {
            int totalMissionsCompleted = GameMetrics.GetMetric(GameMetricsList.TOTAL_MISSIONS_DONE);

            if (UnitUnlockPlan.Unlocks.ContainsKey(totalMissionsCompleted))
            {
                UnlockUnit(UnitUnlockPlan.Unlocks[totalMissionsCompleted]);
            }
        }
예제 #10
0
 public void ObstacleCleared()
 {
     // check that some time has passed, so we don't count as cleared an obstacle we just hit
     if (Time.time - m_lastObstacleHitTime > 0.1f)
     {
         m_currentComboCount++;
         GameMetrics.UpdateCombo(m_currentComboCount);
     }
     GameMetrics.UpdateObstacle(false);
 }
    // Use this for initialization
    void Start()
    {
        // menu
        if (GameManager.instance == null)
        {
            int a = GameMetrics.GetAchievement(1, (int)GameMetrics.activeGameMode);

            SetAchievementCount(a);
        }
    }
예제 #12
0
        public void ShowInfoOf(int pointNumber)
        {
            GameMetrics currentMetric = metricsPoints[pointNumber];

            date.text = currentMetric.GetDate();
//            score.text = "" +currentMetric.GetScore();
//            time.text = "" + currentMetric.GetLapsedSeconds() + " s";
//            correctQuantity.text = "" + currentMetric.GetRightAnswers();
//            incorrectQuantity.text = "" + currentMetric.GetWrongAnswers();
        }
예제 #13
0
        public void SetValues(GameMetrics gameMetrics)
        {
            for (int i = 0; i < 3; i++)
            {
                stars[i].gameObject.SetActive(i < gameMetrics.GetStars());
            }
            score.text = "" + gameMetrics.GetScore();
//            scorePercentage = (int)(((gameMetrics.GetScore() + 0f) / (MetricsController.GetController().GetMaxScore() + 0f)) * 100);
            correct.text   = "" + gameMetrics.GetRightAnswers();
            incorrect.text = "" + gameMetrics.GetWrongAnswers();
            Invoke("IncrementProgressBar", 0.1f);
            RangeText.text     = gameMetrics.GetRange().ToString();
            BonusTimeText.text = "" + gameMetrics.GetBonusTime();
        }
예제 #14
0
 public void SetValues(GameMetrics gameMetrics)
 {
     for (int i = 0; i < 3; i++)
     {
         stars[i].gameObject.SetActive(i < gameMetrics.GetStars());
     }
     score.text = "" + gameMetrics.GetScore();
     scorePercentage = (int)(((gameMetrics.GetScore() + 0f) / (MetricsController.GetController().GetMaxScore() + 0f)) * 100);
     correct.text = "" + gameMetrics.GetRightAnswers();
     incorrect.text = "" + gameMetrics.GetWrongAnswers();
     Invoke("IncrementProgressBar", 0.1f);
     RangeText.text = gameMetrics.GetRange().ToString();
     BonusTimeText.text = "" + gameMetrics.GetBonusTime();
 }
    public static void Reset()
    {
        GameMetrics.Init();

        instance.Init();

        SegmentManager.activeTrack.UnhideObstacles();

        if (instance.m_resultsScreen)
        {
            instance.m_resultsScreen.Deactivate();
        }

        // create a ghost ship
        //	GameObject ghostgo = (GameObject)Instantiate(MenuManager.shipGhostPrefabs[GameMetrics.selectedShip]);
    }
예제 #16
0
 void Start()
 {
     _backEnd = new Backend();
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(instance);
     }
     GameMetrics.Init(_defaultSprite, 4);
     _mapdata = new MapData();
     _model   = new DataModel(_levelGenerator.CreateField(ref _mapdata));
     ReadMapData();
 }
예제 #17
0
        internal GameMetrics GetBestMetric(int level)
        {
            if (metrics[level].Count == 0)
            {
                return(null);
            }
            GameMetrics max = metrics[level][0];

            for (int i = 1; i < metrics[level].Count; i++)
            {
                if (metrics[level][i].GetScore() > max.GetScore())
                {
                    max = metrics[level][i];
                }
            }
            Debug.Log(level + ": max score -> " + max.GetScore());
            return(max);
        }
예제 #18
0
        public void GameStarted()
        {
            Game        currentGame = AppController.GetController().GetAppModel().GetCurrentGame();
            GameMetrics newMetrics  = new GameMetrics(currentGame.GetId());

            currentGameMetrics = SearchMetricsByGame(currentGame.GetId());

            if (currentGameMetrics != null)
            {
                currentGameMetrics.Add(newMetrics);
            }
            else
            {
                currentGameMetrics = new List <GameMetrics> ();
                currentGameMetrics.Add(newMetrics);
                metrics.Add(currentGameMetrics);
            }
        }
예제 #19
0
    // Use this for initialization
    void Start()
    {
        m_totalTime.text = NumberFormat.FloatToString(GameMetrics.totalTime, 2);

        m_maxCombo.text = GameMetrics.maxCombo.ToString();

        m_totalDistance.text = NumberFormat.FloatToString(GameMetrics.totalDistance, 2);

        int new_achievement = GameMetrics.SetAchievement(GameMetrics.selectedTrack, (int)GameMetrics.activeGameMode, GameMetrics.totalDistance);


        AchievementBar achiev_bar = (AchievementBar)GetComponentInChildren(typeof(AchievementBar));

        if (achiev_bar)
        {
            achiev_bar.SetAchievementCount(new_achievement);
        }
    }
    void Init()
    {
        if (Application.isEditor && GameMetrics.activeGameMode == GameMode.None)
        {
            GameMetrics.activeGameMode = GameMode.Speed;
            GameMetrics.selectedTrack  = 1;
        }

        SetGameState(GameState.Loading);

        //instance.m_player = (Player)FindObjectOfType(typeof(Player));
        MusicManager.Init();

        instance.m_player = (Player)GameObject.FindObjectOfType(typeof(Player));
        if (instance.m_player == null)
        {
            print("creating player");
            GameObject playergo = (GameObject)Instantiate(MenuManager.shipPrefabs[GameMetrics.selectedShip]);
            instance.m_player = (Player)playergo.GetComponent(typeof(Player));
        }

        instance.m_player.Init();

        gameMode = GameMetrics.activeGameMode;

        print(gameMode + " " + Application.loadedLevelName);

        GameMetrics.Init();

        ComboSystem.Init();

        //	GhostManager.Init();

        m_endlessModeRemainingLives = m_endlessModeStartingLives;
        m_lapTime     = 0f;
        m_bestLapTime = 1000f;
        m_currentLap  = 0;

        m_firstService = true;

        m_speedModeTimeLeft = m_speedModeTime;

        m_targetTunnelColor = speedLevelData[0].tunnelColor;
    }
//	public GUIText m_topSpeed;

    // Use this for initialization
    void Start()
    {
        m_totalTime.text = NumberFormat.FloatToString(GameMetrics.totalTime, 2);

        m_averageLap.text = NumberFormat.FloatToString(GameMetrics.averageLap, 2);

        m_averageSpeed.text = NumberFormat.FloatToString(GameMetrics.avgSpeed, 2);

        //	m_topSpeed.text = GameMetrics.maxSpeed.ToString();

        int new_achievement = GameMetrics.SetAchievement(GameMetrics.selectedTrack, (int)GameMetrics.activeGameMode, GameMetrics.averageLap);

        AchievementBar achiev_bar = (AchievementBar)GetComponentInChildren(typeof(AchievementBar));

        if (achiev_bar)
        {
            achiev_bar.SetAchievementCount(new_achievement);
        }
    }
예제 #22
0
        private void UpdateRow(GameMetrics gameMetrics, int rowIndex, int activity)
        {
            Game game = AppController.GetController().GetAppModel().GetGameById(gameMetrics.GetGameId());

            raws[rowIndex].setActivity(game.GetName());
            raws [rowIndex].SetIcon(game.GetIcon());

            if (gameMetrics != null)
            {
//				raws[rowIndex].setScore(gameMetrics.GetScore());
                raws[rowIndex].setStars(gameMetrics.GetStars());
                raws[rowIndex].getViewDetailsBtn().enabled = true;
            }
            else
            {
//				raws[rowIndex].setScore(0);
                raws[rowIndex].setStars(0);
                raws[rowIndex].getViewDetailsBtn().enabled = false;
            }
        }
 internal void SetData(GameMetrics playerOneMetrics, GameMetrics playerTwoMetrics, int winner)
 {
     int language = Settings.SettingsController.GetController().GetLanguage();
     if (winner < 1)
     {
         this.winner.text = "";
         this.winnerSentece.text = language == 0 ? "EMPATE" : "DRAW";
     }
     else
     {
         this.winner.text =  (language == 0 ? "JUGADOR " : "PLAYER") + winner;
         this.winnerSentece.text = language == 0 ? "GANADOR" : "WINNER";
     }
     playerOneCorrect.text = "" + playerOneMetrics.GetRightAnswers();
     playerOneWrong.text = "" + playerOneMetrics.GetWrongAnswers();
     playerTwoCorrect.text = "" + playerTwoMetrics.GetRightAnswers();
     playerTwoWrong.text = "" + playerTwoMetrics.GetWrongAnswers();
     this.gameObject.SetActive(true);
     SoundController.GetController().PlayLevelCompleteSound();
 }
예제 #24
0
 // Update is called once per frame
 void Update()
 {
     CalculateMousePosition();
     _worldPosition = Camera.main.ScreenToWorldPoint(_mousePosition);
     _currentIndex  = GameMetrics.VectorToIndex(_worldPosition - _startPoint.position);
     if (_playArea.Contains(new Vector2(_worldPosition.x, _worldPosition.y)))
     {
         if (Input.GetMouseButtonDown(0) && GetCurrentField.HasContent)
         {
             PickUpIngredient(GetCurrentField.Ingredient);
             _currentWorldRepresentation.Lift(true);
         }
         if (Input.GetMouseButton(0) && _currentWorldRepresentation != null)
         {
             _currentWorldRepresentation.Move(_worldPosition);
         }
         else if (_currentIngredient != null)
         {
             ReleaseIngredient();
         }
     }
 }
    public void Init()
    {
        GameMetrics.LoadAchievements();

        int    runs = GameMetrics.GetTotalRuns();
        string num  = runs.ToString();

        if (runs < 100)
        {
            num = "0" + num;
            if (runs < 10)
            {
                num = "0" + num;
            }
        }

        m_trackName.text = "Track " + GameMetrics.selectedTrack + " -- Run " + num;

        ////////
        //records

        m_topSpeedRecord.text  = ((int)GameMetrics.GetRecordSpeed()).ToString();
        m_topSpeedRecord.text += " kph";

        m_fastestLapRecord.text  = NumberFormat.FloatToString(GameMetrics.GetRecordLap(), 2);
        m_fastestLapRecord.text += " s";

        m_distanceRecord.text  = NumberFormat.FloatToString(GameMetrics.GetRecordDistance(), 2);
        m_distanceRecord.text += " km";

        ////////
        ///
        ///

        m_currentTopSpeed = 100;
        m_targetTopSpeed  = ((int)GameMetrics.maxSpeed);
        //	m_targetTopSpeed = 200;
        m_topSpeed.text = "0 kph";

        if (GameMetrics.bestLap < 1000)
        {
            m_fastestLap.text  = NumberFormat.FloatToString(GameMetrics.bestLap, 2);
            m_fastestLap.text += " s";
        }
        else
        {
            m_fastestLap.text = "n/a";
        }

        m_distance.text  = NumberFormat.FloatToString(GameMetrics.totalDistance, 2);
        m_distance.text += " km";

        if (GameMetrics.bestLap < GameMetrics.GetRecordLap())
        {
            m_fastestLapRecord.text           = m_fastestLap.text;
            m_fastestLapRecord.material.color = Color.green;
            m_fastestLap.material.color       = Color.green;
        }
        if (GameMetrics.totalDistance > GameMetrics.GetRecordDistance())
        {
            m_distanceRecord.text           = m_distance.text;
            m_distanceRecord.material.color = Color.green;
            m_distance.material.color       = Color.green;
        }

        GameMetrics.SetSpeedResults();

        m_active = false;

        //	gameObject.SetActiveRecursively(false);
    }
예제 #26
0
 internal void LoadTwoPlayersLevelCompleted(GameMetrics playerOne, GameMetrics playerTwo, int winner)
 {
     ChangeCurrentObject(LoadPrefab("TwoPlayersLevelCompleted"));
     currentGameObject.GetComponent<TwoPlayersLevelCompleted>().SetData(playerOne, playerTwo, winner);
 }
예제 #27
0
 private void CalculateFinalScore(GameMetrics gameMetrics, int minSeconds, int pointsPerSecond, int pointsPerError)
 {
     gameMetrics.SetScore(MAX_SCORE - pointsPerSecond * (gameMetrics.GetLapsedSeconds() < minSeconds ? 0 : gameMetrics.GetLapsedSeconds() - minSeconds) - gameMetrics.GetWrongAnswers() * pointsPerError);
     if (gameMetrics.GetScore() < MIN_SCORE) gameMetrics.SetScore(MIN_SCORE);
 }
예제 #28
0
        private void CalculateFinalScore(GameMetrics gameMetrics, MetricsTable metricsTable)
        {
            for (int i = 0; i < metricsTable.RangeMetricsInfos.Count; i++)
            {
                RangeMetricsInfo currentRangeMetricInfo = metricsTable.RangeMetricsInfos[i];
                if (gameMetrics.GetWrongAnswers() <= currentRangeMetricInfo.MaxErrors &&
                    gameMetrics.GetLapsedSeconds() <= currentRangeMetricInfo.MaxTime)
                {
                    Range range = (Range) (i);
                    float deltaRange = (range.GetDelta() / (currentRangeMetricInfo.MaxErrors - currentRangeMetricInfo.MinErrors + 1));
                    float baseForErrorsQuantity = deltaRange * ( currentRangeMetricInfo.MaxErrors - gameMetrics.GetWrongAnswers());
                    float score = range.GetMinScore() + baseForErrorsQuantity;
                    float bonusFromTime = 0;
                    if (gameMetrics.GetLapsedSeconds() <= currentRangeMetricInfo.MaxTimeToBonus)
                    {
                        float secondsToSubtract = gameMetrics.GetLapsedSeconds() - metricsTable.FreeTime;
                        bonusFromTime = deltaRange;
                        if (secondsToSubtract > 0)
                        {
                            bonusFromTime -= secondsToSubtract*(deltaRange / currentRangeMetricInfo.MaxTimeToBonus);
                        }
                    }
                    score += bonusFromTime;

                    gameMetrics.SetScore(Mathf.RoundToInt(score));
                    gameMetrics.SetBonusTime(Mathf.RoundToInt(bonusFromTime));
                    gameMetrics.SetRange(range);
                    return;
                }
            }

            gameMetrics.SetScore(500);
            gameMetrics.SetBonusTime(0);
            gameMetrics.SetRange(Range.Rookie);
        }
예제 #29
0
 private void CalculeteStars(GameMetrics gameMetrics)
 {
     float percentage = (gameMetrics.GetScore() + 0f) / (MAX_SCORE + 0f);
     gameMetrics.SetStars(percentage > 0.85 ? 3 : percentage > 0.5 ? 2 : 1);
 }
예제 #30
0
        private void groupGames(List<GameMetrics> metrics)
        {
            int gruopSize = (int)Math.Ceiling((metrics.Count + 0.0f) / (MAX_COLUMNS + 0.0f));
            this.note.text = gruopSize + (SettingsController.GetController().GetLanguage() == 0 ? " en " : " in ") + "1";

            for(int i = 0; i < Math.Ceiling((metrics.Count + 0.0f) / (gruopSize + 0.0f)); i++)
            {
                List<GameMetrics> currentGroup = metrics.GetRange(i * gruopSize, (i * gruopSize + gruopSize) <= metrics.Count ? gruopSize : metrics.Count - metricsPoints.Count * gruopSize);
                GameMetrics currentMetric = new GameMetrics(currentGroup[0].GetArea(), currentGroup[0].GetIndex(), currentGroup[0].GetLevel());
                currentMetric.SetDate(currentGroup[0].GetDate());
                for(int j = 0; j < currentGroup.Count; j++)
                {
                    currentMetric.SetScore(currentMetric.GetScore() + currentGroup[j].GetScore());
                    currentMetric.SetLapsedSeconds(currentMetric.GetLapsedSeconds() + currentGroup[j].GetLapsedSeconds());
                    currentMetric.SetRightAnswers(currentMetric.GetRightAnswers() + currentGroup[j].GetRightAnswers());
                    currentMetric.SetWrongAnswers(currentMetric.GetWrongAnswers() + currentGroup[j].GetWrongAnswers());
                }
                currentMetric.SetScore(Average(currentMetric.GetScore(), currentGroup.Count));
                currentMetric.SetLapsedSeconds(Average(currentMetric.GetLapsedSeconds(), currentGroup.Count));
                currentMetric.SetRightAnswers(Average(currentMetric.GetRightAnswers(), currentGroup.Count));
                currentMetric.SetWrongAnswers(Average(currentMetric.GetWrongAnswers(), currentGroup.Count));

                metricsPoints.Add(currentMetric);
            }
        }
예제 #31
0
 private void SaveMetric(GameMetrics currentMetric)
 {
     for (int i = 0; i < metrics.Count; i++)
     {
         if(metrics[i].GetGameId() == currentMetric.GetIndex())
         {
             metrics[i].GetMetrics()[currentMetric.GetLevel()].Add(currentMetric);
             break;
         }
     }
 }
    // Update is called once per frame
    void Update()
    {
        int a = GameMetrics.GetAchievement(GameMetrics.selectedTrack, (int)GameMetrics.activeGameMode);

        SetAchievementCount(a);
    }
예제 #33
0
 internal void GameStarted()
 {
     AppController appController = AppController.GetController();
     Game currentGame = appController.GetCurrentGame();
     currentMetric = new GameMetrics(appController.GetCurrentArea(), currentGame.GetId(), appController.GetCurrentLevel(), currentGame.GetExercisesBySubLevel());
 }
예제 #34
0
 public void EndGameTwoPlayers(GameMetrics playerOne, GameMetrics playerTwo, int winner)
 {
     ViewController.GetController().LoadTwoPlayersLevelCompleted(playerOne, playerTwo, winner);
 }
예제 #35
0
 private void IncrementMetric(string i_metric)
 {
     GameMetrics.IncrementMetric(i_metric);
 }