コード例 #1
0
        public Space(Hero hero, List <Enemy> enemies, float leftEdge) : base()
        {
            this.hero = hero;

            powerups = new List <PowerUp>();
            dyepacks = new List <DyePack>();
            debris   = new List <Debris>();
            trail    = new Trail(hero);

            float height   = GameWorld.topEdge;
            float position = (width * 0.5f) + leftEdge;

            space         = new XNACS1Rectangle(new Vector2(position, height / 2), width, height);
            space.Visible = false;

            // add dyepacks to space region
            List <Color> colors    = Game.randomColorSet(Game.colorCount);
            float        rightEdge = space.CenterX + space.Width / 2;
            float        region    = (rightEdge - leftEdge) / dyepackCount;

            for (int i = 0; i < dyepackCount; i++)
            {
                float regionLeft  = leftEdge + (i * region);
                float regionRight = regionLeft + region;
                dyepacks.Add(new DyePack(hero, regionLeft, regionRight, colors[i % Game.colorCount]));
            }

            region = (rightEdge - leftEdge) / powerupCount;
            for (int i = 0; i < powerupCount; i++)
            {
                float regionLeft  = leftEdge + (i * region);
                float regionRight = regionLeft + region;
                powerups.Add(PowerUp.randomPowerUp(hero, regionLeft, regionRight));
            }

            // offset the region to pad the space before the next element
            // this makes the region slightly smaller than it actually should be otherwise
            int offset = 1;

            region = (rightEdge - leftEdge) / (debrisCount + offset);
            for (int i = 0; i < debrisCount; i++)
            {
                float regionLeft  = leftEdge + (i * region);
                float regionRight = regionLeft + region;
                debris.Add(new Debris(hero, enemies, regionLeft, regionRight));
            }
        }
コード例 #2
0
ファイル: Stargate.cs プロジェクト: kunlakan/LearningGames
        public Stargate(Hero hero, List <Enemy> enemies, float leftEdge) : base()
        {
            List <Color> colors = Game.randomColorSet(GATE_COUNT);

            this.gates = new Gate[GATE_COUNT];
            for (int i = 0; i < this.gates.Length; i++)
            {
                this.gates[i] = new Gate(i, hero, enemies, leftEdge, colors[i]);
            }

            this.platforms = new Platform[GATE_COUNT + 1];
            for (int i = 0; i < this.platforms.Length; i++)
            {
                bool boundary = (i == 0) || (i == this.platforms.Length - 1);
                this.platforms[i] = new Platform(i, hero, enemies, leftEdge, boundary);
            }

            float height    = GameWorld.topEdge;
            float Xposition = (width * 0.5f) + leftEdge;

            this.backdrop       = new XNACS1Rectangle(new Vector2(Xposition, height / 2), width, height);
            this.backdrop.Color = new Color(Color.Black, 130);
        }