Exemple #1
0
    // Use this for initialization
    void Start()
    {
        if (em == null)
        {
            em = this.gameObject.GetComponent <EnemyManager>();
        }

        red              = enemyRed.GetComponent <RedEnemy> ();
        blue             = enemyBlue.GetComponent <BlueEnemy> ();
        pink             = enemyPink.GetComponent <PinkEnemy> ();
        orange           = enemyOrange.GetComponent <OrangeEnemy> ();
        playercontroller = player.GetComponent <PlayerController> ();
        red.activate();
        //Set the basic mode into 3, going around
        setMode3();
    }
Exemple #2
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.GetComponent <RedBullet>() || other.CompareTag("Player"))
        {
            return;
        }

        OnHitParticleSystem();

        if (other.GetComponent <RedEnemy>())
        {
            RedEnemy target = other.GetComponent <RedEnemy>();
            target.TakeDamage(damage, this);
        }

        Destroy(gameObject);
    }
Exemple #3
0
    private void Spawn()
    {
        List <Door> freeWindow = GetFreeWindows();

        if (freeWindow.Count == 0)
        {
            Debug.Log("NO WINDOWS FOUND!");
            return;
        }

        int ran = Random.Range(0, freeWindow.Count);

        freeWindow[ran].isFree = false;

        RedEnemy redEnemy = ObjectPool.instance.GetRedEnemy();

        redEnemy.Attack(freeWindow[ran]);
    }
Exemple #4
0
    public void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("RedEnemy"))
        {
            RedEnemy enemy = other.GetComponentInParent <RedEnemy>();
            enemy.TakeDamage(DamageQuantity(other), "explosion");
        }
        if (other.CompareTag("BlueEnemy"))
        {
            BlueEnemy enemy = other.GetComponentInParent <BlueEnemy>();
            enemy.TakeDamage(DamageQuantity(other), "explosion");
        }
        if (other.CompareTag("Player"))
        {
            PlayerHealth player = other.GetComponentInParent <PlayerHealth>();
            player.TakeDamage(DamageQuantity(other));
        }

        PushBack(other);
        ExplosionEnd();
    }
Exemple #5
0
    IEnumerator SpawnEnemies()
    {
        while (true)
        {
            Enemy newEnemy;

            if (Random.Range(0, 2) == 0)
            {
                newEnemy = new BlueEnemy(enemyGameObject);
            }
            else
            {
                newEnemy = new RedEnemy(enemyGameObject);
            }

            newEnemy.gameObject.transform.position = new Vector3(32f, -4f, 0f);
            instantiatedEnemies.Add(newEnemy);

            yield return(new WaitForSeconds(2f));
        }
    }
Exemple #6
0
    private void generateEnemiesFuelOrCrystal(int[][] lvl, int current, float posx, float posy, float diffx)
    {
        //1.85f longest item size
        int   propability = 3; //propability of generate item
        float x, y;
        int   r, c;
        int   diff1, diff2, diff;
        float x1, x2;

        x = 3;
        y = posy;
        if (!(random.Next(1, propability + 1) == propability))
        {
            if (lvl[current][1] == 0)
            {
                if (current < lvl.Length - 1)
                {
                    diff1 = lvl[current + 1][0] - lvl[current][0];
                }
                else
                {
                    diff1 = 0;
                }
                diff2 = lvl[current - 1][0] - lvl[current][0];
                diff  = Math.Max(diff1, diff2);
                if (diff > 1)
                {
                    x1 = posx - diffx * ((scale / 2) - lvl[current][0]) + (1.85f * diff);
                    x2 = posx + diffx * ((scale / 2) - lvl[current][0]) - (1.85f * diff);
                }
                else
                {
                    x1 = posx - diffx * ((scale / 2) - lvl[current][0]) + (1.85f / 2);
                    x2 = posx + diffx * ((scale / 2) - lvl[current][0]) - (1.85f / 2);
                }
                x = (float)random.NextDouble() * (x2 - x1) + x1;
            }
            else
            {
                if (current < lvl.Length - 1)
                {
                    diff1 = lvl[current + 1][1] - lvl[current][1];
                }
                else
                {
                    diff1 = 0 - lvl[current][1];
                }
                diff2 = lvl[current - 1][1] - lvl[current][1];
                diff  = Math.Max(diff1, diff2);
                if (diff >= 1)
                {
                    if (diff > 3)
                    {
                        if (random.Next(0, 2) == 0)
                        {
                            x = posx - diffx * ((scale / 2) - lvl[current][0]) + 1.85f;
                        }
                        else
                        {
                            x = posx + diffx * ((scale / 2) - lvl[current][0]) - 1.85f;
                        }
                    }
                    else
                    {
                        if (random.Next(0, 2) == 0)
                        {
                            x = posx - ((diffx * lvl[current][1]) / 2.0f) - (diff * 2 * (1.85f / 3));
                        }
                        else
                        {
                            x = posx + ((diffx * lvl[current][1]) / 2.0f) + (diff * 2 * (1.85f / 3));
                        }
                    }
                }
                else
                {
                    if (random.Next(0, 2) == 0)
                    {
                        x = posx - ((diffx * lvl[current][1]) / 2.0f) - (1.85f / 2);
                    }
                    else
                    {
                        x = posx + ((diffx * lvl[current][1]) / 2.0f) + (1.85f / 2);
                    }
                }
            }

            //chose what type of item should be spawned
            r = random.Next(0, 115);
            c = propabilityArray[r];
            //statement for preventing generating tanks in tight corridors
            if (lvl[current][1] >= 9 && c == 0)
            {
                do
                {
                    r = random.Next(0, 115);
                    c = propabilityArray[r];
                } while (c == 0);
            }
            switch (c)
            {
            case (0):
            {
                Tank tank = new Tank(90 + (MainScript.Player.Level * 10), x, y, -100);
                break;
            }

            case (1):
            {
                RedEnemy redEnemy = new RedEnemy(90 + (MainScript.Player.Level * 10), x, y, 175);
                break;
            }

            case (2):
            {
                int rSide = random.Next(-1, 2);
                if (rSide == 0)
                {
                    rSide = -1;
                }
                SpacePlane spacePlane = new SpacePlane(90 + (MainScript.Player.Level * 10), 13.5f * rSide, y, 500 * rSide * -1);
                break;
            }

            case (3):
            {
                FuelTank fueltank = new FuelTank(x, y);
                break;
            }

            case (4):
            {
                Crystal crystal = new Crystal(x, y);
                break;
            }
            }
        }
    }