Example #1
0
    protected override void UpdateDestructableObject()
    {
        //remove HomingMine entries of HomingMines that no longer exist
        List <HomingMine> remove = new List <HomingMine>();

        foreach (HomingMine item in mines)
        {
            if (item == null || !item.active)
            {
                remove.Add(item);
            }
        }
        foreach (HomingMine item in remove)
        {
            mines.Remove(item);
        }

        if (layMineTimer > 0)
        {
            layMineTimer--;
        }

        //lay a new mine if it is time to
        if (layMineTimer <= 0)
        {
            //reset the layMineTimer
            layMineTimer = (int)(mineLayWaitSecs * level.updatesPerSec);

            //destroy and remove the first mine if there are too many
            if (mines.Count >= maxMines * difficultyModifier)
            {
                HomingMine firstMine = mines.First.Value;
                firstMine.DestroyThis();
                mines.Remove(firstMine);
            }

            //create a new mine behind this
            HomingMine mine = (HomingMine)level.CreateObject("HomingMinePF", offset.Rotate(angle) + position, 0, 0);

            mine.damage = damage;
            mine.team   = team;

            mines.AddLast(mine);
        }

        //turn and move away from the closest enemy InteractiveObject if it is too close, or just move forward
        SpaceObject turnFrom = ClosestObject(level.GetTypes(true, true, true, false), false);

        if (turnFrom != null && DistanceFrom(turnFrom) < stayAwayDistance)
        {
            TurnTowards(turnFrom, -turnSpeed);
        }

        MoveForward(acceleration);
    }
Example #2
0
    protected override void HoldingItem(bool use, bool startUse, bool endUse, bool doubleUse)
    {
        //Find and remove from the list any mines that no longer exist
        List <HomingMine> remove = new List <HomingMine>();

        foreach (HomingMine item in mines)
        {
            if (item == null || !item.active)
            {
                remove.Add(item);
            }
        }
        foreach (HomingMine item in remove)
        {
            mines.Remove(item);
        }

        //update the time before the next mine can be layed
        if (layTimer > 0)
        {
            layTimer--;
        }
        //if it is time to lay a mine and the holder is pressing this Item's key,
        //then create a new mine behind the holder
        else if (use)
        {
            //create a mine behind the holder
            Vector2 direction = holder.velocity.normalized;
            direction.x *= -1;
            HomingMine mine = (HomingMine)level.CreateObject("HomingMinePF", holder.position + offset.Rotate(direction.GetAngle()));

            //set mine initial settings
            mine.acceleration = mineAcceleration;
            mine.damage       = mineDamage;
            mine.health       = mineHealth;
            mine.maxSpeed     = mineMaxSpeed;
            mine.color        = color;
            mine.team         = holder.team;

            //if there are too many mines, destroy the oldest
            if (mines.Count >= maxMines)
            {
                mines.Last.Value.DestroyThis();
                mines.RemoveLast();
            }

            mines.AddFirst(mine);

            //reset timer to lay next mine
            layTimer = (int)(layTimeSecs * level.updatesPerSec);

            level.score += USE_POINTS;
        }
    }
Example #3
0
    protected override void CreateLevel()
    {
        MusicPlay("sounds/level1Loop");

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

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

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

        for (int i = 0; i < 2; i++)
        {
            HomingMine current = (HomingMine)CreateObject("HomingMinePF", GetRandomPosition(), GetRandomAngle());
        }

        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++)
        {
            MineLayer current = (MineLayer)CreateObject("MineLayerPF", GetRandomPosition(), GetRandomAngle());
            current.velocity = GetRandomVelocity(current.maxSpeed);
        }

        for (int i = 0; i < 2; i++)
        {
            RubberyDebris current = (RubberyDebris)CreateObject("RubberyDebrisPF", 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 < 1; i++)
        {
            IndestructableDebris current = (IndestructableDebris)CreateObject("IndestructableDebrisPF", GetRandomPosition(), GetRandomAngle());
            current.velocity = GetRandomVelocity(current.maxSpeed);
        }

        GravityWellController well = (GravityWellController)CreateObject("GravityWellControllerPF");
    }
