Example #1
0
 /// <summary>
 ///
 /// </summary>
 protected override void Awake()
 {
     base.Awake();
     GManager   = this.GetComponent <bl_GunManager>();
     AmmoTextUI = bl_UIReferences.Instance.AmmoText;
     ClipText   = bl_UIReferences.Instance.ClipText;
 }
    public override void OnInspectorGUI()
    {
        serializedObject.Update();
        m_Target = (bl_PlayerSync)this.target;
        bool isProjectPrefab   = EditorUtility.IsPersistent(m_Target.gameObject);
        bool allowSceneObjects = !EditorUtility.IsPersistent(m_Target);

        GUI.enabled = false;
        GUILayout.BeginVertical("box");
        m_Target.FPState = (PlayerFPState)EditorGUILayout.EnumPopup("FPState", m_Target.FPState, EditorStyles.toolbarDropDown);
        GUILayout.EndVertical();
        GUI.enabled = true;
        if (m_Target.NetworkGuns == null)
        {
            m_Target.NetworkGuns = new System.Collections.Generic.List <bl_NetworkGun>();
        }

        if (m_Target.NetworkGuns.Count == 0)
        {
            m_Target.NetworkGuns.Add(null);
        }

        DrawIsPlayingWarning();
        GUI.enabled = !Application.isPlaying;

        DrawSynchronizePositionHeader();
        DrawSynchronizePositionData();

        GUI.enabled = !Application.isPlaying;
        DrawSynchronizeRotationHeader();
        DrawSynchronizeRotationData();

        GUI.enabled = !Application.isPlaying;
        DrawSynchronizeScaleHeader();
        DrawSynchronizeScaleData();

        serializedObject.ApplyModifiedProperties();

        GUI.enabled = true;
        DrawNetworkGunsList();
        EditorGUILayout.BeginVertical("box");
        m_Target.HeatTarget        = EditorGUILayout.ObjectField("Heat Target", m_Target.HeatTarget, typeof(Transform), isProjectPrefab) as Transform;
        m_Target.GManager          = (bl_GunManager)EditorGUILayout.ObjectField("Gun Manager", m_Target.GManager, typeof(bl_GunManager), allowSceneObjects) as bl_GunManager;
        m_Target.m_PlayerAnimation = EditorGUILayout.ObjectField("Player Animation", m_Target.m_PlayerAnimation, typeof(bl_PlayerAnimations), allowSceneObjects) as bl_PlayerAnimations;
        if (GUILayout.Button("Current FPWeapon", EditorStyles.toolbarButton))
        {
            bl_GunManager gm = m_Target.transform.GetComponentInChildren <bl_GunManager>(true);
            if (Application.isPlaying)
            {
                Selection.activeObject = gm.CurrentGun;
                EditorGUIUtility.PingObject(gm.CurrentGun);
            }
            else
            {
                Selection.activeObject = gm;
                EditorGUIUtility.PingObject(gm);
            }
        }
        EditorGUILayout.EndVertical();
    }
Example #3
0
 public void Init(Transform character, Transform camera, bl_GunManager gm)
 {
     m_CharacterTargetRot = character.localRotation;
     m_CameraTargetRot    = camera.localRotation;
     GunManager           = gm;
     XSensitivity         = bl_RoomMenu.Instance.m_sensitive;
     YSensitivity         = bl_RoomMenu.Instance.m_sensitive;
 }
 /// <summary>
 ///
 /// </summary>
 protected override void Awake()
 {
     base.Awake();
     m_CharacterController = GetComponent <CharacterController>();
     KillFeed           = FindObjectOfType <bl_KillFeed>();
     GameData           = bl_GameData.Instance;
     Indicator          = GetComponent <bl_DamageIndicator>();
     PlayerSync         = GetComponent <bl_PlayerSync>();
     GunManager         = transform.GetComponentInChildren <bl_GunManager>(true);
     HealthRegeneration = GameData.HealthRegeneration;
 }
Example #5
0
 public void Init(Transform character, Transform camera, bl_RoomMenu r, bl_GunManager gm)
 {
     m_CharacterTargetRot = character.localRotation;
     m_CameraTargetRot    = camera.localRotation;
     m_Camera             = camera;
     RoomMenu             = r;
     GunManager           = gm;
     if (RoomMenu != null)
     {
         XSensitivity = RoomMenu.m_sensitive;
         YSensitivity = RoomMenu.m_sensitive;
     }
 }
    private void OnEnable()
    {
        bl_GunManager script = (bl_GunManager)target;

        AssaultAnim = new AnimBool(ShowAssault);
        AssaultAnim.valueChanged.AddListener(Repaint);
        EnginnerAnim = new AnimBool(ShowEngi);
        EnginnerAnim.valueChanged.AddListener(Repaint);
        ReconAnim = new AnimBool(ShowRecon);
        ReconAnim.valueChanged.AddListener(Repaint);
        SupportAnim = new AnimBool(ShowSupport);
        SupportAnim.valueChanged.AddListener(Repaint);
    }
