コード例 #1
0
    //Spawns the ammo prefab in game. Updates world ammo count
    void SpawnAmmo(int x, int z)
    {
        ammo box = ScriptableObject.CreateInstance <ammo>();

        box.model = ammoBox;
        Instantiate(box.model, new Vector3(x, 1f, z), Quaternion.identity);
        ++totalWorldAmmo;
    }
コード例 #2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            backgscroll   = new scrollingbackground(Content, "space", 1, 5, 5);
            gameoverimage = new graphics2d(Content, "gameover", displaywidth, displayheight);

            for (int i = 0; i < numberofballs; i++)
            {
                float tempsize = (float)(randomiser.Next(100) + 1) * ballsizeratio;
                if (tempsize < miniballsize)
                {
                    tempsize = miniballsize;
                }

                balls[i] = new sprites2d(Content, "ast1", displaywidth / 2, displayheight / 2, tempsize,
                                         new Color((byte)randomiser.Next(255), (byte)randomiser.Next(255), (byte)randomiser.Next(255)), true, randomiser);
            }
            collidesound    = Content.Load <SoundEffect>("rocks");
            soundtrack1     = Content.Load <SoundEffect>("explosive_attack");
            music1          = soundtrack1.CreateInstance();
            music1.IsLooped = true;
            music1.Volume   = 0.5f;
            soundtrack2     = Content.Load <SoundEffect>("iron-man");
            music2          = soundtrack2.CreateInstance();
            music2.IsLooped = true;
            music2.Volume   = 0.5f;
            mainfont        = Content.Load <SpriteFont>("quartz4");

            for (int i = 0; i < numberofballs; i++)
            {
                explosion[i] = new animation(Content, "effect_005", 0, 0, 1f, Color.White, false, 24, 4, 5, false);
            }

            shiphit[0] = new animation(Content, "effect_003", 0, 0, 1, Color.White, false, 24, 5, 5, false);
            shiphit[1] = new animation(Content, "effect_002", 0, 0, 1, Color.White, false, 24, 4, 5, false);

            bullet[0] = new ammo(Content, "bullet1", 0, 0, .1f, Color.White, false);
            bullet[1] = new ammo(Content, "bullet2", 0, 0, .1f, Color.White, false);

            for (int b = 0; b < numberofbullets; b++)
            {
                for (int s = 0; s < numberofships; s++)
                {
                    bullets5[s, b] = new ammo(Content, "bullet2", 0, 0, .1f, Color.White, false);
                }
            }

            reset();
        }
コード例 #3
0
 // Use this for initialization
 void Start()
 {
     //rand is picked from a range of 100 and the number chosen will tie into the chances of what the item will be
     int rand = UnityEngine.Random.Range (0, 100);
     if (rand >= 0 && rand < 70) { //70% of getting nothing
         type = "none";
     } else if (rand >= 70 && rand < 85) { //15% of getting pistol ammo
         ammunition = new pistolammo ();
         ammunition.Start ();
         type = "pistol";
     } else if (rand >= 85 && rand < 95) { //10% of getting rifle ammo
         ammunition = new rifleammo ();
         ammunition.Start ();
         type = "rifle";
     } else if (rand >= 95 && rand < 98) { //3% of getting gas
         gas = 20;
         type = "gas";
     } else { //2% chance of getting 20 health
         health = 20;
         type = "health";
     }
 }
コード例 #4
0
ファイル: Game1.cs プロジェクト: easdale2010/Asteriods
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            backgscroll = new scrollingbackground(Content, "space", 1, 5, 5);
            gameoverimage = new graphics2d(Content, "gameover", displaywidth, displayheight);

            for (int i = 0; i < numberofballs; i++)
            {
                float tempsize = (float)(randomiser.Next(100) + 1) * ballsizeratio;
                if (tempsize < miniballsize) tempsize = miniballsize;

                balls[i] = new sprites2d(Content, "ast1", displaywidth / 2, displayheight / 2, tempsize,
                    new Color((byte)randomiser.Next(255), (byte)randomiser.Next(255), (byte)randomiser.Next(255)), true, randomiser);
            }
            collidesound = Content.Load<SoundEffect>("rocks");
            soundtrack1 = Content.Load<SoundEffect>("explosive_attack");
            music1 = soundtrack1.CreateInstance();
            music1.IsLooped = true;
            music1.Volume = 0.5f;
            soundtrack2 = Content.Load<SoundEffect>("iron-man");
            music2 = soundtrack2.CreateInstance();
            music2.IsLooped = true;
            music2.Volume = 0.5f;
            mainfont = Content.Load<SpriteFont>("quartz4");

            for (int i = 0; i < numberofballs; i++)
            {
                explosion[i] = new animation(Content, "effect_005", 0, 0, 1f, Color.White, false, 24, 4, 5, false);
            }

            shiphit[0] = new animation(Content, "effect_003", 0, 0, 1, Color.White, false, 24, 5, 5, false);
            shiphit[1] = new animation(Content, "effect_002", 0, 0, 1, Color.White, false, 24, 4, 5, false);

            bullet[0] = new ammo(Content, "bullet1", 0, 0, .1f, Color.White, false);
            bullet[1] = new ammo(Content, "bullet2", 0, 0, .1f, Color.White, false);

            for (int b = 0; b < numberofbullets; b++)
                for (int s = 0; s < numberofships; s++)

                    bullets5[s, b] = new ammo(Content, "bullet2", 0, 0, .1f, Color.White, false);

            reset();
        }