Exemplo n.º 1
0
    protected override void CreateLevel()
    {
        MusicPlay("sounds/level1Loop");

        levelSize = new Vector2(80, 60); //set the level size

        CreateObject("SpaceDustPF", gameBounds.center, 0);

        IngameInterface.DisplayMessage("Survive the attack of the Space Blobs!", 3);

        for (int i = 0; i < 4; i++)
        {
            Blob current = (Blob)CreateObject("BlobPF", GetRandomPosition(), GetRandomAngle(), GetRandomVelocity(10));
            current.velocity = GetRandomVelocity(current.maxSpeed);
        }

        for (int i = 0; i < 1; i++)
        {
            GravityWell current = (GravityWell)CreateObject("GravityWellPF", GetRandomPosition(), GetRandomAngle());
            current.velocity = GetRandomVelocity(current.maxSpeed);
        }

        for (int i = 0; i < 2; i++)
        {
            SlowTurner current = (SlowTurner)CreateObject("SlowTurnerPF", GetRandomPosition(), GetRandomAngle());
            current.velocity = GetRandomVelocity(current.maxSpeed);
        }

        for (int i = 0; i < 2; i++)
        {
            RandomTurner current = (RandomTurner)CreateObject("RandomTurnerPF", GetRandomPosition(), GetRandomAngle());
            current.velocity = GetRandomVelocity(current.maxSpeed);
        }

        for (int i = 0; i < 2; i++)
        {
            SputteringDebris current = (SputteringDebris)CreateObject("SputteringDebrisPF", GetRandomPosition(), GetRandomAngle());
            current.velocity = GetRandomVelocity(current.maxSpeed);
        }

        for (int i = 0; i < 2; i++)
        {
            RotatingLazerSentry current = (RotatingLazerSentry)CreateObject("RotatingLazerSentryPF", GetRandomPosition(), GetRandomAngle());
            current.velocity = GetRandomVelocity(current.maxSpeed);
        }

        for (int i = 0; i < 1; i++)
        {
            LazerEmitter current = (LazerEmitter)CreateObject("LazerEmitterPF", GetRandomPosition(), GetRandomAngle());
            current.velocity = GetRandomVelocity(current.maxSpeed);
        }

        for (int i = 0; i < 2; i++)
        {
            IndestructableDebris current = (IndestructableDebris)CreateObject("IndestructableDebrisPF", GetRandomPosition(), GetRandomAngle());
            current.velocity = GetRandomVelocity(current.maxSpeed);
        }

        LazerBeam beam = (LazerBeam)CreateObject("LazerBeamPF");
    }
Exemplo n.º 2
0
 public void Update()
 {
     if (Input.GetMouseButtonDown(0) && gameObject.GetComponent <Player_Controler>().getCharge() != 0.0)
     {
         gameObject.GetComponent <Player_Controler>().subtractCharge(cost);
         PowerUp_Controler pc = (PowerUp_Controler)gameObject.GetComponent("PowerUp_Controler");
         if (pc.getMode() == 1)              // fire
         {
             LazerBeam.CreateLazerBeam(fireLocation.position, fireLocation.rotation, Color.red, gameObject);
             LazerBeam.CreateLazerBeam(fireLocation2.position, fireLocation2.rotation, Color.red, gameObject);
             // TODO remove extra charge in the player_conroler
         }
         else if (pc.getMode() == 2)                // water
         {
             LazerBeam.CreateLazerBeam(fireLocation.position, fireLocation.rotation, Color.blue, gameObject);
         }
         else if (pc.getMode() == 3)                // earth
         {
             LazerBeam.CreateLazerBeam(fireLocation.position, fireLocation.rotation, Color.gray, gameObject);
         }
         else if (pc.getMode() == 4)                // air
         {
             LazerBeam.CreateLazerBeam(fireLocation.position, fireLocation.rotation, Color.cyan, gameObject);
         }
         else if (pc.getMode() == 5)                // lightning
         {
             LazerBeam.CreateLazerBeam(fireLocation.position, fireLocation.rotation, Color.yellow, gameObject);
         }
         else                 // default
         {
             LazerBeam.CreateLazerBeam(fireLocation.position, fireLocation.rotation, Color.green, gameObject);
         }
     }
 }