Example #7
0
 /// <summary>
 ///
 /// </summary>
 private void OnEnable()
 {
     script     = (bl_NetworkGun)target;
     PSync      = script.transform.root.GetComponent <bl_PlayerSync>();
     GunManager = script.transform.root.GetComponentInChildren <bl_GunManager>(true);
     if (GunManager != null)
     {
         LocalGuns = GunManager.transform.GetComponentsInChildren <bl_Gun>(true);
         for (int i = 0; i < LocalGuns.Length; i++)
         {
             FPWeaponsAvailable.Add(LocalGuns[i].name);
         }
     }
 }
Example #8
0
    /// <summary>
    ///
    /// </summary>
    private void Start()
    {
        GameObject g = new GameObject("Recoil");

        m_Transform                = g.transform;
        m_Transform.parent         = transform.parent;
        m_Transform.localPosition  = transform.localPosition;
        m_Transform.localRotation  = transform.localRotation;
        transform.parent           = m_Transform;
        transform.localPosition    = Vector3.zero;
        transform.localEulerAngles = Vector3.zero;

        RecoilRot  = m_Transform.localEulerAngles;
        GunManager = transform.GetComponentInChildren <bl_GunManager>();
    }
 /// <summary>
 ///
 /// </summary>
 void Awake()
 {
     if (ParentGun == null)
     {
         ParentGun = transform.parent.GetComponent <bl_Gun>();
     }
     GunManager = transform.root.GetComponentInChildren <bl_GunManager>();
     GunBob     = GunManager.GetComponent <bl_GunBob>();
     m_source   = GetComponent <AudioSource>();
     if (m_source == null)
     {
         m_source             = gameObject.AddComponent <AudioSource>();
         m_source.playOnAwake = false;
     }
 }
 /// <summary>
 ///
 /// </summary>
 protected override void Awake()
 {
     base.Awake();
     m_CharacterController = GetComponent <CharacterController>();
     RoomMenu   = FindObjectOfType <bl_RoomMenu>();
     GunManager = GetComponentInChildren <bl_GunManager>();
     m_Camera   = Camera.main;
     m_OriginalCameraPosition = m_Camera.transform.localPosition;
     defaultCameraRPosition   = CameraRoot.localPosition;
     m_FovKick.Setup(m_Camera);
     m_HeadBob.Setup(m_Camera, m_StepInterval);
     m_StepCycle   = 0f;
     m_NextStep    = m_StepCycle / 2f;
     m_Jumping     = false;
     m_AudioSource = GetComponent <AudioSource>();
     m_MouseLook.Init(transform, HeatRoot, RoomMenu, GunManager);
 }
Example #11
0
    public void SetUpClasses(bl_GunManager gm)
    {
        if (AssaultClass == null)
        {
            Init();
        }

        bl_PlayerClassLoadout pcl = null;

        switch (m_Class)
        {
        case PlayerClass.Assault:
            pcl = AssaultClass;
            break;

        case PlayerClass.Recon:
            pcl = ReconClass;
            break;

        case PlayerClass.Engineer:
            pcl = EngineerClass;
            break;

        case PlayerClass.Support:
            pcl = SupportClass;
            break;
        }

        if (pcl == null)
        {
            Debug.LogError($"Player Class Loadout has not been assigned for the class {m_Class.ToString()}");
            return;
        }

        gm.PlayerEquip[0] = gm.GetGunOnListById(pcl.Primary);
        gm.PlayerEquip[1] = gm.GetGunOnListById(pcl.Secondary);
        gm.PlayerEquip[2] = gm.GetGunOnListById(pcl.Letal);
        gm.PlayerEquip[3] = gm.GetGunOnListById(pcl.Perks);
    }
Example #12
0
    /// <summary>
    ///
    /// </summary>
    protected override void Awake()
    {
        if (!photonView.IsMine)
        {
            return;
        }

        base.Awake();
        m_Transform           = transform;
        m_CharacterController = GetComponent <CharacterController>();
        GunManager            = GetComponentInChildren <bl_GunManager>();
        DamageManager         = GetComponent <bl_PlayerDamageManager>();
#if MFPSM
        Joystick = FindObjectOfType <bl_Joystick>();
#endif
        defaultCameraRPosition = CameraRoot.localPosition;
        m_Jumping            = false;
        m_AudioSource        = gameObject.AddComponent <AudioSource>();
        m_AudioSource.volume = FootStepVolume;
        m_MouseLook.Init(m_Transform, HeatRoot, GunManager);
        lastJumpTime = Time.time;
        RunFov       = 0;
    }
 private void OnEnable()
 {
     list = new ReorderableList(serializedObject, serializedObject.FindProperty(Dependency.GOListPropiertie), true, true, true, true);
     list.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) =>
     {
         var element = list.serializedProperty.GetArrayElementAtIndex(index);
         rect.y += 2;
         EditorGUI.PropertyField(new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight), element, GUIContent.none);
     };
     list.drawHeaderCallback = (Rect rect) => { EditorGUI.LabelField(rect, "On No Ammo Desactive"); };
     GameData       = bl_GameData.Instance;
     script         = (bl_Gun)target;
     playerSettings = script.transform.root.GetComponent <bl_PlayerSettings>();
     if (playerSettings != null)
     {
         AimReference = playerSettings.m_hands.AimPositionReference;
     }
     AimIcon = new GUIContent(EditorGUIUtility.IconContent("Main Light Gizmo").image);
     if (script != null)
     {
         GunManager = script.transform.parent.GetComponent <bl_GunManager>();
     }
 }
