示例#1
0
    public void TypeLetter(char letter)
    {
        ActiveWord.TypeLetter(letter);

        if (ActiveWord.IsWordTyped())
        {
            Debug.Log("Player attack");

            playerInBattle.GetComponent <PlayerInBattle>().attack(enemy);

            enemyHealth.text = enemy.GetComponent <EnemyInBattle>().health + "/" + maxEnemyHealth;

            if (enemy.GetComponent <EnemyInBattle>().health <= 0)
            {
                //Invoke the Restart function to start the next level with a delay of restartLevelDelay (default 1 second).
                Debug.Log("!!!!!!!!!!!!!!!!!!!!!!!!!!!! VICTORY");
                Text foodText = GameObject.FindGameObjectWithTag("FoodText").GetComponent <Text>();
                headline.text = "Victory!";
                Invoke("Exit", exitDelay);
            }
            else
            {
                WordLevel wordLevel = EmotionMenager.GetInstance().WordLevelDifficulty();
                ActiveWord = new WordToType(WordsRepository.GetRandomWord(wordLevel), WordSpawner.SpawnWord());
            }
            // GameManager.instance.loadMainScene();
        }
    }
示例#2
0
 public void TypeLetter(char letter)
 {
     if (_word[_index] == letter)
     {
         _index++;
         EmotionMenager.GetInstance().HandleEvent(EmotionEventType.TYPE_CORRECT_SIGN);
         _wordDisplay.RemoveLetter();
         GameManager.instance.typedKeys += 1;
     }
     else
     {
         EmotionMenager.GetInstance().HandleEvent(EmotionEventType.MISSPELL);
     }
 }
示例#3
0
    // Update is called once per frame
    void Update()
    {
        foreach (var letter in Input.inputString)
        {
            BattleManager.TypeLetter(letter);
        }
        GameManager.instance.milisec += DateTime.Now.Subtract(timeStart).Milliseconds;
        milisec  += DateTime.Now.Subtract(timeStart).Milliseconds;
        timeStart = DateTime.Now;
        double kps = GameManager.instance.typedKeys / (GameManager.instance.milisec / 60000); // 60 sekun * 1000 milisekund = 1 min

        GameManager.instance.meanKPM = kps;
        EmotionMenager.GetInstance().SatisfactionFromKPS(kps);
        //Debug.Log("mili " + GameManager.instance.milisec);
        //Debug.Log("KPS " + kps);
    }
示例#4
0
    //Update is called every frame.
    void Update()
    {
        if (isBattle)
        {
            EmotionMenager.GetInstance().HandleEvent(EmotionEventType.TIME_ELAPSED);
        }

        if ((int)(Input.GetAxisRaw("Cancel")) == 1)
        {
            exitToMenu();
        }
        //Check that playersTurn or enemiesMoving or doingSetup are not currently true.
        if (playersTurn || enemiesMoving || doingSetup)
        {
            return;
        }

        StartCoroutine(MoveEnemies());
    }
示例#5
0
    // Use this for initialization when manager is enabled with "setActive"
    void OnEnable()
    {
        Debug.Log("OnEnabled BattleManager");

        // Prevent to init on very first start of the game
        if (GameManager.instance != null && GameManager.instance.isBattle)
        {
            WordsRepository = XmlManager.Deserialize <WordsRepository>();
            WordLevel wordLevel = EmotionMenager.GetInstance().WordLevelDifficulty();
            ActiveWord = new WordToType(WordsRepository.GetRandomWord(wordLevel), WordSpawner.SpawnWord());

            // get random enemy from prefabs
            Debug.Log("Init enemy:");
            EnemyType enemyType = getEnemyType();
            Debug.Log(enemyType);
            if (enemyType.Equals(EnemyType.Wolf))
            {
                Debug.Log("Loading Wolf.");
                enemy = Instantiate(Resources.Load("Prefabs/WolfBattle", typeof(GameObject)), enemyPosition.position, Quaternion.identity) as GameObject;
            }
            else if (enemyType.Equals(EnemyType.Zombie))
            {
                Debug.Log("Loading Zombie.");
                enemy = Instantiate(Resources.Load("Prefabs/Zombie1Battle", typeof(GameObject)), enemyPosition.position, Quaternion.identity) as GameObject;
            }
            Debug.Log(enemy);
            // enemy.transform.parent = enemyPosition;
            //set up player&enemy health text
            Debug.Log("Player health: ");
            Debug.Log(playerInBattle.GetComponent <PlayerInBattle>().health);
            Debug.Log("Enemy health: ");
            Debug.Log(enemy.GetComponent <EnemyInBattle>().health);
            maxEnemyHealth    = enemy.GetComponent <EnemyInBattle>().health;
            playerHealth.text = playerInBattle.GetComponent <PlayerInBattle>().health + "/" + Player.maxHealth;
            enemyHealth.text  = enemy.GetComponent <EnemyInBattle>().health + "/" + enemy.GetComponent <EnemyInBattle>().health;
            headline.text     = "Fight!";
        }
    }