コード例 #1
0
    void OnTriggerEnter(Collider col)
    {
        if (col.gameObject.tag == "Enemy" || col.gameObject.tag == "Enemy2" || col.gameObject.tag == "Pathway")
        {
            mortarshell_model.SetActive(false);
            m_render.enabled     = true;
            exploding            = true;
            rb.isKinematic       = true;
            rendr.material.color = explosion_color;

            if (col.gameObject.tag == "Enemy")
            {
                enemy_script = col.GetComponent <enemy>();
                enemy_script.ReceiveDamage(damage);
            }

            else if (col.gameObject.tag == "Enemy2")
            {
                enemy_script2 = col.GetComponent <enemy2>();
                enemy_script2.ReceiveDamage(damage);
            }

            else
            {
                //add fix here if necessary
            }
        }
    }
コード例 #2
0
    IEnumerator SpawnWave(int waveIndex)
    {
        currentWave = waves[waveIndex];

        for (int i = 0; i < currentWave.count; i++)
        {
            if (player == null)
            {
                yield break;
            }
            enemy2    randomEnemy      = currentWave.enemies[Random.Range(0, currentWave.enemies.Length)];
            Transform randomSpawnPoint = spawnPoints[Random.Range(0, spawnPoints.Length)];
            Instantiate(randomEnemy, randomSpawnPoint.position, transform.rotation);

            if (i == currentWave.count - 1)
            {
                spawningFinished = true;
            }
            else
            {
                spawningFinished = false;
            }

            yield return(new WaitForSeconds(currentWave.timeBetweenSpawns));
        }
    }
コード例 #3
0
    void OnTriggerEnter(Collider col)
    {
        if (col.gameObject.tag == "Enemy")
        {
            enemy_script = col.GetComponent <enemy>();
            if (!enemy_script.frozen)
            {
                enemy_script.Freeze(duration);

                durability--;
                if (durability <= 0)
                {
                    Destroy(this.gameObject);
                }
            }
        }

        if (col.gameObject.tag == "Enemy2")
        {
            enemy_script2 = col.GetComponent <enemy2>();
            if (!enemy_script2.frozen)
            {
                enemy_script2.Freeze(duration);

                durability--;
                if (durability <= 0)
                {
                    Destroy(this.gameObject);
                }
            }
        }
    }
コード例 #4
0
ファイル: wavespawner.cs プロジェクト: jamest209/ShinobiBlitz
    void SpawnEnemy2(GameObject enemy2)
    {
        GameObject spawned_enemy2 = Instantiate(enemy2, spawn_point2.position, spawn_point2.rotation);

        enemy2_scr = spawned_enemy2.GetComponent <enemy2>();
        enemy2_scr.IncreaseHealth(wave_number);
    }
コード例 #5
0
    void OnTriggerEnter(Collider col)
    {
        //Destroy(col.gameObject);
        if (col != null)
        {
            if (col.gameObject.tag == "Enemy")
            {
                GameObject effect = (GameObject)Instantiate(damage_effect, transform.position, transform.rotation);
                Destroy(effect, 1f);
                enemy_script = col.GetComponent <enemy>();
                enemy_script.ReceiveDamage(damage);
                Destroy(gameObject);
            }

            if (col.gameObject.tag == "Enemy2")
            {
                GameObject effect = (GameObject)Instantiate(damage_effect, transform.position, transform.rotation);
                Destroy(effect, 1f);
                enemy_script2 = col.GetComponent <enemy2>();
                enemy_script2.ReceiveDamage(damage);
                Destroy(gameObject);
            }

            else
            {
                Destroy(gameObject);
            }
        }
    }
コード例 #6
0
ファイル: enemy2.cs プロジェクト: VUHAILAM/Dekaranger
//    public Sprite imgNoEnemy;

    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
    }
コード例 #7
0
ファイル: SpikeTrap.cs プロジェクト: jamest209/ShinobiBlitz
    void OnTriggerEnter(Collider col)
    {
        if (col.gameObject.tag == "Enemy")
        {
            GameObject effect = (GameObject)Instantiate(damage_effect, transform.position, transform.rotation);
            Destroy(effect, 1f);


            enemy_script = col.GetComponent<enemy>();
            enemy_script.ReceiveDamage(damage);

            durability--;
            if(durability <= 0)
            {
                Destroy(this.gameObject);
            }
        }

        if (col.gameObject.tag == "Enemy2")
        {
            GameObject effect = (GameObject)Instantiate(damage_effect, transform.position, transform.rotation);
            Destroy(effect, 1f);


            enemy_script2 = col.GetComponent<enemy2>();
            enemy_script2.ReceiveDamage(damage);

            durability--;
            if (durability <= 0)
            {
                Destroy(this.gameObject);
            }
        }
    }
コード例 #8
0
 // Use this for initialization
 void Start()
 {
     en  = FindObjectOfType <enemy>();
     en1 = FindObjectOfType <enemy1>();
     en2 = FindObjectOfType <enemy2>();
     bos = FindObjectOfType <Boss>();
 }
