void Start()
    {
        levelData         = Data.Instance.levels.GetCurrentLevelData();
        Events.StartGame += StartGame;

        Tutorials.panels panel = Tutorials.panels.RUN;
        int distance           = levelData.enemies.distance;

        if (levelData.enemies.VERTICAL_BAR.Length > 0)
        {
            panel = Tutorials.panels.WALLS;
        }
        if (levelData.enemies.TRAMPOLIN)
        {
            panel = Tutorials.panels.TRAMPOLIN;
        }
        if (levelData.enemies.HURDLES)
        {
            panel = Tutorials.panels.HURDLES;
        }
        if (levelData.enemies.WIND)
        {
            panel = Tutorials.panels.MUD;
        }

        Events.OnTutorialOn(panel);
    }
Exemplo n.º 2
0
    void Start()
    {
        print("start summary");

        levelData = Data.Instance.levelData;

        System.TimeSpan t = System.TimeSpan.FromSeconds(levelData.time);

        string timerFormatted = string.Format("{0:00}:{1:00}.{2:000}", t.Minutes, t.Seconds, t.Milliseconds);

        Levels.LevelData CurrentlevelData = Data.Instance.levels.GetCurrentLevelData();

        float score = 0;

        if (CurrentlevelData.totalLaps > 0)
        {
            title_txt.text   = "TIME";
            results_txt.text = timerFormatted + "SEC";
            score            = levelData.time;
        }
        else if (CurrentlevelData.totalTime > 0)
        {
            title_txt.text   = "DISTANCE";
            results_txt.text = levelData.laps.ToString() + " MTS";
            score            = levelData.laps;
        }
        int currentLevel = Data.Instance.levels.currentLevel;

        Events.OnSaveScore(currentLevel, score);
    }
    public void Init(Challenges challenges, int _id, Challenges.PlayerData playerData)
    {
        RemindButton.SetActive(false);
        this.playerData = playerData;
        this.challenges = challenges;
        this.id         = _id;

        if (challenges.type == Challenges.types.MADE)
        {
            InactiveButtons();
            RemindButton.SetActive(true);
        }


        if (playerData.winner != "")
        {
            if (playerData.winner == Data.Instance.userData.facebookID)
            {
                result.text  = "YOU WON";
                result.color = WinColor;
            }
            else
            {
                result.text  = "YOU LOST";
                result.color = lostColor;
            }
            InactiveButtons();
        }
        this.objectID   = playerData.objectID;
        this.facebookID = playerData.facebookID;

        username           = Data.Instance.gameSettings.GetUsername(playerData.playerName);
        usernameLabel.text = username;


        levelId    = playerData.level;
        level.text = "LEVEL " + levelId;

        string score = Data.Instance.levelsData.GetScoreString(playerData.level, playerData.score);

        Levels.LevelData data = Data.Instance.levels.GetData(levelId);

        if (data.Sudden_Death)
        {
            scoreLabel.text = score;
        }
        else
        if (data.totalTime > 0)
        {
            scoreLabel.text = score + " in " + Data.Instance.levelsData.GetTimer(data.totalTime);
        }
        else
        {
            scoreLabel.text = data.totalLaps + "000" + "m in " + score;
        }

        op_score = playerData.score;
        profilePicture.setPicture(facebookID);
        infoLoaded = true;
    }
Exemplo n.º 4
0
    void Start()
    {
        id           = Data.Instance.levelData.winnerID;
        player.color = Data.Instance.colors[id - 1];

        MultiplayerData multiData = Data.Instance.multiplayerData;

        string username = "";

        switch (id)
        {
        case 1: username = multiData.playerName1; break;

        case 2: username = multiData.playerName2; break;

        case 3: username = multiData.playerName3; break;

        case 4: username = multiData.playerName4; break;
        }

        usernameLabel.text = username;

        usernameLabel.text = Data.Instance.multiplayerData.GetPlayer(id).username;

        LevelData levelData = Data.Instance.levelData;

        System.TimeSpan t = System.TimeSpan.FromSeconds(levelData.time);

        string timerFormatted = string.Format("{0:00}:{1:00}.{2:000}", t.Minutes, t.Seconds, t.Milliseconds);

        Levels.LevelData CurrentlevelData = Data.Instance.levels.GetCurrentLevelData();

        float score = 0;

        if (CurrentlevelData.totalLaps > 0)
        {
            score = levelData.time;
        }
        else if (CurrentlevelData.totalTime > 0)
        {
            score = levelData.laps;
        }

        Events.OnSaveScore(Data.Instance.levels.currentLevel, score);
    }
    void Start()
    {
        levelData = Data.Instance.levelData;

        System.TimeSpan t = System.TimeSpan.FromSeconds(levelData.time);

        string timerFormatted = string.Format("{0:00}:{1:00}.{2:000}", t.Minutes, t.Seconds, t.Milliseconds);

        Levels.LevelData CurrentlevelData = Data.Instance.levels.GetCurrentLevelData();

        float score = 0;

        if (CurrentlevelData.totalLaps > 0)
        {
            title_txt.text   = "TIME";
            results_txt.text = timerFormatted;
            score            = levelData.time;
        }
        else if (CurrentlevelData.totalTime > 0)
        {
            title_txt.text   = "LAPS";
            results_txt.text = levelData.laps.ToString();
            score            = levelData.laps;
        }

        int currentLevel = Data.Instance.levels.currentLevel;


        if (Data.Instance.levelData.challenge_objectID != "")
        {
            CloseChallenge(currentLevel, score);
        }
        else if (Data.Instance.levelData.challenge_username != "")
        {
            SendChallenge(currentLevel, score);
        }
    }
