Example #1
0
    // Method when enemy got hit
    public void addDamage(float damage, TowerType tower)
    {
        // to indicate hitting, damage must be more than 0
        if (damage > 0)
        {
            hitTime = 0f;
            if (property.type == EnemyType.ARMORED && tower != TowerType.SNIPER)
            {
                damage *= 0.25f;
            }
            currHealth -= damage;
            isHit       = true;
        }

        // if enemy got shocked
        if (tower == TowerType.ELECTRIC)
        {
            shockTimer = property.shockRecovery;
        }

        // if it dies just put it to the pooler
        if (currHealth <= 0f || status == EnemyStatus.FROZEN)
        {
            GameObject          moneyAddObj = Instantiate(moneyAdd);
            MoneyAddedBehaviour money       = moneyAddObj.GetComponent <MoneyAddedBehaviour>();
            money.activatePlus((int)property.rewardPrice, position);
            pooler.insertBack(this);
            GameManager.instance.addMoney(property.rewardPrice);
        }

        conditionChanged = true;
    }
Example #2
0
    // Check if the answer is correct or not then change the question text to tell player if its right or wrong, and update the gameManager
    public void checkAnswer(Answer answer)
    {
        generatorClick.StartCoroutine(generatorClick.openGenerator());
        if (answer.isRightAnswer)
        {
            // if its not practice ignore the total answered question
            if (!GameManager.instance.isPractice)
            {
                GameManager.instance.totalAnsweredQuestion++;
                GameManager.instance.scoreboard.consecutiveAnswer++;
            }

            // if Player answer maxCharged amount of answers
            if (GameManager.instance.totalAnsweredQuestion >= GameManager.instance.maxCharged)
            {
                kotoTowerClick.StartCoroutine(kotoTowerClick.closeKotoTower());
                questionText.text = "MENANG!!!";
                GameEvents.current.GameWonEnter();
            }
            else
            {
                GameManager.instance.isChangedDifficulty = true;
                GameObject          moneyAddObj    = Instantiate(moneyAdd);
                MoneyAddedBehaviour moneyAddBehave = moneyAddObj.GetComponent <MoneyAddedBehaviour>();
                moneyAddBehave.activatePlus((int)(20 * GameManager.instance.totalAnsweredQuestion), this.gameObject.transform.position);
                GameManager.instance.money       += 20 * GameManager.instance.totalAnsweredQuestion;
                GameManager.instance.moneyChanged = true;
                questionText.text = "JAWABAN BENAR!!!";
                isStartTiming     = true; // start the timer
            }
        }
        else
        {
            GameManager.instance.scoreboard.consecutiveAnswer = 0;
            questionText.text = "JAWABAN SALAH!!!";
            isStartTiming     = true; // start the timer
            GameManager.instance.isChangedEnemyGroupSize = true;
        }

        // Tell question manager that the truck has arrived and charged the generator
        kotoTowerClick.StartCoroutine(kotoTowerClick.closeKotoTower());
    }