示例#1
0
        public PlayerObject(Game game, SpriteBatch sB)
            : base(game, sB)
        {
            isControllable = true;
            isMoveable = true;
            APressedCount = 0;

            //position = new Vector2(10, 10);
            speed = 2f;
            friction = 0.15f;
            maxcount_weapon1 = 10;
            maxcount_weapon2 = 20;
            //Higher number, slower the rate
            fireRate_weapon1 = 300;
            fireRate_weapon2 = 100;

            velocity_weapon1 = new Vector2(0,-10);
            velocity_weapon2 = new Vector2(0,-20);

            activeTextureID = 0;

            weapon1 = new WeaponObject[maxcount_weapon1];
            for (int i = 0; i < maxcount_weapon1; i++)
            {
                weapon1[i] = new WeaponObject(game, sB, Game.Content.Load<Texture2D>("Sprites/Player/mainWeaponV1"));
                weapon1[i].velocity = velocity_weapon1;
                weapon1[i].fireRate = fireRate_weapon1;
                Game.Components.Add(weapon1[i]);
            }

            weapon2 = new WeaponObject[maxcount_weapon2];
            for (int i = 0; i < maxcount_weapon2; i++)
            {
                weapon2[i] = new WeaponObject(game, sB, Game.Content.Load<Texture2D>("Sprites/Player/mainWeaponV1"));
                weapon2[i].velocity = velocity_weapon2;
                weapon2[i].fireRate = fireRate_weapon2;
                Game.Components.Add(weapon2[i]);

            }

            weaponDict = new Dictionary<int,WeaponObject[]>();

            weaponDict.Add(1, weapon1);
            weaponDict.Add(2, weapon2);

            textureList = new List<Texture2D>();
            textureList.Add(Game.Content.Load<Texture2D>("Sprites/Player/ChromiumLogoV2")); //element 0
            textureList.Add(Game.Content.Load<Texture2D>("Sprites/Player/heyouV1"));
            textureList.Add(Game.Content.Load<Texture2D>("Sprites/Player/ouch"));
            textureList.Add(Game.Content.Load<Texture2D>("Sprites/Player/hit_a"));
            textureList.Add(Game.Content.Load<Texture2D>("Sprites/Player/pewpew"));
            textureList.Add(Game.Content.Load<Texture2D>("Sprites/Player/moveme")); //element 5
            textureList.Add(Game.Content.Load<Texture2D>("Sprites/Player/goodjob"));
            textureList.Add(Game.Content.Load<Texture2D>("Sprites/Player/nextlvl")); //element 7
            textureList.Add(Game.Content.Load<Texture2D>("Sprites/Player/smileyfaceV1"));
            textureList.Add(Game.Content.Load<Texture2D>("Sprites/Player/shiftyface"));//element9
            textureList.Add(Game.Content.Load<Texture2D>("Sprites/Player/OOOface"));//element10
            textureList.Add(Game.Content.Load<Texture2D>("Sprites/Player/polegoatFace"));//element11

            //Sounds from soundjay.com and flashkit.com
            weapon_sound1 = Game.Content.Load<SoundEffect>("SoundEffects/button-4");

            // for player2 controls
            inputHandler = new InputHandler(game,1);
            Game.Components.Add(inputHandler);
        }
示例#2
0
        public PlayerObject(Game game, SpriteBatch sB) : base(game, sB)
        {
            isControllable = true;
            isMoveable     = true;
            APressedCount  = 0;

            //position = new Vector2(10, 10);
            speed            = 2f;
            friction         = 0.15f;
            maxcount_weapon1 = 10;
            maxcount_weapon2 = 20;
            //Higher number, slower the rate
            fireRate_weapon1 = 300;
            fireRate_weapon2 = 100;

            velocity_weapon1 = new Vector2(0, -10);
            velocity_weapon2 = new Vector2(0, -20);

            activeTextureID = 0;

            weapon1 = new WeaponObject[maxcount_weapon1];
            for (int i = 0; i < maxcount_weapon1; i++)
            {
                weapon1[i]          = new WeaponObject(game, sB, Game.Content.Load <Texture2D>("Sprites/Player/mainWeaponV1"));
                weapon1[i].velocity = velocity_weapon1;
                weapon1[i].fireRate = fireRate_weapon1;
                Game.Components.Add(weapon1[i]);
            }


            weapon2 = new WeaponObject[maxcount_weapon2];
            for (int i = 0; i < maxcount_weapon2; i++)
            {
                weapon2[i]          = new WeaponObject(game, sB, Game.Content.Load <Texture2D>("Sprites/Player/mainWeaponV1"));
                weapon2[i].velocity = velocity_weapon2;
                weapon2[i].fireRate = fireRate_weapon2;
                Game.Components.Add(weapon2[i]);
            }

            weaponDict = new Dictionary <int, WeaponObject[]>();

            weaponDict.Add(1, weapon1);
            weaponDict.Add(2, weapon2);

            textureList = new List <Texture2D>();
            textureList.Add(Game.Content.Load <Texture2D>("Sprites/Player/ChromiumLogoV2")); //element 0
            textureList.Add(Game.Content.Load <Texture2D>("Sprites/Player/heyouV1"));
            textureList.Add(Game.Content.Load <Texture2D>("Sprites/Player/ouch"));
            textureList.Add(Game.Content.Load <Texture2D>("Sprites/Player/hit_a"));
            textureList.Add(Game.Content.Load <Texture2D>("Sprites/Player/pewpew"));
            textureList.Add(Game.Content.Load <Texture2D>("Sprites/Player/moveme"));       //element 5
            textureList.Add(Game.Content.Load <Texture2D>("Sprites/Player/goodjob"));
            textureList.Add(Game.Content.Load <Texture2D>("Sprites/Player/nextlvl"));      //element 7
            textureList.Add(Game.Content.Load <Texture2D>("Sprites/Player/smileyfaceV1"));
            textureList.Add(Game.Content.Load <Texture2D>("Sprites/Player/shiftyface"));   //element9
            textureList.Add(Game.Content.Load <Texture2D>("Sprites/Player/OOOface"));      //element10
            textureList.Add(Game.Content.Load <Texture2D>("Sprites/Player/polegoatFace")); //element11

            //Sounds from soundjay.com and flashkit.com
            weapon_sound1 = Game.Content.Load <SoundEffect>("SoundEffects/button-4");


            // for player2 controls
            inputHandler = new InputHandler(game, 1);
            Game.Components.Add(inputHandler);
        }