Example #4
0
    protected override void UpdateLevel()
    {
        remaining = 0;

        foreach (DestructableObject item in destructables)
        {
            if (item.team <= 0)
            {
                remaining++;
            }
        }

        spawnTimer--;

        if (spawnTimer <= 0)
        {
            spawnTimer = (int)(spawnTimeSecs * updatesPerSec);

            wave++;
            switch (wave)
            {
            case 1:
                IngameInterface.DisplayMessage("Wave 1", MESSAGE_SECS);
                for (int i = 0; i < 1; i++)
                {
                    SlowTurner current = (SlowTurner)CreateObject("SlowTurnerPF", GetRandomGameEdge(), GetRandomAngle());
                    current.velocity = GetRandomVelocity(current.maxSpeed);
                }

                for (int i = 0; i < 1; i++)
                {
                    LazerShooter current = (LazerShooter)CreateObject("LazerShooterPF", GetRandomGameEdge(), GetRandomAngle());
                    current.velocity = GetRandomVelocity(current.maxSpeed);
                }

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

                for (int i = 0; i < 1; i++)
                {
                    MineLayer current = (MineLayer)CreateObject("MineLayerPF", GetRandomGameEdge(), GetRandomAngle());
                    current.velocity = GetRandomVelocity(current.maxSpeed);
                }
                for (int i = 0; i < 2; i++)
                {
                    Asteroid current = (Asteroid)CreateObject("AsteroidPF", GetRandomGameEdge(), GetRandomAngle());
                    current.velocity = GetRandomVelocity(current.maxSpeed);
                }
                for (int i = 0; i < 1; i++)
                {
                    RotatingLazerSentry current = (RotatingLazerSentry)CreateObject("RotatingLazerSentryPF", GetRandomGameEdge(), GetRandomAngle());
                    current.velocity = GetRandomVelocity(current.maxSpeed);
                }

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

            case 2:
                IngameInterface.DisplayMessage("Wave 2", MESSAGE_SECS);
                for (int i = 0; i < 1; i++)
                {
                    SlowTurner current = (SlowTurner)CreateObject("SlowTurnerPF", GetRandomGameEdge(), GetRandomAngle());
                    current.velocity = GetRandomVelocity(current.maxSpeed);
                }

                for (int i = 0; i < 1; i++)
                {
                    LazerShooter current = (LazerShooter)CreateObject("LazerShooterPF", GetRandomGameEdge(), GetRandomAngle());
                    current.velocity = GetRandomVelocity(current.maxSpeed);
                }

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

                for (int i = 0; i < 1; i++)
                {
                    MineLayer current = (MineLayer)CreateObject("MineLayerPF", GetRandomGameEdge(), GetRandomAngle());
                    current.velocity = GetRandomVelocity(current.maxSpeed);
                }
                for (int i = 0; i < 2; i++)
                {
                    Asteroid current = (Asteroid)CreateObject("AsteroidPF", GetRandomGameEdge(), GetRandomAngle());
                    current.velocity = GetRandomVelocity(current.maxSpeed);
                }

                for (int i = 0; i < 1; i++)
                {
                    HomingMine current = (HomingMine)CreateObject("HomingMinePF", GetRandomGameEdge(), GetRandomAngle());
                    current.velocity = GetRandomVelocity(current.maxSpeed);
                }
                for (int i = 0; i < 1; i++)
                {
                    RotatingLazerSentry current = (RotatingLazerSentry)CreateObject("RotatingLazerSentryPF", GetRandomGameEdge(), GetRandomAngle());
                    current.velocity = GetRandomVelocity(current.maxSpeed);
                }
                break;

            case 3:
                IngameInterface.DisplayMessage("Wave 3", MESSAGE_SECS);
                for (int i = 0; i < 1; i++)
                {
                    MineLayer current = (MineLayer)CreateObject("MineLayerPF", GetRandomGameEdge(), GetRandomAngle());
                    current.velocity = GetRandomVelocity(current.maxSpeed);
                }
                for (int i = 0; i < 2; i++)
                {
                    Asteroid current = (Asteroid)CreateObject("AsteroidPF", GetRandomGameEdge(), GetRandomAngle());
                    current.velocity = GetRandomVelocity(current.maxSpeed);
                }

                for (int i = 0; i < 1; i++)
                {
                    RotatingLazerSentry current = (RotatingLazerSentry)CreateObject("RotatingLazerSentryPF", GetRandomGameEdge(), GetRandomAngle());
                    current.velocity = GetRandomVelocity(current.maxSpeed);
                }
                for (int i = 0; i < 1; i++)
                {
                    SlowTurner current = (SlowTurner)CreateObject("SlowTurnerPF", GetRandomGameEdge(), GetRandomAngle());
                    current.velocity = GetRandomVelocity(current.maxSpeed);
                }

                for (int i = 0; i < 1; i++)
                {
                    LazerShooter current = (LazerShooter)CreateObject("LazerShooterPF", GetRandomGameEdge(), GetRandomAngle());
                    current.velocity = GetRandomVelocity(current.maxSpeed);
                }
                break;

            case 4:
                IngameInterface.DisplayMessage("Wave 4", MESSAGE_SECS);
                for (int i = 0; i < 1; i++)
                {
                    MineLayer current = (MineLayer)CreateObject("MineLayerPF", GetRandomGameEdge(), GetRandomAngle());
                    current.velocity = GetRandomVelocity(current.maxSpeed);
                }
                for (int i = 0; i < 2; i++)
                {
                    Asteroid current = (Asteroid)CreateObject("AsteroidPF", GetRandomGameEdge(), GetRandomAngle());
                    current.velocity = GetRandomVelocity(current.maxSpeed);
                }

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

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

            default:
                break;
            }
        }
    }
Example #5
0
    protected override void CreateLevel()
    {
        MusicPlay("sounds/level1Loop");

        levelSize    = new Vector2(100, 80); //set the level size
        minSize      = new Vector2(10, 8);
        shrinkAmount = (levelSize - minSize) / (SHRINK_SECONDS * updatesPerSec);

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

        IngameInterface.DisplayMessage("Kill all enemies before space collapses!", 3);

        for (int i = 0; i < 4; i++)
        {
            HomingMine current = (HomingMine)CreateObject("HomingMinePF", GetRandomPosition(), GetRandomAngle());
        }

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

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

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

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

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

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

        for (int i = 0; i < 2; 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);
        }

        Shield shield = (Shield)CreateObject("ShieldPF");
    }
Example #6
0
    protected override void CreateLevel()
    {
        MusicPlay("sounds/level1Loop");

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

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

        for (int i = 0; i < 8; i++)
        {
            HomingMine current = (HomingMine)CreateObject("HomingMinePF", GetRandomPosition(), GetRandomAngle());
        }

        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++)
        {
            LazerShooter current = (LazerShooter)CreateObject("LazerShooterPF", GetRandomPosition(), GetRandomAngle());
            current.velocity = GetRandomVelocity(current.maxSpeed);
        }

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

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

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

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

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

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

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

        Armor armor = (Armor)CreateObject("ArmorPF");
    }