Example #14
0
 public void SetGunManager(bl_GunManager gm)
 {
     GunManager = gm;
 }
    void DrawFPWeapon()
    {
        if (subStep == 0)
        {
            GUILayout.Label("Ok, to proceed with this step lets open a new empty scene \nto make things more clear: File -> New Scene.", EditorStyles.miniLabel);
            GUILayout.Space(10);
            DrawText("Then drag one of the player prefabs to the hierarchy.");
            GUILayout.BeginHorizontal();
            GUILayout.Label("Drag: ", GUILayout.Width(50));
            if (DrawButton("Player 1"))
            {
                PlayerInstantiated = PrefabUtility.InstantiatePrefab(bl_GameData.Instance.Player1) as GameObject;
#if UNITY_2018_3_OR_NEWER
                PrefabUtility.UnpackPrefabInstance(PlayerInstantiated, PrefabUnpackMode.Completely, InteractionMode.AutomatedAction);
#endif
                Selection.activeObject = PlayerInstantiated;
                EditorGUIUtility.PingObject(PlayerInstantiated);
                subStep++;
            }
            GUILayout.Label("Or", GUILayout.Width(25));
            if (DrawButton("Player 2"))
            {
                PlayerInstantiated = PrefabUtility.InstantiatePrefab(bl_GameData.Instance.Player2) as GameObject;
#if UNITY_2018_3_OR_NEWER
                PrefabUtility.UnpackPrefabInstance(PlayerInstantiated, PrefabUnpackMode.Completely, InteractionMode.AutomatedAction);
#endif
                Selection.activeObject = PlayerInstantiated;
                EditorGUIUtility.PingObject(PlayerInstantiated);
                subStep++;
            }
            GUILayout.EndHorizontal();
        }
        else if (subStep == 1)
        {
            DrawText("Now go to where all first person weapons are, under the WeaponManager object inside of the player prefab:" +
                     " <i>Player -> Local -> Mouse -> Animations -> Main Camera -> WeaponCamera -> TilEffect -> WeaponsManager -> *</i>");
            if (DrawButton("Try open automatically"))
            {
                bl_PlayerSync player = FindObjectOfType <bl_PlayerSync>();
                if (player != null)
                {
                    bl_GunManager gm = player.transform.GetComponentInChildren <bl_GunManager>();
                    Selection.activeObject = gm;
                    EditorGUIUtility.PingObject(gm);
                    subStep++;
                }
            }
        }
        else if (subStep == 2)
        {
            DrawText("Now under 'WeaponManager' object you will have all first person weapons already set up, so for save some work we'll duplicated one of this to modify with the new weapon model," +
                     "so duplicated one that is of the same type, for example if your new weapon is a Sniper duplicated a sniper weapon.");
            DrawText("So for duplicated simply select the weapon in hierarchy -> Right Mouse Click -> Duplicate.");
            DrawImage(GetServerImage(0));
        }
        else if (subStep == 3)
        {
            DrawText("Drag your weapon model and put inside of the duplicated weapon, don't delete the actual model yet, just disable for the moment and positioned your new weapon model as you want as default position" +
                     "\n\n Then when you have it, select the root of your weapon model and go to the 'Layer' list (on top of the inspector window) and change the layer to <b>'Weapons'</b> and apply to all children.");
            DrawImage(GetServerImage(1));
        }
        else if (subStep == 4)
        {
            DrawText("Now select the top of the duplicated weapon (where bl_Gun is) and click one time in the 'FirePoint' value (not the propertie name), with this the hierarchy will foldout to where the 'FirePoint'" +
                     " and 'Muzzleflash' objects are located inside the old model, so select then (FirePoint, Muzzleflash and CartridgeEjectEffect) and put inside of your new model, positioned it correctly (FirePoint " +
                     "and Muzzleflash on the end of the weapon barrel) and then delete the old model.");
            DownArrow();
            DrawImage(GetServerImage(2));
        }
        else if (subStep == 5)
        {
            DrawText("Select the top of new weapon model where 'Animation' or 'Animator' component is attached and add the script <b>'bl_WeaponAnimation'</b> (click the inspector button 'Add Component' and write bl_WeaponAnimation and click it).");
            DownArrow();
            if (animationType == 0)
            {
                DrawText("Now select which Animation system are your weapon model using:");
                Space(5);
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Animation (Legacy)", EditorStyles.toolbarButton))
                {
                    animationType = 1;
                }
                GUILayout.Space(2);
                if (GUILayout.Button("Animator (Mecanim)", EditorStyles.toolbarButton))
                {
                    animationType = 2;
                }
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
            }
            else if (animationType == 1)
            {
                DrawText("Now in the inspector of the script you will need assign the respectively animations of the weapon model\n\n-Draw = TakeIn\n-Hide = Take Out\n-Fire Aim: this can be the same as normal fire " +
                         "animation but is recommended use a animation with low kick back movement.\n-In case that the weapon is a Shotgun or Sniper and this have a split reload animation (Start, Insert Bullet and Finish)" +
                         " Simple check the 'SplitReloadAnimation' in bl_Gun and assign the animations in bl_WeaponAnimation script." +
                         "\n\n<b>NOTE:</b> All animations that are assigned in bl_WeaponAnimation should be listed in the 'Animations' list " +
                         "of the 'Animation' Component");
                DownArrow();
                DrawImage(GetServerImage(3));
            }
            else if (animationType == 2)
            {
                DrawText("Ok, so first make sure that the Animator component doesn't have a <b>Controller</b> assigned yet, if it have, remove it.\n \n" +
                         "now in the bl_WeaponAnimation -> AnimationType, select <b>Animator</b>, then you will see some empty Animation clips fields, in these you have to assign the respectively animations of the weapon model\n\n-Draw = TakeIn\n-Hide = Take Out\n-Fire Aim: this can be the same as normal fire" +
                         " animation but is recommended use a animation with low kick back movement.\n-In case that the weapon is a Shotgun or Sniper and this have a split reload animation (Start, Insert Bullet and Finish)" +
                         " Simple check the 'SplitReloadAnimation' in bl_Gun and assign the animations in bl_WeaponAnimation script.\n \n" +
                         "when you have assigned all require animations, press the button <b>SetUp</b> -> a Window will open, select a folder in the project to save the Animator Controller.");
                Space(5);
                DrawImage(GetServerImage(23));
            }
        }
        else if (subStep == 6)
        {
            DrawText("Now some weapons packages comes with a 'Walk' and 'Run' animations, but in MFPS these movements are procedural generated (by code) so you don't need these animations," +
                     "what you need to do now is add the script <b>bl_WeaponMovement.cs</b> in the same object where add the last script bl_WeaponAnimation.");
            DownArrow();
            DrawText("Then copy the current Transform Values of the weapon model.");
            DownArrow();
            DrawImage(GetServerImage(5));
            DownArrow();
            DrawText("Now positioned <i>(move and rotate)</i> the weapon model in the editor view simulating where will be when the player is running, like this:");
            DrawImage(GetServerImage(6));
            DownArrow();
            DrawText("When you have it go to the bl_WeaponMovements inspector and click on the first button <b>Get Actual Position</b>, that will get the current transform values and copy in the " +
                     "respectively script values automatically.");
            DrawImage(GetServerImage(7));
            DrawText("Then do the same for the 'Run and Reload Position', you can use the same position as normal run, just click on the 'Get Actual Position' button.");
            DownArrow();
            DrawText("Now go again to the Transform inspector, open the Context menu and click on <b>Paste Component Values</b>, that will make the transform back to the default position.");
            DrawImage(GetServerImage(8));
        }
        else if (subStep == 7)
        {
            DrawText("Now go to the top of the new weapon where bl_Gun script is attached and in the inspector of the script start to modify the values as necessary.");
            DrawPropertieInfo("GunID", "enum", "There select the gun name that you set up before in GameData list, note that each weapon need have they own weapon info, weapons can't share the same " +
                              "GunID");
            DrawPropertieInfo("Aim Position", "Vector3", "The position where the weapon will be when player aim with this weapon, for set up this:");
            DownArrow();
            DrawImage(GetServerImage(9));
            DownArrow();
            DrawText("after click the button a 'crosshair' should active and be visible in the game view, that will do as reference of the center of the screen and store the default" +
                     " position while you get the aim position.\n\nso now positioned the weapon (the object that have bl_Gun attached)" +
                     " in the center of screen making the weapon scope/iron sight be exactly aligned with the crosshair <b>in the Game View</b>, like this:");
            DrawImage(GetServerImage(10));
            DownArrow();
            DrawText("Once you're sure that you have the right position, click again the button, and automatically will assign the Aim position and return to the default position and that's for this part.");
            DrawImage(GetServerImage(11));
            DownArrow();
            DrawPropertieInfo("Aim Smooth", "float", "the speed of the default position to the aim position transition.");
            DrawPropertieInfo("Aim Delay Movement", "float", "the amount of the delay movement effect when is aiming.");
            DrawPropertieInfo("Aim FoV", "float", "the Field Of View (Zoom) of the camera when is aiming, less value = more zooming.");
            DrawPropertieInfo("Bullet", "string", "Here you assign the name of the pooled bullet that will shoot this weapon.");
            DrawPropertieInfo("Impact Force", "int", "Force applied to rigidbody's when the bullet impact them");
            DrawPropertieInfo("Head Shake On Fire", "float", "Intensity of the random shake movement when fire.");
            DrawPropertieInfo("Recoil", "float", "'Kickback' movement amount when fire.");
            DrawPropertieInfo("Recoil Speed", "float", "Speed with which the camera will return from the kickback.");
            DrawPropertieInfo("Auto Reload", "bool", "Reload the weapon automatically when ammo = 0?");
            DrawPropertieInfo("Split Reload Animation", "bool", "Sniper/Shotgun Only, Your weapon model have the reload animation splitted (start, insert, finish)?");
            DrawPropertieInfo("Delay Fire", "float", "On grenades only, delay time to throw the projectile since input down");
            DrawPropertieInfo("Spread", "float", "the base spread of this weapon, the bullet random propagation.");
            DrawPropertieInfo("Max Spread", "float", "the max spread, cuz the spread increase while is firing");
            DrawPropertieInfo("Spread Per Second", "float", "how much increase the spread while is firing");
            DrawPropertieInfo("Decrease Spread Per Second", "float", "how much decrease the spread per second when stop firing.");
            DrawPropertieInfo("Sound Reload By Animation", "bool", "are the reload sounds play by animation key events (manual) or by time calculation (auto)?");
            DrawPropertieInfo("OnNoAmmoDesactive", "Array", "Grenade Only, Put in the list all projectile objects that is in the hands.");
            DownArrow();
            DrawText("Finally if this weapon is a Sniper, add the script bl_SniperScope.cs too, assign the scope texture and in the list 'OnScopeDisable' add all meshes of the sniper model include hands");
        }
        else if (subStep == 8)
        {
            DrawText("To finish with this, select the <b>WeaponManager</b> object and go to -> bl_GunManager -> GunList, in the list add a new field, in this new field drag the new weapon.");
            DownArrow();
            DrawImage(GetServerImage(12));
            DownArrow();
            DrawText("Now if you want assign it to as a default weapon of a player class simply (always in bl_GunManager)" +
                     "open the wanted player class section (Assault, Support, Recon or Engineer) and in the slot that you want (Primary, Secondary, Knife or Projectile) select" +
                     " the name of the weapon.");
            DownArrow();
            DrawImage(GetServerImage(13));
            DownArrow();
            DrawText("Next save/apply the changes to the player prefab (Don't delete the player from scene yet, still require for the next step)");
            DownArrow();
            DrawText("There you go!, you have added a new first person weapon.\n\nIf you wanna make it even better and show a menu where players can select their weapons load out between all your available weapons you can use <b>Class Customization</b> addon.");
            if (DrawButton("Class Customization"))
            {
                Application.OpenURL("http://www.lovattostudio.com/en/shop/addons/class-cutomization/");
            }
        }
    }
