Ejemplo n.º 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();
        }
    }
Ejemplo n.º 2
0
    private void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {
            Destroy(gameObject);
        }

        DontDestroyOnLoad(gameObject);
    }
Ejemplo n.º 3
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);
     }
 }
Ejemplo n.º 4
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);
    }
Ejemplo n.º 5
0
    public EmotionMenager(GameManager gameManager)
    {
        Satisfaction = 0.5;

        this.gameManager = gameManager;

        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {
            Destroy(gameObject);
        }

        // DontDestroyOnLoad(gameObject);
    }
Ejemplo n.º 6
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());
    }
Ejemplo n.º 7
0
    void Start()
    {
        emotionMenager = new EmotionMenager(this);

        Debug.Log(boardCamera);
        Debug.Log(battleCamera);

        boardCamera.SetActive(true);
        battleCamera.SetActive(false);


        //Assign enemies to a new List of Enemy objects.
        enemies = new List <Enemy>();

        //Get a component reference to the attached BoardManager script
        boardScript = GetComponent <BoardManager>();

        //Call the InitGame function to initialize the first level
        InitGame();
    }
Ejemplo n.º 8
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!";
        }
    }