Exemplo n.º 1
0
        /// <summary>
        /// Creates the weapon's 3D model in the scene
        /// </summary>
        /// <returns>The weapon game object.</returns>
        /// <param name="position">Position.</param>
        /// <param name="weapon">Weapon.</param>
        public static GameObject createWeaponGameObject(Vector3 position, PrebuiltWeaponType weapon)
        {
            GameObject reference = null;
            Vector3 rotation = Vector3.zero;

            switch (weapon) {

            case PrebuiltWeaponType.Chaingun:
                reference =  Resources.Load<GameObject>("Weaponry/Gatling Gun");
                rotation = new Vector3(-90,0,0);
                break;

            case PrebuiltWeaponType.MissileLauncher:
                reference =  Resources.Load<GameObject>("Weaponry/Rocket Launcher");
                break;

            default:
                reference =  Resources.Load<GameObject>("Weaponry/Gatling Gun");
                rotation = new Vector3(-90,0,0);
                break;

            }

            GameObject instance = null;

            if (reference != null) {
                instance = GameObject.Instantiate (reference, position, Quaternion.Euler(rotation)) as GameObject;
            }

            return instance;
        }
Exemplo n.º 2
0
        // TODO create override that takes WeaponConfigurations instead of PrebuiltWeaponType
        public static GameObject CreatePlayer(Vector3 position, PrebuiltWeaponType leftWeapon, PrebuiltWeaponType rightWeapon)
        {
            // Grab reference to the player to load
            GameObject playerReference = Resources.Load<GameObject> ("Player");

            // Create instance of the player
            GameObject instance = Object.Instantiate (playerReference, position, Quaternion.identity) as GameObject;

            // Try grabing instance of player behavior
            PlayerBehavior playerBehavior = instance.GetComponent<PlayerBehavior> ();
            GameManagement.GameManager.getInstance ().addFriendly (playerBehavior);

            // If we where succesful in getting the player behavior
            if (playerBehavior != null) {

                // Configure player settings
                playerBehavior.setBoosterSettings (200f, 200f);
                playerBehavior.setHealthParameters (100f, 100f);

            }

            // Create the Weapons //

            // get instance of the player's weapon behavior
            WeaponBehavoir weaponBehavior = instance.GetComponent<WeaponBehavoir>();

            if (weaponBehavior != null) {

                // Create the players left weapon if one was passed in
                if (leftWeapon != PrebuiltWeaponType.None) {

                    Weapon leftWeaponObject = WeaponFactory.createWeapon (Vector3.zero, leftWeapon);
                    weaponBehavior.setLeftArm (leftWeaponObject);

                    leftWeaponObject.getWeaponModel().transform.parent = instance.transform.FindChild("MainCamera").FindChild("Turret Cannons");

                    // Invert the X axis because it's on the players left side
                    Vector3 pos = WeaponFactory.offSetFromPlayer(leftWeapon);
                    pos.x *= -1;
                    leftWeaponObject.getWeaponModel().transform.localPosition = pos;

                }

                // Create the players right weapon if one was passed in
                if (rightWeapon != PrebuiltWeaponType.None) {

                    Weapon rightWeaponObject = WeaponFactory.createWeapon (Vector3.zero, rightWeapon);
                    weaponBehavior.setRightArm (rightWeaponObject);

                    rightWeaponObject.getWeaponModel().transform.parent = instance.transform.FindChild("MainCamera").FindChild("Turret Cannons");
                    rightWeaponObject.getWeaponModel().transform.localPosition = WeaponFactory.offSetFromPlayer(rightWeapon);

                }

            }

            return instance;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a weapon configuration based on the weapon type passed in. 
        /// ( A chaingun fires faster than a rocket launcher )
        /// </summary>
        /// <returns>The weapon configuration.</returns>
        /// <param name="weapon">Weapon.</param>
        public static WeaponConfiguration getWeaponConfiguration(PrebuiltWeaponType weapon)
        {
            WeaponConfiguration config;

            switch (weapon){

            case PrebuiltWeaponType.Chaingun:

                config = new WeaponConfiguration(4f, .02f,  .15f, 0.05f, .8f, Resources.Load<GameObject> ("Particle/Bullet Impact"));
                config.Name = "SKULL F****R";

                return config;

            case PrebuiltWeaponType.MissileLauncher:

                config = new WeaponConfiguration(50f, .2f, .05f, 1f, .95f, new ProjectileConfiguration(Resources.Load<GameObject>("Projectiles/Missile")));
                config.Name = "ROCKET LAWNCHER";

                return config;

            }

            return new WeaponConfiguration();
        }
Exemplo n.º 4
0
 /// <summary>
 /// Builds a weapon object based on what prebuilt weapon was passed in
 /// </summary>
 /// <returns>The weapon.</returns>
 /// <param name="position">Position.</param>
 /// <param name="weapon">Weapon.</param>
 public static Weapon createWeapon(Vector3 position, PrebuiltWeaponType weapon)
 {
     return new Weapon (createWeaponGameObject (position, weapon), getWeaponConfiguration (weapon));
 }
Exemplo n.º 5
0
        /// <summary>
        /// A weapon when parented to the player has a certain offset from them,
        /// and that offset changes based on the 3D model
        /// </summary>
        /// <returns>The set from player.</returns>
        /// <param name="weapon">Weapon.</param>
        public static Vector3 offSetFromPlayer(PrebuiltWeaponType weapon)
        {
            switch (weapon){

            case PrebuiltWeaponType.Chaingun:
                return new Vector3 (1.63f, 0, 0);

            case PrebuiltWeaponType.MissileLauncher:
                return new Vector3 (1.649f, 0.033f, 0.239f);

            }

            return new Vector3 (1.63f, 0, 0);
        }