Example #16
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        bool allowSceneObjects = !EditorUtility.IsPersistent(script);

        if (script.LocalGun != null)
        {
            script.gameObject.name = bl_GameData.Instance.GetWeapon(script.LocalGun.GunID).Name;
        }

        EditorGUILayout.BeginVertical("box");
        script.LocalGun = EditorGUILayout.ObjectField("Local Weapon", script.LocalGun, typeof(bl_Gun), allowSceneObjects) as bl_Gun;
        EditorGUILayout.EndVertical();

        if (script.LocalGun != null)
        {
            if (script.LocalGun.Info.Type != GunType.Knife)
            {
                EditorGUILayout.BeginVertical("box");

                if (script.LocalGun.Info.Type == GunType.Grenade)
                {
                    script.Bullet = EditorGUILayout.ObjectField("Bullet", script.Bullet, typeof(GameObject), allowSceneObjects) as GameObject;
                }
                if (script.LocalGun.Info.Type != GunType.Grenade)
                {
                    script.MuzzleFlash = EditorGUILayout.ObjectField("MuzzleFlash", script.MuzzleFlash, typeof(ParticleSystem), allowSceneObjects) as ParticleSystem;
                }
                if (script.LocalGun.Info.Type == GunType.Grenade)
                {
                    script.DesactiveOnOffAmmo = EditorGUILayout.ObjectField("Desactive On No Ammo", script.DesactiveOnOffAmmo, typeof(GameObject), allowSceneObjects) as GameObject;
                }
                EditorGUILayout.EndVertical();
            }

            if (script.LocalGun.Info.Type != GunType.Grenade && script.LocalGun.Info.Type != GunType.Knife)
            {
                GUILayout.BeginVertical("box");
                if (script.LeftHandPosition != null)
                {
                    if (GUILayout.Button("Edit Hand Position", EditorStyles.toolbarButton))
                    {
                        OpenIKWindow(script);
                    }
                }
                else
                {
                    if (GUILayout.Button("SetUp Hand IK", EditorStyles.toolbarButton))
                    {
                        GameObject gobject = new GameObject("LeftHandPoint");
                        gobject.transform.parent           = script.transform;
                        gobject.transform.position         = bl_UtilityHelper.CalculateCenter(script.transform);
                        gobject.transform.localEulerAngles = Vector3.zero;
                        script.LeftHandPosition            = gobject.transform;
                        OpenIKWindow(script);
                    }
                }
                if (PSync != null && !PSync.NetworkGuns.Contains(script))
                {
                    if (GUILayout.Button("Enlist TPWeapon", EditorStyles.toolbarButton))
                    {
                        PSync.NetworkGuns.Add(script);
                    }
                }
                GUILayout.EndVertical();
            }
            else
            {
                if (PSync != null && !PSync.NetworkGuns.Contains(script))
                {
                    if (GUILayout.Button("Enlist TPWeapon", EditorStyles.toolbarButton))
                    {
                        PSync.NetworkGuns.Add(script);
                    }
                }
            }
        }
        else
        {
            if (GunManager != null)
            {
                GUILayout.BeginVertical("box");
                GUILayout.Label("Select the local weapon of this TPWeapon");
                GUILayout.BeginHorizontal();
                GUILayout.Label("FPWeapon:", GUILayout.Width(100));
                selectLG = EditorGUILayout.Popup(selectLG, FPWeaponsAvailable.ToArray());
                if (GUILayout.Button("Select", EditorStyles.toolbarButton, GUILayout.Width(75)))
                {
                    script.LocalGun = LocalGuns[selectLG];
                }
                GUILayout.EndHorizontal();
                GUILayout.EndVertical();
            }
            else
            {
                if (GUILayout.Button("Open FPWeapons", EditorStyles.toolbarButton))
                {
                    bl_GunManager gm = script.transform.root.GetComponentInChildren <bl_GunManager>();
                    Selection.activeObject = gm.transform.GetChild(0).gameObject;
                    EditorGUIUtility.PingObject(gm.transform.GetChild(0).gameObject);
                }
            }
        }

        serializedObject.ApplyModifiedProperties();
    }