コード例 #9
0
ファイル: OilTrap.cs プロジェクト: jamest209/ShinobiBlitz
    void OnTriggerEnter(Collider col)
    {
        if (col.gameObject.tag == "Enemy")
        {
            enemy_script = col.GetComponent <enemy>();
            enemy_script.SlowDown();

            durability--;
            if (durability <= 0)
            {
                Destroy(this.gameObject);
            }
        }

        if (col.gameObject.tag == "Enemy2")
        {
            enemy_script2 = col.GetComponent <enemy2>();
            enemy_script2.SlowDown();

            durability--;
            if (durability <= 0)
            {
                Destroy(this.gameObject);
            }
        }
    }
コード例 #10
0
ファイル: LookAt.cs プロジェクト: jamest209/ShinobiBlitz
 // Use this for initialization
 void Start()
 {
     if (transform.parent.gameObject.tag == "Enemy")
     {
         enemy_scr = transform.parent.GetComponent <enemy>();
     }
     else
     {
         enemy2_scr = transform.parent.GetComponent <enemy2>();
     }
 }
コード例 #11
0
    // Start is called before the first frame update
    void Start()
    {
        Instance = this;
        speed    = 25;

        rb = GetComponent <Rigidbody2D>();

        spriteRenderer = GetComponent <SpriteRenderer>();

        rb.velocity = Vector2.left * speed;

        StartCoroutine(spawnBullet());
    }
コード例 #12
0
    public void ReactToHit()
    {
        WanderingAI behavior  = GetComponent <WanderingAI>();
        enemy2      behavior2 = GetComponent <enemy2>();

        _animator = this.GetComponent <Animator> ();
        if (behavior != null)
        {
            behavior.SetAlive(false);
            StartCoroutine(Die());
        }
        else if (behavior2 != null)
        {
            behavior2.SetAlive(false);
            StartCoroutine(Die());
        }
    }
コード例 #13
0
    void OnTriggerEnter(Collider other)
    {
        PlayerCharacter player = other.GetComponent <PlayerCharacter>();

        if (player != null)
        {
            //	print("hit");
            player.Hurt(damage);
        }

        enemy2      zombie  = other.GetComponent <enemy2>();
        boss        boss    = other.GetComponent <boss>();
        WanderingAI reptile = other.GetComponent <WanderingAI>();

        if (zombie != null)
        {
            ReactiveTarget target = zombie.GetComponent <ReactiveTarget>();
            print("child found");

            zombie.transform.Find("blood").gameObject.active = true;

            // the code here is called
            // for each child named Bone


            target.ReactToHit();
        }
        else if (reptile != null)
        {
            print("reptile hit");
            ReactiveTarget target = reptile.GetComponent <ReactiveTarget>();
            target.ReactToHit();
        }
        else if (boss != null)
        {
            boss.hurt(10);
        }

        Destroy(this.gameObject);
    }
コード例 #14
0
    void OnTriggerEnter(Collider col)
    {
        if (col.gameObject.tag == "Enemy")
        {
            GameObject effect = (GameObject)Instantiate(damage_effect, transform.position, transform.rotation);
            Destroy(effect, 1f);
            enemy_script = col.GetComponent <enemy>();
            if (enemy_script.slowed)
            {
                damage += damage_bonus;
                enemy_script.ReceiveDamage(damage);
                damage -= damage_bonus;
            }
            else
            {
                enemy_script.ReceiveDamage(damage);
            }
            enemy_script.GetBurned();
        }

        if (col.gameObject.tag == "Enemy2")
        {
            GameObject effect = (GameObject)Instantiate(damage_effect, transform.position, transform.rotation);
            Destroy(effect, 1f);
            enemy_script2 = col.GetComponent <enemy2>();
            if (enemy_script2.slowed)
            {
                damage += damage_bonus;
                enemy_script2.ReceiveDamage(damage);
                damage -= damage_bonus;
            }
            else
            {
                enemy_script2.ReceiveDamage(damage);
            }
            enemy_script2.GetBurned();
        }
    }
コード例 #15
0
ファイル: Cannonball.cs プロジェクト: jamest209/ShinobiBlitz
    void OnTriggerEnter(Collider col)
    {
        if (col != null)
        {
            if (col.gameObject.tag == "Enemy")
            {
                enemy_script = col.GetComponent <enemy>();
                enemy_script.ReceiveDamage(damage);
                exploding            = true;
                rb.isKinematic       = true;
                rendr.material.color = explosion_color;
            }

            if (col.gameObject.tag == "Enemy2")
            {
                enemy_script2 = col.GetComponent <enemy2>();
                enemy_script2.ReceiveDamage(damage);
                exploding            = true;
                rb.isKinematic       = true;
                rendr.material.color = explosion_color;
            }
        }
    }