Exemplo n.º 3
0
    void Update()
    {
        if (timePassed <= 0.0f)
        {
            timePassed = 1.0f;
            LazerBeam.CreateLazerBeam(transform.position, transform.rotation, myColor, gameObject);
        }

        timePassed -= Time.deltaTime;
    }
Exemplo n.º 4
0
    /**
     * Creates a new LazerBeam with the given position, rotation, color and owner
     * @param position - Lazer starting position
     * @param rotation - Lazer starting rotation
     * @param color - Color of Lazer Beam
     * @param ownerRoot - Owner of lazer (cannot hit self, teammate (if enabled), own base (if enabled), etc
     */
    public static GameObject CreateLazerBeam(Vector3 position, Quaternion rotation, Color color, GameObject ownerRoot)
    {
        // Create a new "Lazer"
        GameObject beam = GameObject.CreatePrimitive(PrimitiveType.Capsule);

        beam.name = "Lazer-Beam (" + beam.GetInstanceID() + ")";
        beam.tag  = TAG_NAME;

        // Set the transform data
        beam.transform.position   = position;
        beam.transform.rotation   = rotation;
        beam.transform.localScale = LAZER_OBJECT_SCALE;

        // Add the selfIllumin shader and given color
        Shader selfIllumin = Shader.Find("Self-Illumin/Diffuse");

        if (selfIllumin != null)
        {
            beam.renderer.material.shader = selfIllumin;
            beam.renderer.material.color  = color;
        }

        // Set the collider to a trigger
        if (beam.collider != null)
        {
            beam.collider.isTrigger = true;
        }

        // Add the Lazer script (this script) and set owner
        LazerBeam script = beam.AddComponent <LazerBeam>();

        if (script != null)
        {
            script.ownerRoot = ownerRoot;
        }

        // Add a rigidbody with no gravity and add a velocity for the speed.
        // A Rigidbody is required for the OnTriggerEnter messages to be called.
        // If the Lazer was not a rigidbody AND the beam it another non-rigidbody,
        // the OnTriggerEnter message is NOT called!
        Rigidbody body = beam.AddComponent <Rigidbody>();

        if (body != null)
        {
            body.velocity               = beam.transform.up * BEAM_SPEED;
            body.useGravity             = false;
            body.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
        }

        SoundUtils.playSound(ownerRoot, ownerRoot.GetComponent <Player_Controler>().fireSound, 1.0f);

        return(beam);
    }
Exemplo n.º 5
0
 public void FireLazer(Vector3 pos, Quaternion rot, Vector3 color, NetworkMessageInfo info)
 {
     LazerBeam.CreateLazerBeam(pos, rot, new Color(color.x, color.y, color.z, 1.0f), info.networkView.gameObject);
 }
