Exemple #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;
    }
Exemple #2
0
    // activate means start shooting
    public void activate()
    {
        GameObject          moneyAddObj    = Instantiate(moneyAdd);
        MoneyAddedBehaviour moneyAddBehave = moneyAddObj.GetComponent <MoneyAddedBehaviour>();

        hasTarget       = false;
        shootTimer      = property.fireRate;
        currentPosition = this.transform.position;
        isActive        = true;
        circle.SetActive(false);
        totalFire = 5;
        moneyAddBehave.activateMinus((int)GameManager.instance.getPrice(property.type), currentPosition);
    }
    //activate
    public void activate()
    {
        if (property.type == TrapType.TIME_TRAP)
        {
            audioSource.Play();
        }

        GameObject          moneyAddObj    = Instantiate(moneyAdd);
        MoneyAddedBehaviour moneyAddBehave = moneyAddObj.GetComponent <MoneyAddedBehaviour>();

        currentPosition = this.gameObject.transform.position;
        isActive        = true;
        moneyAddBehave.activateMinus((int)GameManager.instance.getPrice(property.type), currentPosition);
    }
Exemple #4
0
    //despawn the tower and give back the money
    public void despawn()
    {
        GameObject          moneyAddObj    = Instantiate(moneyAdd);
        MoneyAddedBehaviour moneyAddBehave = moneyAddObj.GetComponent <MoneyAddedBehaviour>();

        moneyAddBehave.activateRefund((int)(GameManager.instance.getRefundMoney(selectedTower.getTowerType())), selectedTower.transform.position);
        TowerGridBlocker blocker = selectedTower.gameObject.GetComponent <TowerGridBlocker>();

        blocker.removeGridStatus();
        GameManager.instance.refund(selectedTower.getTowerType());
        Destroy(selectedTower.gameObject);
        GameEvents.current.TowerUnselected();
        GameManager.instance.currentStatus = GameStatus.PLAY;
        OnTowerUnselected();
    }
Exemple #5
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());
    }