Example #17
0
 /// <summary>
 ///
 /// </summary>
 void Awake()
 {
     GManager       = this.GetComponent <bl_GunManager>();
     AmmoTextUI     = GameObject.Find("AmmoText").GetComponent <Text>();
     weaponNameText = GameObject.Find("WeaponName (Text)").GetComponent <Text>();
 }
Example #18
0
 void Awake()
 {
     GManager = this.GetComponent<bl_GunManager>();
     AmmoTextUI = GameObject.Find("Ammo_UI").GetComponentInChildren<Text>();
 }
Example #19
0
        public void Import()
        {
            GameObject playerInstance = Player.gameObject;
            bool       isPrefab       = false;

            if (Player.gameObject.scene.name == null)
            {
                playerInstance = PrefabUtility.InstantiatePrefab(Player.gameObject, EditorSceneManager.GetActiveScene()) as GameObject;
#if UNITY_2018_3_OR_NEWER
                PrefabUtility.UnpackPrefabInstance(playerInstance, PrefabUnpackMode.Completely, InteractionMode.AutomatedAction);
#endif
                playerInstance.name = Player.gameObject.name;
                isPrefab            = true;
            }
            bl_WeaponExported we = WeaponToImport;
            if (WeaponToImport.gameObject.scene.name == null)
            {
                GameObject weo = PrefabUtility.InstantiatePrefab(WeaponToImport.gameObject, EditorSceneManager.GetActiveScene()) as GameObject;
#if UNITY_2018_3_OR_NEWER
                PrefabUtility.UnpackPrefabInstance(weo, PrefabUnpackMode.Completely, InteractionMode.AutomatedAction);
#endif
                we = weo.GetComponent <bl_WeaponExported>();
            }
            if (we.WeaponInfo != null && !string.IsNullOrEmpty(we.WeaponInfo.Name))
            {
                if (!bl_GameData.Instance.AllWeapons.Exists(x => x.Name == we.WeaponInfo.Name))
                {
                    bl_GameData.Instance.AllWeapons.Add(we.WeaponInfo);
                    we.FPWeapon.GunID = bl_GameData.Instance.AllWeapons.Count - 1;
                    EditorUtility.SetDirty(bl_GameData.Instance);
                    results[0] = 1;
                }
                else
                {
                    we.FPWeapon.GunID = bl_GameData.Instance.AllWeapons.FindIndex(x => x.Name == we.WeaponInfo.Name);
                    EditorUtility.SetDirty(bl_GameData.Instance);
                    results[0] = 2;
                }
            }
            else
            {
                results[0] = 0;
            }

            bl_GunManager gm = playerInstance.GetComponentInChildren <bl_GunManager>();
            if (gm != null)
            {
                we.FPWeapon.transform.parent        = gm.transform;
                we.FPWeapon.transform.localPosition = we.FPWPosition;
                we.FPWeapon.transform.localRotation = we.FPWRotation;
                we.FPWeapon.name = we.FPWeapon.name.Replace("[FP]", "");
                gm.AllGuns.Add(we.FPWeapon);
                results[1] = 1;
            }
            else
            {
                results[1] = 0;
            }

            if (we.TPWeapon != null)
            {
                we.TPWeapon.LocalGun                = we.FPWeapon;
                we.TPWeapon.transform.parent        = playerInstance.GetComponent <bl_PlayerSync>().NetworkGuns[0].transform.parent;
                we.TPWeapon.transform.localPosition = we.TPWPosition;
                we.TPWeapon.transform.localRotation = we.TPWRotation;
                we.TPWeapon.name = we.TPWeapon.name.Replace("[TP]", "");
                playerInstance.GetComponent <bl_PlayerSync>().NetworkGuns.Add(we.TPWeapon);
                results[2] = 1;
            }
            else
            {
                results[2] = 0;
            }

            if (isPrefab)
            {
            }
            DestroyImmediate(we.gameObject);
            EditorUtility.SetDirty(playerInstance);
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
            isDone = true;
            Repaint();
        }
    void DrawNetworkGunsList(bl_GunManager script)
    {
        GUILayout.BeginHorizontal();
        GUILayout.Label("WEAPON MANAGER", EditorStyles.toolbarButton);
        GUILayout.Space(5);
        if (GUILayout.Button(new GUIContent("IMPORT", EditorGUIUtility.IconContent("ol plus").image), EditorStyles.toolbarButton, GUILayout.Width(70)))
        {
            EditorWindow.GetWindow <bl_ImportExportWeapon>("Import", true).PrepareToImport(script.transform.root.GetComponent <bl_PlayerSync>(), null);
        }
        GUILayout.EndHorizontal();
        SerializedProperty listProperty = serializedObject.FindProperty("AllGuns");

        if (listProperty == null)
        {
            return;
        }

        float containerElementHeight = 22;
        float containerHeight        = listProperty.arraySize * containerElementHeight;

        bool isOpen = PhotonGUI.ContainerHeaderFoldout("Gun List (" + script.AllGuns.Count + ")", serializedObject.FindProperty("ObservedComponentsFoldoutOpen").boolValue);

        serializedObject.FindProperty("ObservedComponentsFoldoutOpen").boolValue = isOpen;

        if (isOpen == false)
        {
            containerHeight = 0;
        }

        Rect containerRect = PhotonGUI.ContainerBody(containerHeight);

        if (isOpen == true)
        {
            for (int i = 0; i < listProperty.arraySize; ++i)
            {
                Rect elementRect = new Rect(containerRect.xMin, containerRect.yMin + containerElementHeight * i, containerRect.width, containerElementHeight);
                {
                    Rect texturePosition = new Rect(elementRect.xMin + 6, elementRect.yMin + elementRect.height / 2f - 1, 9, 5);
                    // MFPSEditorUtils.DrawTexture(texturePosition, MFPSEditorUtils.texGrabHandle);
                    Rect propertyPosition = new Rect(elementRect.xMin + 20, elementRect.yMin + 3, elementRect.width - 45, 16);
                    EditorGUI.PropertyField(propertyPosition, listProperty.GetArrayElementAtIndex(i), new GUIContent());

                    Rect removeButtonRect = new Rect(elementRect.xMax - PhotonGUI.DefaultRemoveButtonStyle.fixedWidth,
                                                     elementRect.yMin + 2,
                                                     PhotonGUI.DefaultRemoveButtonStyle.fixedWidth,
                                                     PhotonGUI.DefaultRemoveButtonStyle.fixedHeight);

                    GUI.enabled = listProperty.arraySize > 1;
                    if (GUI.Button(removeButtonRect, new GUIContent(MFPSEditorUtils.texRemoveButton), PhotonGUI.DefaultRemoveButtonStyle))
                    {
                        listProperty.DeleteArrayElementAtIndex(i);
                    }
                    GUI.enabled = true;

                    if (i < listProperty.arraySize - 1)
                    {
                        texturePosition = new Rect(elementRect.xMin + 2, elementRect.yMax, elementRect.width - 4, 1);
                        PhotonGUI.DrawSplitter(texturePosition);
                    }
                }
            }
        }

        if (PhotonGUI.AddButton())
        {
            listProperty.InsertArrayElementAtIndex(Mathf.Max(0, listProperty.arraySize - 1));
        }

        serializedObject.ApplyModifiedProperties();
    }