Exemplo n.º 6
0
    private const int WAVE_TIME_SECS         = 60; //60 seconds between waves

    protected override void UpdateLevel()
    {
        waveTimer--;

        //determine if there are any enemies left in the level
        bool noEnemies = true;

        foreach (DestructableObject item in destructables)
        {
            if (item.team <= 0)
            {
                noEnemies = false;
                break;
            }
        }

        //if it is time for the next wave or there are not more enemies, go to the next wave
        if (waveTimer <= 0 || noEnemies)
        {
            //reset waveTimer
            waveTimer = (int)(WAVE_TIME_SECS * updatesPerSec);

            //update wave numbers
            type++;
            if (type > NUM_TYPES)
            {
                type = 1;
                round++;
            }

            //find which type of enemies to spawn, then spawn a number equal to the round
            //bascially, each type is gone through one at a time then it is started at the
            //begining again but this time, waves make one more of that type than last time
            //each type also gives the user a different item, each round the item given gets stronger
            //a message is dispayed to the user when each wave is spawned, telling them abou the wave
            switch (type)
            {
            case 1:
                IngameInterface.DisplayMessage("Wave " + (type * (round - 1) + type) + ", " + round + " Suttering Debris and a "
                                               + round + " power Heal item.", WAVE_MESSAGE_TIME);
                for (int i = 0; i < round; i++)
                {
                    SputteringDebris current = (SputteringDebris)CreateObject("SputteringDebrisPF", GetRandomGameEdge(), GetRandomAngle());
                    current.velocity = GetRandomVelocity((int)current.maxSpeed);
                }
                Heal heal = (Heal)CreateObject("HealPF");
                heal.healthPerSecGain *= round * ITEM_POWER_INCRIMENT;
                break;

            case 2:
                IngameInterface.DisplayMessage("Wave " + (type * (round - 1) + type) + ", " + round + " Aseroid(s) and a "
                                               + round + " power MultiShot item.", WAVE_MESSAGE_TIME);
                for (int i = 0; i < round; i++)
                {
                    Asteroid current = (Asteroid)CreateObject("AsteroidPF", GetRandomGameEdge(), GetRandomAngle(), 0, random.Next(100));
                    current.velocity = GetRandomVelocity((int)current.maxSpeed);
                }
                MultiShots multiShot = (MultiShots)CreateObject("MultiShotPF");
                multiShot.numberOfShots *= round * ITEM_POWER_INCRIMENT;
                break;

            case 3:
                IngameInterface.DisplayMessage("Wave " + (type * (round - 1) + type) + ", " + round + " Lazer Emitters(s) and a "
                                               + round + " power Lazer Sword item.", WAVE_MESSAGE_TIME);
                for (int i = 0; i < round; i++)
                {
                    LazerEmitter current = (LazerEmitter)CreateObject("LazerEmitterPF", GetRandomGameEdge(), GetRandomAngle(), 0, random.Next(100));
                    current.velocity = GetRandomVelocity((int)current.maxSpeed);
                }
                LazerSword sword = (LazerSword)CreateObject("LazerSwordPF");
                sword.swordLength *= round * ITEM_POWER_INCRIMENT;
                break;

            case 4:
                IngameInterface.DisplayMessage("Wave " + (type * (round - 1) + type) + ", " + round + " Random Turner(s) and a "
                                               + round + " power Homing Missiles item.", WAVE_MESSAGE_TIME);
                for (int i = 0; i < round; i++)
                {
                    RandomTurner current = (RandomTurner)CreateObject("RandomTurnerPF", GetRandomGameEdge(), GetRandomAngle());
                    current.velocity = GetRandomVelocity((int)current.maxSpeed);
                }
                HomingMissiles homing = (HomingMissiles)CreateObject("HomingMissilesPF");
                homing.missileDamge *= round * ITEM_POWER_INCRIMENT;
                break;

            case 5:
                IngameInterface.DisplayMessage("Wave " + (type * (round - 1) + type) + ", " + round + " Mine Layer(s) and a "
                                               + round + " power Gravity Well Controller item.", WAVE_MESSAGE_TIME);
                for (int i = 0; i < round; i++)
                {
                    MineLayer current = (MineLayer)CreateObject("MineLayerPF", GetRandomGameEdge(), GetRandomAngle());
                    current.velocity = GetRandomVelocity((int)current.maxSpeed);
                }
                GravityWellController well = (GravityWellController)CreateObject("GravityWellControllerPF");
                well.maxGravity *= round * ITEM_POWER_INCRIMENT;
                break;

            case 6:
                IngameInterface.DisplayMessage("Wave " + (type * (round - 1) + type) + ", " + round + " Rotating Lazer Sentry(s) and a "
                                               + round + " power Lazer Beam item.", WAVE_MESSAGE_TIME);
                for (int i = 0; i < round; i++)
                {
                    RotatingLazerSentry current = (RotatingLazerSentry)CreateObject("RotatingLazerSentryPF", GetRandomGameEdge(), GetRandomAngle());
                    current.velocity = GetRandomVelocity((int)current.maxSpeed);
                }
                LazerBeam beam = (LazerBeam)CreateObject("LazerBeamPF");
                beam.beamDamge = (beam.beamDamge - 1) * round * ITEM_POWER_INCRIMENT + 1;
                break;

            case 7:
                IngameInterface.DisplayMessage("Wave " + (type * (round - 1) + type) + ", " + round + " Green Blob(s) and a "
                                               + round + " power Rapid Shots item.", WAVE_MESSAGE_TIME);
                for (int i = 0; i < round; i++)
                {
                    GreenBlob current = (GreenBlob)CreateObject("GreenBlobPF", GetRandomGameEdge(), GetRandomAngle());
                    current.velocity = GetRandomVelocity((int)current.maxSpeed);
                }
                RapidShots rapid = (RapidShots)CreateObject("RapidShotsPF");
                rapid.shotDamage *= round * ITEM_POWER_INCRIMENT;
                break;

            case 8:
                IngameInterface.DisplayMessage("Wave " + (type * (round - 1) + type) + ", " + round + " Red Blob(s) and a "
                                               + round + " power Armor item.", WAVE_MESSAGE_TIME);
                for (int i = 0; i < round; i++)
                {
                    RedBlob current = (RedBlob)CreateObject("RedBlobPF", GetRandomGameEdge(), GetRandomAngle());
                    current.velocity = GetRandomVelocity((int)current.maxSpeed);
                }
                Armor armor = (Armor)CreateObject("ArmorPF");
                armor.armorGain *= round * ITEM_POWER_INCRIMENT;
                break;

            case 9:
                IngameInterface.DisplayMessage("Wave " + (type * (round - 1) + type) + ", " + round + " Blue Blob(s) and a "
                                               + round + " power Charged Shot item.", WAVE_MESSAGE_TIME);
                for (int i = 0; i < round; i++)
                {
                    BlueBlob current = (BlueBlob)CreateObject("BlueBlobPF", GetRandomGameEdge(), GetRandomAngle());
                    current.velocity = GetRandomVelocity((int)current.maxSpeed);
                }
                ChargedShots charged = (ChargedShots)CreateObject("ChargedShotPF");
                charged.shotMaxDamage *= round * ITEM_POWER_INCRIMENT;
                break;

            case 10:
                IngameInterface.DisplayMessage("Wave " + (type * (round - 1) + type) + ", " + round + " Slow Turner(s) and a "
                                               + round + " power Homing Mines item.", WAVE_MESSAGE_TIME);
                for (int i = 0; i < round; i++)
                {
                    SlowTurner current = (SlowTurner)CreateObject("SlowTurnerPF", GetRandomGameEdge(), GetRandomAngle());
                    current.velocity = GetRandomVelocity((int)current.maxSpeed);
                }
                HomingMines mines = (HomingMines)CreateObject("HomingMinesPF");
                mines.maxMines     = (int)(round * ITEM_POWER_INCRIMENT * mines.maxMines);
                mines.layTimeSecs *= round * ITEM_POWER_INCRIMENT;
                break;

            case 11:
                IngameInterface.DisplayMessage("Wave " + (type * (round - 1) + type) + ", " + round + " Rammer(s) and a "
                                               + round + " power Accelerant item.", WAVE_MESSAGE_TIME);
                for (int i = 0; i < round; i++)
                {
                    Rammer current = (Rammer)CreateObject("RammerPF", GetRandomGameEdge(), GetRandomAngle());
                    current.velocity = GetRandomVelocity((int)current.maxSpeed);
                }
                Accelerant accelerant = (Accelerant)CreateObject("AccelerantFP");
                accelerant.accelerationPerSecGain *= round * ITEM_POWER_INCRIMENT;
                break;

            case 12:
                IngameInterface.DisplayMessage("Wave " + (type * (round - 1) + type) + ", " + round + " LazerShooter(s) and a "
                                               + round + " power Shield item.", WAVE_MESSAGE_TIME);
                for (int i = 0; i < round; i++)
                {
                    LazerShooter current = (LazerShooter)CreateObject("LazerShooterPF", GetRandomGameEdge(), GetRandomAngle());
                    current.velocity = GetRandomVelocity((int)current.maxSpeed);
                }
                Shield shield = (Shield)CreateObject("ShieldPF");
                shield.shieldWidth *= round * ITEM_POWER_INCRIMENT / 2.0f;
                break;

            default:
                if (type > 12)
                {
                    round++;
                }
                type      = 0;
                waveTimer = 0;
                Debug.Log("Veraible 'type' has an invalid value of: " + type);
                break;
            }
        }
    }