Esempio n. 1
0
        //Set a weapon port to a new weapon
        public void AddWeapon(Weapon newWeapon, int zeroBasePortNumber)
        {
            //Increase the count of the number of weapons attached to the ship
            weaponCount++;

            //Check if vali port number was given
            if (zeroBasePortNumber < 0 || zeroBasePortNumber > (weaponCount - 1))
                return;       //Invalid weapon port #

            //assign weapon to the port
            weapons[zeroBasePortNumber] = newWeapon;
        }
Esempio n. 2
0
        //Find the first free port on the ship and put the weapon there
        //if no port is found, do nothing
        public void AddWeapon(Weapon newWeapon)
        {
            int emptyPort = -1; //port with no weapon assigned

            for (int i = 0; i < weaponPortCount; i++)
            {
                if (weapons[i] == null) //found empty port
                {
                    emptyPort = i;
                    break;
                }
            }

            //Check if no port found
            if (emptyPort == -1)
                return;

            //Increase the count of the number of weapons attached to the ship
            weaponCount++;

            //assign weapon to the port
            weapons[emptyPort] = newWeapon;
        }
Esempio n. 3
0
        public void AddWeaponPort(Vector2 imageOffset)
        {
            //increase count of available weapon ports on the ship
            weaponPortCount++;

            //---------
            //Create the new weapon port

            //add a new port to the list
            Vector2[] newPorts = new Vector2[weaponPortCount];

            //add new port to the end of the list
            newPorts[weaponPortCount-1] = imageOffset;

            //Copy old ports into new list
            for (int i = 0; i < weaponPort.Length; i++)
                newPorts[i] = weaponPort[i];

            //replace old list with new list (new null element on the end)
            weaponPort = newPorts;

            //---------
            //Save orriginal position of port

            //make new list of port saves
            Vector2[] newPortSaves = new Vector2[weaponPortCount];

            //copy port saves into the new list
            for (int i = 0; i < weaponPortCount - 1; i++)
                newPortSaves[i] = weaponPortSave[i];

            //add the new save to the end
            newPortSaves[weaponPortCount - 1] = imageOffset;

            //replace old list with new
            weaponPortSave = newPortSaves;

            //---------
            //Now fix the size of the weapons array (add a null weapon to the end of the array)

            //make new weapon list same size as port
            Weapon[] newWeaponList = new Weapon[weaponPortCount];

            //copy the weapons into the new list
            for (int i = 0; i < (weaponPort.Length - 1); i++)
                newWeaponList[i] = weapons[i];

            //replace old weapons array with the new one that hass a nul;l on the end
            weapons = newWeaponList;
        }
Esempio n. 4
0
        //############################################################################################
        //############################################################################################
        public static Weapon CreateWeapon(WeaponType type)
        {
            Weapon w;

            switch (type)
            {

                //----------------------------------------------------------------
                case WeaponType.BasicCanon:
                    //Create weapon, load content and size info
                    w = new Weapon(Textures.TextureName.weaponCanon1);
                    w.LoadContent();
                    //Set weapon properties
                    w.name = "Simple Canon";
                    w.bulletType = BulletType.BRoundRedSlow;
                    w.bulletOffset = new Vector2(0, 16f);
                    //Behaviors
                    w.SetAimMethod(new AMLinear());
                    //w.SetAimMethod(new AMNearestPlayer());
                    w.SetFirePattern(new FPStraightSingle());
                    w.SetFireMethod(new FMWConstant(100));
                    break;

                //----------------------------------------------------------------
                case WeaponType.TripleCanon:
                    //Create weapon, load content and size info
                    w = new Weapon(Textures.TextureName.weaponCanon1);
                    w.LoadContent();
                    //Set weapon properties
                    w.name = "Triple Canon";
                    w.bulletType = BulletType.Round;
                    w.bulletOffset = new Vector2(0, 16f);
                    //Behaviors
                    w.SetAimMethod(new AMLinear());
                    w.SetFirePattern(new FPTripleWide());
                    w.SetFireMethod(new FMWConstant(100));
                    break;

                //----------------------------------------------------------------
                case WeaponType.SideShooter:
                    //Create weapon, load content and size info
                    w = new Weapon(Textures.TextureName.weaponCanon1);
                    w.LoadContent();
                    //Set weapon properties
                    w.name = "Right Shooter";
                    w.bulletType = BulletType.PeaShot;
                    w.bulletOffset = new Vector2(0, 10f);
                    //Behaviors
                    w.SetAimMethod(new AMCardinal(Cardinal.Right));
                    w.SetFirePattern(new FPStraightSingle());
                    w.SetFireMethod(new FMWConstant(300));
                    break;

                //----------------------------------------------------------------
                case WeaponType.UpShooter:
                    //Create weapon, load content and size info
                    w = new Weapon(Textures.TextureName.NullImage);
                    w.LoadContent();
                    //Set weapon properties
                    w.name = "Up Shooter";
                    w.bulletType = BulletType.Fatty;
                    w.bulletOffset = new Vector2(0, 10f);
                    //Behaviors
                    w.SetAimMethod(new AMCardinal(Cardinal.Up));
                    w.SetFirePattern(new FPStraightSingle());
                    w.SetFireMethod(new FMWConstant(100));
                    break;

                //----------------------------------------------------------------
                case WeaponType.FunGun:
                    //Create weapon, load content and size info
                    w = new Weapon(Textures.TextureName.weaponCanon1);
                    w.LoadContent();
                    //Set weapon properties
                    w.name = "BFG";
                    w.bulletType = BulletType.Fatty;
                    w.bulletOffset = new Vector2(0, 30f);
                    //Behaviors
                    w.SetAimMethod(new AMLinear());
                    w.SetFirePattern(new FPTripleNarrow());
                    w.SetFireMethod(new FMWConstant(80));
                    break;

                //----------------------------------------------------------------
                default:
                    w = CreateWeapon(WeaponType.BasicCanon);
                    break;
            }

            w.type = type;
            return w;
        }