示例#1
0
        public BlackHole[] LoadInBlackHoles(Scene scene)
        {
            BlackHole[] blackHolesObj = new BlackHole[blackHoles.Count];

            for (int i = 0; i < blackHoles.Count; i++)
            {
                blackHolesObj[i] = blackHoles[i];
                scene.AddChild(blackHolesObj[i].getSprite());
            }

            if (blackHoles.Count != 0)
            {
                return(blackHolesObj);
            }
            else
            {
                return(null);
            }
        }
示例#2
0
        public void AddObject(string type, float x, float y, float rotation)
        {
            switch (type)
            {
            // Collectables
            case "Coin":
                Coin coin = new Coin();
                coin.setPosition(new Vector2(x, y));
                coin.setRotation(-rotation);
                coins.Add(coin);
                break;

            case "Gem":
                Gem gem = new Gem();
                gem.setPosition(new Vector2(x, y));
                gem.setRotation(-rotation);
                gems.Add(gem);
                break;

            // Obstacles
            case "Small Spikes":
                Spikes smallSpikes = new Spikes(1);

                if (rotation == 0)
                {
                    smallSpikes.setPosition(new Vector2(x, y - 100.0f));
                }
                else
                {
                    smallSpikes.setPosition(new Vector2(x - 220.0f, y - 165.0f));
                }

                //rotation += 270;
                smallSpikes.setRotation(-rotation);
                spikes.Add(smallSpikes);
                break;

            case "Large Spikes":
                Spikes largeSpikes = new Spikes(2);

                if (rotation == 0)
                {
                    largeSpikes.setPosition(new Vector2(x, y - 100.0f));
                }
                else
                {
                    largeSpikes.setPosition(new Vector2(x - 240.0f, y - 210.0f));
                }

                //rotation += 270;
                largeSpikes.setRotation(-rotation);
                spikes.Add(largeSpikes);
                break;

            case "Black Hole":
                BlackHole blackHole = new BlackHole();

                if (rotation == 0)
                {
                    blackHole.setPosition(new Vector2(x, y));
                }
                else
                {
                    blackHole.setPosition(new Vector2(x, y));
                }

                blackHole.setRotation(-rotation);
                blackHole.setDirection((int)rotation);
                blackHoles.Add(blackHole);
                break;

            case "Breakable Wall":
                BreakableWall breakableWall = new BreakableWall();

                if (rotation == 0)
                {
                    breakableWall.setPosition(new Vector2(x, y));
                }
                else
                {
                    breakableWall.setPosition(new Vector2(x, y));
                }

                breakableWall.setRotation(-rotation);
                breakableWall.setDirection((int)rotation);
                breakableWalls.Add(breakableWall);
                break;

            case "Laser Gate":
                LaserGate laserGate = new LaserGate(rnd.Next(0, 18));

                if (rotation == 0)
                {
                    laserGate.setPosition(new Vector2(x, y));
                }
                else
                {
                    laserGate.setPosition(new Vector2(x, y));
                }

                laserGate.setRotation(-rotation);
                laserGate.setDirection((int)rotation);
                laserGates.Add(laserGate);
                break;

            case "Wind Tunnel":
                WindTunnel windTunnel = new WindTunnel();

                if (rotation == 0)
                {
                    windTunnel.setPosition(new Vector2(x, y));
                }
                else
                {
                    windTunnel.setPosition(new Vector2(x, y));
                }

                windTunnel.setRotation(-rotation);
                windTunnel.setDirection((int)rotation);
                windTunnels.Add(windTunnel);
                break;

            // Level Flag
            case "Level":
                levelFlag = new LevelFlag();
                levelFlag.setPosition(new Vector2(x, y - 80.0f));

                levelFlag.setRotation(-rotation);
                break;

            // Player Position
            case "Player":
                playerPos = new Vector2(x, y);
                break;
            }
        }