Exemplo n.º 1
0
 /// <summary>
 /// Used for updating weapons when in the shipdesigner GameState
 /// </summary>
 /// <param name="wpn">The new weaponry that replaces Stats_Weapons</param>
 public void UpdateWeaponConfig(ShipWeaponry wpn)
 {
     if (EventManager.Instance.CurrState == GameState.shipdesigner)
     {
         Stats_Weapons = wpn;
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Creates a ShipConfiguration with the specified parameters
 /// </summary>
 /// <param name="wpn">Ship's weapons</param>
 /// <param name="def">Ship's defenses</param>
 /// <param name="thr">Ship's thrusters</param>
 /// <param name="mas">Ship's mass</param>
 /// <param name="col">Ship's colliders</param>
 /// <param name="spr">Ship's body sprite</param>
 public ShipConfiguration(ShipWeaponry wpn, ShipDefenses def, ShipThrusters thr, float mas, Vector2[] col, Sprite spr)
 {
     Stats_Weapons    = wpn;
     Stats_Defenses   = def;
     Current_Defenses = def;
     Stats_Thrusters  = thr;
     Mass             = mas;
     ColliderForm     = col;
     BodySprite       = spr;
 }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a basic, otherwise blank ship config
        /// </summary>
        /// <param name="spr">The sprite for the ship</param>
        /// <param name="e">A reference to the EventManager in the scene</param>
        public ShipConfiguration(Sprite spr)
        {
            BodySprite = spr;

            ShipWeaponry w = new ShipWeaponry();

            w.WeaponCount = 3;
            w.Weapons     = new List <ShipWeapon>();
            w.Rotations   = new List <Vector3>();
            w.Positions   = new List <Vector3>();
            w.SlotStatus  = new List <WeaponSlotStatus>();
            Stats_Weapons = w;

            ShipDefenses d = new ShipDefenses();

            Stats_Defenses   = d;
            Current_Defenses = d;

            ShipThrusters t = new ShipThrusters();

            Stats_Thrusters = t;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Called before the first frame update
        /// </summary>
        private void Start()
        {
            ShipDefenses  defenses  = new ShipDefenses();
            ShipThrusters thrusters = new ShipThrusters();
            ShipWeaponry  weapons   = new ShipWeaponry();

            Vector2[] colliders = null;

            #region Setup

            defenses.ArmorStrength    = 50f;
            defenses.ShieldRecharge   = 1f;
            defenses.ShieldStrength   = 15f;
            defenses.ShieldDelay      = 5f;
            defenses.DamageResistance = 15f;

            thrusters.DampenerStrength     = 0.5f;              // Equivalent to rigidbody linear drag set before this temp code (shipDragRate was unused)
            thrusters.ForwardThrusterForce = 10f;               // Equivalent to shipAccRate set in the old player class ResetPlayer()
            thrusters.MaxDirectionalSpeed  = 10f;               // Equivalent to shipMaxSpd set in old player class
            thrusters.RecoilCompensation   = 0.9f;
            thrusters.ReverseThrusterForce = 3f;
            thrusters.RotationalSpeed      = 5f;                // Equivalent to shipRotSpd set in old player class

            ShipWeapon basicBlaster = new ShipWeapon();
            basicBlaster.Damage       = 5f;                     // Original hardcoded value in prototyped Projectile was 5
            basicBlaster.Name         = "Basic Blaster";
            basicBlaster.OutputPrefab = bulletPrefab;           // The prefabs and sounds will eventually be handled/stored outside Player
            basicBlaster.OutputSound  = bulletSound;
            basicBlaster.RateOfFire   = 0.35f;                  // Originally fireRate in old Player
            basicBlaster.Recoil       = 15f;                    // Originally -shipAcc * 5f when handling recoil in old Player
            basicBlaster.Speed        = 200f;                   // Originally projectileSpeed in old Player
            basicBlaster.Type         = WeaponType.projectile;
            ShipWeapon secondBlaster = new ShipWeapon();
            secondBlaster.Damage       = 1f;
            secondBlaster.Name         = "Secondary Blaster";
            secondBlaster.OutputPrefab = bulletPrefab;
            secondBlaster.OutputSound  = bulletSound2;
            secondBlaster.RateOfFire   = 0.2f;
            secondBlaster.Recoil       = 5f;
            secondBlaster.Speed        = 100f;
            secondBlaster.Type         = WeaponType.projectile;

            weapons.DamageModifier = 1;
            weapons.RateModifier   = 1;
            weapons.WeaponCount    = 3;
            weapons.Positions      = new List <Vector3>()
            {
                new Vector3(0.35f, 0, 0),
                new Vector3(0.25f, 0.21f, 0),
                new Vector3(0.25f, -0.21f, 0)
            };
            weapons.Rotations = new List <Vector3>
            {
                { new Vector3(0, 0, 0) },
                { new Vector3(0, 0, 10f) },
                { new Vector3(0, 0, -10f) }
            };
            weapons.SlotStatus = new List <WeaponSlotStatus>
            {
                { WeaponSlotStatus.enabled },
                { WeaponSlotStatus.enabled },
                { WeaponSlotStatus.enabled }
            };
            weapons.Weapons = new List <ShipWeapon>
            {
                { basicBlaster },
                { secondBlaster },
                { secondBlaster }
            };

            colliders = new Vector2[]                           // This is based off of what was in the PolygonCollider2D in old Player
            {
                new Vector2(0.25f, 0),
                new Vector2(-0.25f, 0.25f),
                new Vector2(-0.125f, 0),
                new Vector2(-0.25f, -0.25f)
            };

            #endregion

            ShipConfiguration tempShipConfig = new ShipConfiguration(weapons, defenses, thrusters, 1, colliders, sprite.sprite);

            // This may seem redundant, accessing what was set in the previous Setup region, but that will eventually disappear once actual ships are defined
            rigidbody.drag  = tempShipConfig.Stats_Thrusters.DampenerStrength;
            rigidbody.mass  = tempShipConfig.Mass;
            collider.points = colliders;
            sprite.sprite   = tempShipConfig.BodySprite; // This, like the bulletPrefab and bulletSound, will be handled/stored outside player, so the back-and-fourth setting seen here won't be present eventually

            for (int i = 0; i < weapons.WeaponCount; i++)
            {
                ShipWeapon w   = weapons.Weapons[i];
                GameObject obj = new GameObject(w.Name);
                obj.transform.parent   = gameObject.transform;
                obj.transform.position = weapons.Positions[i];
                obj.transform.rotation = Quaternion.Euler(weapons.Rotations[i]);
                bulletLoc.Add(obj);
            }
        }