Beispiel #1
0
    // initialize event
    private void Start()
    {
        // get all needed component
        kotoTower = GameObject.FindGameObjectWithTag("Koto Tower").GetComponent <KotoTowerBehaviour>();

        generatorButton = this.gameObject.transform.GetChild(0).gameObject;
        kotoTowerButton = this.gameObject.transform.GetChild(1).gameObject;

        if (!GameManager.instance.isTutorial)
        {
            showKotoTower = false;
        }
        else
        {
            showKotoTower = true;
        }

        showGenerator = true;
        showtruck     = false;
        isChanges     = true;

        GameEvents.current.onGeneratorOffScreenEnter += GeneratorOffScreen;
        GameEvents.current.onGeneratorOnScreenEnter  += GeneratorOnScreen;
        GameEvents.current.onKotoTowerOffScreenEnter += KotoTowerOffScreen;
        GameEvents.current.onKotoTowerOnScreenEnter  += KotoTowerOnScreen;
    }
Beispiel #2
0
    // attack kotoTower
    void attackKotoTower()
    {
        if (attackTimer < property.hitRate && status == EnemyStatus.ATTACKING)
        {
            attackTimer += Time.deltaTime;
        }

        if (status != EnemyStatus.ATTACKING && status == EnemyStatus.MOVING)
        {
            status    = EnemyStatus.ATTACKING;
            kotoTower = GameObject.FindGameObjectWithTag("Koto Tower").GetComponent <KotoTowerBehaviour>();
        }
        else if (attackTimer >= property.hitRate)
        {
            if (kotoTower == null)
            {
                kotoTower = GameObject.FindGameObjectWithTag("Koto Tower").GetComponent <KotoTowerBehaviour>();
            }

            kotoTower.addDamage(property.damage);
            attackTimer = 0f;
        }
    }