예제 #1
0
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(this.gameObject);
        }


        scoreText = GetComponent <Text>();

        mapKey = SceneManager.GetActiveScene().name + "Highscore";

        if (Debug.isDebugBuild)
        {
            WipeHighscore();
        }

        highscore = PlayerPrefs.GetInt(mapKey);

        Debug.Log("Highscore: " + highscore);

        audioSource = GetComponent <AudioSource>();
    }
예제 #2
0
/// -----------------------------------------------------------------------------------------------
/// Private methods -------------------------------------------------------------------------------

    // Initialize game variables
    private void InitVars()
    {
        _ic         = GameObject.Find("Input").GetComponent <InputController>();
        _cc         = GameObject.Find("ComboBonus").GetComponent <ComboController>();
        _mc         = GameObject.Find("MultGauge").GetComponent <MultiplierController>();
        _sc         = GameObject.Find("ScoreText").GetComponent <ScoreTextController>();
        GameCanvas  = GameObject.Find("Canvas").transform;
        _numPatText = GameObject.Find("NumPatterns").GetComponent <Text>();
        _inputs     = new List <int>();
        _pattern    = new List <int>();

        // Game config
        _maxTime    = 15f;
        _prevTimer  = _timer = _maxTime - 5f;
        _timeTaken  = 0.2f;
        _multScores = new [] { 0, 1500, 8000, 16000, 26000, 42000, 50000, 60000, 75000, 100000 }; // Needs 10 length

        // Init stats
        _score           = 0;
        _numPatterns     = 0;
        _flawlessPattern = true;

        // Init UI
        _mc.SetMultiplier();

        // Start game
        _active = true;
    }
예제 #3
0
 private void AddScores()
 {
     scores.Sort();
     for (int i = 0; i < scores.Count; i++)
     {
         GameObject s = Instantiate(score);
         s.transform.SetParent(content.transform);
         ScoreTextController text = s.GetComponent <ScoreTextController>();
         text.number = (i + 1).ToString();
         text.name   = scores[i].name;
         text.score  = scores[i].roundsSurvived.ToString();
         content.GetComponent <RectTransform>().sizeDelta = new Vector2(content.GetComponent <RectTransform>().sizeDelta.x, 100 * (i + 1));
     }
 }
예제 #4
0
    void SetInstances()
    {
        panelObject         = (GameObject)Resources.Load("Panel");
        panelField          = GameObject.Find("PanelField").GetComponent <PanelFieldController>();
        panelDeleteParticle = (GameObject)Resources.Load("PanelDeleteParticle");

        questionText = GameObject.Find("QuestionText").GetComponent <TextController>();
        answerText   = GameObject.Find("AnswerText").GetComponent <TextController>();
        scoreText    = GameObject.Find("ScoreText").GetComponent <ScoreTextController>();
        levelText    = GameObject.Find("LevelText").GetComponent <TextController>();

        scrollUpButton = GameObject.Find("ScrollUpButton").GetComponent <ScrollUpButtonController>();
        mainBackground = GameObject.Find("MainBackground").GetComponent <MainBackgroundController>();

        audioSource = GetComponent <AudioSource>();
    }
예제 #5
0
    public GameController(
        GameStateChangedSignal gameStateChangedSignal,
        StateFactory stateFactory,
        GiveScorepointsSignal giveScorepointsSignal,
        GameEndedSignal gameEndedSignal,
        ScoreTextController scoreText,
        EndGameTextController endGameText,
        ScoreboardDataController scoreboardDataController)
    {
        _gameStateChangedSignal = gameStateChangedSignal;
        _stateFactory           = stateFactory;
        _endGameText            = endGameText;
        _scoreText = scoreText;
        _scoreboardDataController = scoreboardDataController;

        giveScorepointsSignal += OnGainedScorepoints;
        gameEndedSignal       += OnGameEnded;
    }
