Exemple #1
0
    void Update()
    {
        GameObject go = GameObject.FindGameObjectWithTag("Player");

        ally_targeting at = (ally_targeting)go.GetComponent("ally_targeting");

        Enemy_health_tracking eh = (Enemy_health_tracking)GetComponent("Enemy_health_tracking");

        if (timeSinceLastSpawn == 0)         //New time
        {
            timeSinceLastSpawn = Time.time;  //Set the current time
        }
        else
        {
            if (curEnemys.Count < maxNumberOfEnemys && (int)(Time.time - timeSinceLastSpawn) >= spawnDelay)
            {
                Instantiate(enemyToSpawn, spawnPlace, Quaternion.identity);
                at.targets = new List <Transform>();
                curEnemys  = new List <Transform>();
                AddAllEnemy();
                at.AddAllEnemy();
                timeSinceLastSpawn = 0;
            }
        }

        if (eh.curHealth == 0)
        {
            curEnemys = new List <Transform>();
            AddAllEnemy();
        }

        //Debug.Log((int)(Time.time - timeSinceLastSpawn));
    }
Exemple #2
0
    // Update is called once per frame
    void Update()
    {
        if (timer > 0)
        {
            timer -= Time.deltaTime;
        }
        if (timer < 0)
        {
            timer = 0;
        }

        if (Input.GetKeyDown(KeyCode.F))
        {
            if (timer == 0)
            {
                Attack();
                timer = coolDown;
            }
        }
        if (target == null)
        {
            ally_targeting al = (ally_targeting)GetComponent("ally_targeting");

            al.targets = new System.Collections.Generic.List <UnityEngine.Transform>();

            al.AddAllEnemy();
        }
    }