Example #21
0
 void Awake()
 {
     GManager   = this.GetComponent <bl_GunManager>();
     AmmoTextUI = GameObject.Find("Ammo_UI").GetComponentInChildren <Text>();
 }
    public override void OnInspectorGUI()
    {
        serializedObject.Update();
        bl_GunManager script            = (bl_GunManager)target;
        bool          allowSceneObjects = !EditorUtility.IsPersistent(script);

        EditorGUILayout.BeginVertical("box");
        DrawNetworkGunsList(script);
        EditorGUILayout.EndVertical();

        EditorGUILayout.BeginVertical("box");
        string[] weaponList = bl_GameData.Instance.AllWeaponStringList();

        EditorGUILayout.BeginVertical("box");
        ShowAssault        = PhotonGUI.ContainerHeaderFoldout("Assault Class", ShowAssault);
        AssaultAnim.target = ShowAssault;
        if (EditorGUILayout.BeginFadeGroup(AssaultAnim.faded))
        {
            script.m_AssaultClass.primary   = EditorGUILayout.Popup("Primary", script.m_AssaultClass.primary, weaponList);
            script.m_AssaultClass.secondary = EditorGUILayout.Popup("Secondary", script.m_AssaultClass.secondary, weaponList);
            script.m_AssaultClass.Knife     = EditorGUILayout.Popup("Knife", script.m_AssaultClass.Knife, weaponList);
            script.m_AssaultClass.Special   = EditorGUILayout.Popup("Special", script.m_AssaultClass.Special, weaponList);
        }
        EditorGUILayout.EndFadeGroup();
        EditorGUILayout.EndVertical();

        EditorGUILayout.BeginVertical("box");
        ShowEngi            = PhotonGUI.ContainerHeaderFoldout("Engineer Class", ShowEngi);
        EnginnerAnim.target = ShowEngi;
        if (EditorGUILayout.BeginFadeGroup(EnginnerAnim.faded))
        {
            script.m_EngineerClass.primary   = EditorGUILayout.Popup("Primary", script.m_EngineerClass.primary, weaponList);
            script.m_EngineerClass.secondary = EditorGUILayout.Popup("Secondary", script.m_EngineerClass.secondary, weaponList);
            script.m_EngineerClass.Knife     = EditorGUILayout.Popup("Knife", script.m_EngineerClass.Knife, weaponList);
            script.m_EngineerClass.Special   = EditorGUILayout.Popup("Special", script.m_EngineerClass.Special, weaponList);
        }
        EditorGUILayout.EndFadeGroup();
        EditorGUILayout.EndVertical();

        EditorGUILayout.BeginVertical("box");
        ShowRecon        = PhotonGUI.ContainerHeaderFoldout("Recon Class", ShowRecon);
        ReconAnim.target = ShowRecon;
        if (EditorGUILayout.BeginFadeGroup(ReconAnim.faded))
        {
            script.m_ReconClass.primary   = EditorGUILayout.Popup("Primary", script.m_ReconClass.primary, weaponList);
            script.m_ReconClass.secondary = EditorGUILayout.Popup("Secondary", script.m_ReconClass.secondary, weaponList);
            script.m_ReconClass.Knife     = EditorGUILayout.Popup("Knife", script.m_ReconClass.Knife, weaponList);
            script.m_ReconClass.Special   = EditorGUILayout.Popup("Special", script.m_ReconClass.Special, weaponList);
        }
        EditorGUILayout.EndFadeGroup();
        EditorGUILayout.EndVertical();

        EditorGUILayout.BeginVertical("box");
        ShowSupport        = PhotonGUI.ContainerHeaderFoldout("Support Class", ShowSupport);
        SupportAnim.target = ShowSupport;
        if (EditorGUILayout.BeginFadeGroup(SupportAnim.faded))
        {
            script.m_SupportClass.primary   = EditorGUILayout.Popup("Primary", script.m_SupportClass.primary, weaponList);
            script.m_SupportClass.secondary = EditorGUILayout.Popup("Secondary", script.m_SupportClass.secondary, weaponList);
            script.m_SupportClass.Knife     = EditorGUILayout.Popup("Knife", script.m_SupportClass.Knife, weaponList);
            script.m_SupportClass.Special   = EditorGUILayout.Popup("Special", script.m_SupportClass.Special, weaponList);
        }
        EditorGUILayout.EndFadeGroup();
        EditorGUILayout.EndVertical();

        EditorGUILayout.EndVertical();

        GUILayout.BeginVertical("box");
        script.SwichTime  = EditorGUILayout.Slider("Switch Time", script.SwichTime, 0.1f, 5);
        script.PickUpTime = EditorGUILayout.Slider("Pick Up Time", script.PickUpTime, 0.1f, 5);
        GUILayout.EndVertical();

        GUILayout.BeginVertical("box");
        script.HeadAnimator        = EditorGUILayout.ObjectField("Head Animator", script.HeadAnimator, typeof(Animator), allowSceneObjects) as Animator;
        script.TrowPoint           = EditorGUILayout.ObjectField("Throw Point", script.TrowPoint, typeof(Transform), allowSceneObjects) as Transform;
        script.SwitchFireAudioClip = EditorGUILayout.ObjectField("Switch Fire Mode Audio", script.SwitchFireAudioClip, typeof(AudioClip), allowSceneObjects) as AudioClip;
        GUILayout.EndVertical();

        serializedObject.ApplyModifiedProperties();
    }