Exemplo n.º 6
0
    void OnAvatarDie(Player _player)
    {
        int playersDead = 0;

        foreach (Player player in players)
        {
            if (player.state == Player.states.DEAD)
            {
                playersDead++;
            }
        }
        if (playersDead == players.Count)
        {
            Levels.LevelData levelData = Data.Instance.levels.GetCurrentLevelData();
            if (levelData.Sudden_Death && chronometer.timer < levelData.gameOver)
            {
                Events.GameOver(false);
            }
            else
            {
                LevelComplete();
            }
        }
    }
Exemplo n.º 7
0
    public void Open(int levelId)
    {
        panel.transform.localScale = Data.Instance.screenManager.scale;

        if (Data.Instance.userData.mode == UserData.modes.SINGLEPLAYER)
        {
            ranking.LoadSinglePlayerWinners(levelId);

            if (FB.IsLoggedIn)
            {
                Logout.SetActive(false);
            }
            else
            {
                Logout.SetActive(true);
            }

            singlePanel.SetActive(true);
            multiPanel.SetActive(false);
        }
        else
        {
            ranking.LoadMultiplayerWinners(levelId);

            singlePanel.SetActive(false);
            multiPanel.SetActive(true);
            Logout.SetActive(false);
        }

        Events.OnSoundFX("buttonPress");
        this.levelId = levelId;
        isActive     = true;
        panel.SetActive(true);
        panel.GetComponent <Animation>().Play("PopupOn");
        field.text = "LEVEL " + levelId;

        float _myScore = PlayerPrefs.GetFloat("Run_Level_" + levelId);

        starsInLevel = 0;

        if (_myScore == 0)
        {
            stars.Reset();
        }
        else
        {
            starsInLevel = Data.Instance.levels.GetCurrentLevelStarsByScore(levelId, _myScore);
            stars.Init(starsInLevel);
        }

        string _score = Data.Instance.levelsData.GetScoreString(levelId, _myScore);

        if (Data.Instance.userData.mode == UserData.modes.SINGLEPLAYER)
        {
            subTitle.text = "MY BEST: " + _score;
        }
        else
        {
            subTitle.text = "";
        }

        Levels.LevelData levelData = Data.Instance.levels.levels[levelId];

        if (starsInLevel < 1)
        {
            challengesButtonDisable.SetActive(true);
            challengesButton.interactable = false;
        }
        else
        {
            challengesButton.interactable = true;
            challengesButtonDisable.SetActive(false);
        }


        if (levelData.Sudden_Death)
        {
            goalText.text = "SUDDEN DEATH!";
        }
        else if (levelData.totalLaps > 0)
        {
            goalText.text = (levelData.totalLaps * 1000).ToString() + "m";
        }
        else
        {
            goalText.text = (levelData.totalTime).ToString() + " SECONDS";
        }
    }
Exemplo n.º 8
0
    void Start()
    {
        Events.OnMusicChange("crowds");

        Levels.LevelData levelData = Data.Instance.GetComponent <Levels>().GetCurrentLevelData();
        targetSpeed  = levelData.speed;
        acceleration = levelData.acceleration;

        totalPlayers = 1;
        if (ForceMultiplayer || Data.Instance.userData.mode == UserData.modes.MULTIPLAYER)
        {
            totalPlayers = Data.Instance.multiplayerData.players.Count;
        }

        LaneSeparation = Data.Instance.gameSettings.LaneSeparation;

        float offsetY = (totalPlayers - 1) * (LaneSeparation / 2);

        for (int a = 0; a < totalPlayers; a++)
        {
            int id = 1;

            if (ForceMultiplayer || Data.Instance.userData.mode == UserData.modes.MULTIPLAYER)
            {
                id = Data.Instance.multiplayerData.players[a].playerID;
            }

            GameObject newContainer = Instantiate(container) as GameObject;
            newContainer.GetComponent <GameCamera>().id = a + 1;
            newContainer.GetComponent <GameCamera>()._y = a * -LaneSeparation;
            containers.Add(newContainer);
            newContainer.transform.SetParent(gameCanvas.transform);
            Vector3 pos = new Vector3(0, offsetY, 0);
            newContainer.transform.localPosition = pos;
            newContainer.transform.localScale    = Vector3.one;

            Lane newLane = Instantiate(lane) as Lane;
            newLane.transform.SetParent(newContainer.transform);
            lanes.Add(newLane);
            newLane.GetComponent <Transform>().localPosition = new Vector2(0, a * -LaneSeparation);
            newLane.Init(newContainer.GetComponent <GameCamera>());


            Player newPlayer = Instantiate(player) as Player;
            newPlayer.SetColor(Data.Instance.colors[id - 1]);
            newPlayer.transform.SetParent(newContainer.transform);
            players.Add(newPlayer);
            newPlayer.GetComponent <Transform>().localPosition = new Vector2(-18f, a * -LaneSeparation);
            newPlayer.id = id;
            newPlayer.Init(newContainer.GetComponent <GameCamera>());
        }

        //scaleFactor = containers[0].GetComponentInParent<Canvas>().scaleFactor;
        Events.StartGame      += StartGame;
        Events.OnAvatarDie    += OnAvatarDie;
        Events.OnAvatarWinLap += OnAvatarWinLap;
        Events.OnTimeOver     += OnTimeOver;
        Events.GameOver       += GameOver;

        LaneSeparation /= scaleFactor;

        if (!ForceMultiplayer)
        {
            Invoke("OnPowerUp", Random.Range(8, 12));
        }
    }