예제 #6
0
    private IEnumerator AttackFront()
    {
        if (_isRobotAtFront)
        {
            PassivateRobot();
            //additemdrop
            DropRandomItem();
            _score += 20;
            ScoreTextController.UpdateScoreText(_score);
        }

        PlayerAnimator.SetBool("IsAttacked1", true);
        yield return(new WaitForSeconds(0.2f));

        PlayerAnimator.SetBool("IsAttacked1", false);
        yield return(new WaitForSeconds(0.8f));

        _isAvailableToAttack = true;
    }
 void SetInstances()
 {
     masterData          = GameObject.Find("MasterData").GetComponent <MasterData>();
     titleTextController = GameObject.Find("TitleText").GetComponent <TitleTextController>();
     scoreTextController = GameObject.Find("ScoreText").GetComponent <ScoreTextController>();
 }
예제 #8
0
    void Update()
    {
        if (_isPlayerActive)
        {
            //Debug.Log(Input.inputString);
            if (transform.position.z > PlaneList[_positionIndex].ZPosition + 10)
            {
                PlaneList[_positionIndex].ZPosition += 50;
                Vector3 newPosition = new Vector3(0, 0, PlaneList[_positionIndex].ZPosition);
                PlaneList[_positionIndex].ThisGameObject.transform.position = newPosition;
                _positionIndex++;
                _passedPlaneCountModded++;
                _positionIndex = _positionIndex % (GlobalPlaneNumber);
                _score        += 10; //10 points for griffindor
                ScoreTextController.UpdateScoreText(_score);
            }

            if (_passedPlaneCountModded >= PlaneCountToIncreaseSpeed)
            {
                IncreaseSpeed();
                EnemySpawnIntervalBegin *= 5f / 8f;
                EnemySpawnIntervalEnd   *= 5f / 8f;
            }


            if (_newEnemyCanSpawn)
            {
                _newEnemyCanSpawn = false;
                //Debug.Log(EnemySpawnIntervalBegin);

                float randomTimeToSpawn = UnityEngine.Random.Range(EnemySpawnIntervalBegin, EnemySpawnIntervalEnd);
                StartCoroutine(SpawnEnemy(randomTimeToSpawn));
            }


#if UNITY_EDITOR
            if ((Input.GetKeyDown(KeyCode.LeftArrow) || Input.GetKeyDown(KeyCode.A)) && _isAvailableToChangeDirection)
            {
                StartCoroutine(MoveLeft());
            }

            if ((Input.GetKeyDown(KeyCode.RightArrow) || Input.GetKeyDown(KeyCode.D)) && _isAvailableToChangeDirection)
            {
                StartCoroutine(MoveRight());
            }
            if (Input.GetKeyDown(KeyCode.R))
            {
                RestartGame();
            }

            if ((Input.GetMouseButtonDown(0) && _isAvailableToAttack))
            {
                _isAvailableToAttack = false;
                StartCoroutine(AttackFront());
            }
#else
            ScreenSwipeManager.DetectSwipe();
            if (ScreenSwipeManager.swipeDirection == Swipe.Left)
            {
                // do something...
                StartCoroutine(MoveLeft());
            }

            if (ScreenSwipeManager.swipeDirection == Swipe.Right)
            {
                // do something...
                StartCoroutine(MoveRight());
            }

            if (ScreenSwipeManager.swipeDirection == Swipe.Tap && _isAvailableToAttack)
            {
                // do something...
                _isAvailableToAttack = false;
                StartCoroutine(AttackFront());
            }
#endif



            if (_score >= _highScore)
            {
                _highScore = _score;
                HighScoreTextController.UpdateHighScoreText(_highScore);
            }

            MovePlayer();
        }

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            RestartPanelController.ToggleStaticPanel();
        }
    }
예제 #9
0
 // Start is called before the first frame update
 void Awake()
 {
     scoreTextController    = GetComponentInChildren <ScoreTextController>();
     usernameTextController = GetComponentInChildren <UsernameTextController>();
 }
예제 #10
0
 private void Start()
 {
     scoreTextController = GameObject.Find("ScoreText").GetComponent <ScoreTextController>();
 }