예제 #1
0
    void CurrentTPVGun(bool local = false)
    {
        if (GManager == null)
        {
            return;
        }

        //Get the current gun ID local and sync with remote
        for (int i = 0; i < NetworkGuns.Count; i++)
        {
            bl_NetworkGun guns = NetworkGuns[i];
            if (guns == null)
            {
                continue;
            }

            int currentID = (local) ? GManager.GetCurrentWeapon().GunID : CurNetGun;
            if (guns.GetWeaponID == currentID)
            {
                guns.gameObject.SetActive(true);
                if (!local)
                {
                    CurrenGun = guns.gameObject.GetComponent <bl_NetworkGun>();
                    CurrenGun.SetUpType();
                }
            }
            else
            {
                if (guns != null)
                {
                    guns.gameObject.SetActive(false);
                }
            }
        }
    }
예제 #2
0
        public void PrepareToExport(bl_Gun fpweapon, bl_PlayerSync player)
        {
            FPWeapon = fpweapon;
            Player   = player;
            if (FPWeapon == null || Player == null)
            {
                return;
            }
            NetworkGun = Player.NetworkGuns.Find(x => x.LocalGun.GunID == FPWeapon.GunID);
            isExport   = true;

            minSize = new Vector2(200, 150);
            maxSize = new Vector2(250, 200);
        }
예제 #3
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);
         }
     }
 }
예제 #4
0
    void OpenIKWindow(bl_NetworkGun script)
    {
        AnimatorRunner window = (AnimatorRunner)EditorWindow.GetWindow(typeof(AnimatorRunner));

        window.Show();
        bl_PlayerSync pa   = script.transform.root.GetComponent <bl_PlayerSync>();
        Animator      anim = pa.m_PlayerAnimation.m_animator;

        pa.m_PlayerAnimation.EditorSelectedGun = script;
        bl_PlayerIK hm = pa.m_PlayerAnimation.GetComponentInChildren <bl_PlayerIK>(true);

        if (hm != null)
        {
            hm.enabled = true;
        }
        window.SetAnim(anim);
        Selection.activeObject = script.LeftHandPosition.gameObject;
    }
예제 #5
0
    void SyncCustomizer(int weaponID, string line, PhotonMessageInfo info)
    {
        if (photonView.ViewID != info.photonView.ViewID)
        {
            return;
        }

        bl_NetworkGun ng = NetworkGuns.Find(x => x.LocalGun.GunID == weaponID);

        if (ng != null)
        {
            if (ng.GetComponent <bl_CustomizerWeapon>() != null)
            {
                ng.GetComponent <bl_CustomizerWeapon>().ApplyAttachments(line);
            }
            else
            {
                Debug.LogWarning("You have not setup the attachments in the TPWeapon: " + weaponID);
            }
        }
    }
예제 #6
0
        void UpdateAttachemtns()
        {
            bl_Customizer[] all = customizerManager.transform.GetComponentsInChildren <bl_Customizer>(true);
            for (int i = 0; i < all.Length; i++)
            {
                if (all[i].WeaponID == script.WeaponID)
                {
                    _CustomizerWeapon  = all[i];
                    customizerSelected = i;
                }
            }
            int                 gunID         = script.GetComponent <bl_Gun>().GunID;
            bl_NetworkGun       ngun          = script.transform.root.GetComponentInChildren <bl_PlayerNetwork>().NetworkGuns.Find(x => x.LocalGun.GunID == gunID);
            bl_CustomizerWeapon networkScript = ngun.GetComponent <bl_CustomizerWeapon>();

            CompareLists(_CustomizerWeapon.Attachments.Foregrips, ref script.Attachments.Foregrips, ref networkScript.Attachments.Foregrips);
            CompareLists(_CustomizerWeapon.Attachments.Magazines, ref script.Attachments.Magazines, ref networkScript.Attachments.Magazines);
            CompareLists(_CustomizerWeapon.Attachments.Sights, ref script.Attachments.Sights, ref networkScript.Attachments.Sights);
            CompareLists(_CustomizerWeapon.Attachments.Suppressers, ref script.Attachments.Suppressers, ref networkScript.Attachments.Suppressers);
            EditorUtility.SetDirty(networkScript);
            EditorUtility.SetDirty(target);
        }
예제 #7
0
    /// <summary>
    ///
    /// </summary>
    void OnLocalChangeWeapon(int gunID)
    {
        if (playerViewMode == MPlayerViewMode.FirstPerson)
        {
            return;
        }
        //if the player is with hands only
        if (gunID == -1)
        {
            playerNetwork.SetWeaponBlocked(1);
            return;
        }

        playerNetwork.networkGunID = gunID;
        playerNetwork.CurrentTPVGun();
        //change the bullet origin point from FP to TP weapon
        bl_NetworkGun ng = playerNetwork.CurrenGun;

        if (ng != null && ng.MuzzleFlash != null)
        {
            playerNetwork.gunManager.CurrentGun?.OverrideMuzzlePoint(ng.MuzzleFlash.transform);
        }
    }
예제 #8
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();
        bl_NetworkGun script            = (bl_NetworkGun)target;
        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)
        {
            EditorGUILayout.BeginVertical("box");
            if (script.LocalGun.Info.Type != GunType.Knife)
            {
                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();
        }

        serializedObject.ApplyModifiedProperties();
    }
예제 #9
0
        void Transfer()
        {
            Transform  oldRig = _CustomizerWeapon.Positions.BarrelRoot.transform.parent;
            GameObject clone  = Instantiate(oldRig.gameObject) as GameObject;

            clone.name = "Attachments [FP]";
            Dictionary <string, string> paths = new Dictionary <string, string>();

            _CustomizerWeapon.Attachments.Sights.ForEach(x => { if (x.Model != null)
                                                                {
                                                                    paths.Add(x.Name, AnimationUtility.CalculateTransformPath(x.Model.transform, oldRig));
                                                                }
                                                         });
            _CustomizerWeapon.Attachments.Suppressers.ForEach(x => { if (x.Model != null)
                                                                     {
                                                                         paths.Add(x.Name, AnimationUtility.CalculateTransformPath(x.Model.transform, oldRig));
                                                                     }
                                                              });
            _CustomizerWeapon.Attachments.Magazines.ForEach(x => { if (x.Model != null)
                                                                   {
                                                                       paths.Add(x.Name, AnimationUtility.CalculateTransformPath(x.Model.transform, oldRig));
                                                                   }
                                                            });
            _CustomizerWeapon.Attachments.Foregrips.ForEach(x => { if (x.Model != null)
                                                                   {
                                                                       paths.Add(x.Name, AnimationUtility.CalculateTransformPath(x.Model.transform, oldRig));
                                                                   }
                                                            });

            clone.transform.parent           = oldRig.parent;
            clone.transform.localPosition    = oldRig.localPosition;
            clone.transform.localEulerAngles = oldRig.localEulerAngles;
            clone.transform.localScale       = oldRig.localScale;

            clone.transform.parent = _CustomizerMesh;
            Vector3[] data = new Vector3[3];
            data[0] = clone.transform.localPosition;
            data[1] = clone.transform.localEulerAngles;
            data[2] = clone.transform.localScale;

            clone.transform.parent           = _TargetMesh;
            clone.transform.localPosition    = data[0];
            clone.transform.localEulerAngles = data[1];
            clone.transform.localScale       = data[2];

            script.Attachments.Sights.ForEach(x => { if (paths.ContainsKey(x.Name))
                                                     {
                                                         x.Model = FindChild(clone, paths[x.Name]);
                                                     }
                                              });
            script.Attachments.Suppressers.ForEach(x => { if (paths.ContainsKey(x.Name))
                                                          {
                                                              x.Model = FindChild(clone, paths[x.Name]);
                                                          }
                                                   });
            script.Attachments.Foregrips.ForEach(x => { if (paths.ContainsKey(x.Name))
                                                        {
                                                            x.Model = FindChild(clone, paths[x.Name]);
                                                        }
                                                 });
            script.Attachments.Magazines.ForEach(x => { if (paths.ContainsKey(x.Name))
                                                        {
                                                            x.Model = FindChild(clone, paths[x.Name]);
                                                        }
                                                 });

            if (script.isFPWeapon)
            {
                //clone.layer = LayerMask.NameToLayer("Weapon");
                foreach (Transform t in clone.GetComponentsInChildren <Transform>(true))
                {
                    t.gameObject.layer = LayerMask.NameToLayer("Weapons");
                }
            }
            EditorUtility.SetDirty(target);

            //TP
            int           gunID = script.GetComponent <bl_Gun>().GunID;
            bl_NetworkGun ngun  = script.transform.root.GetComponentInChildren <bl_PlayerNetwork>().NetworkGuns.Find(x => {
                if (x.LocalGun == null)
                {
                    return(false);
                }
                return(x.LocalGun.GunID == gunID);
            });

            if (ngun != null)
            {
                bl_CustomizerWeapon networkCustomizer = ngun.GetComponent <bl_CustomizerWeapon>();
                if (networkCustomizer == null)
                {
                    networkCustomizer = ngun.gameObject.AddComponent <bl_CustomizerWeapon>();
                }
                networkCustomizer.isFPWeapon = false;
                networkCustomizer.WeaponID   = script.WeaponID;
                networkCustomizer.WeaponName = script.WeaponName;
                networkCustomizer.BuildAttachments();
                if (networkCustomizer.CamoRender == null)
                {
                    networkCustomizer.CamoRender = new CustomizerCamoRender();
                }
                networkCustomizer.CamoRender.MaterialID = script.CamoRender.MaterialID;

                //Transform networkTarget = ngun
                MeshFilter[] meshes        = ngun.GetComponentsInChildren <MeshFilter>();
                Mesh         mesh          = script.CamoRender.Render.GetComponent <MeshFilter>().sharedMesh;
                Transform    networkTarget = null;
                for (int i = 0; i < meshes.Length; i++)
                {
                    if (meshes[i].sharedMesh == mesh)
                    {
                        networkCustomizer.CamoRender.Render = meshes[i].GetComponent <MeshRenderer>();
                        networkTarget = networkCustomizer.CamoRender.Render.transform;
                    }
                }

                clone      = Instantiate(oldRig.gameObject) as GameObject;
                clone.name = "Attachments [TP]";

                clone.transform.parent           = networkTarget;
                clone.transform.localPosition    = data[0];
                clone.transform.localEulerAngles = data[1];
                clone.transform.localScale       = data[2];

                networkCustomizer.Attachments.Sights.ForEach(x => { if (paths.ContainsKey(x.Name))
                                                                    {
                                                                        x.Model = FindChild(clone, paths[x.Name]);
                                                                    }
                                                             });
                networkCustomizer.Attachments.Suppressers.ForEach(x => { if (paths.ContainsKey(x.Name))
                                                                         {
                                                                             x.Model = FindChild(clone, paths[x.Name]);
                                                                         }
                                                                  });
                networkCustomizer.Attachments.Foregrips.ForEach(x => { if (paths.ContainsKey(x.Name))
                                                                       {
                                                                           x.Model = FindChild(clone, paths[x.Name]);
                                                                       }
                                                                });
                networkCustomizer.Attachments.Magazines.ForEach(x => { if (paths.ContainsKey(x.Name))
                                                                       {
                                                                           x.Model = FindChild(clone, paths[x.Name]);
                                                                       }
                                                                });
                EditorUtility.SetDirty(networkCustomizer);

                Debug.Log("All done!");
            }
            else
            {
                Debug.Log("Could not find the network gun with GunID: " + gunID);
            }
            ActiveEditorTracker.sharedTracker.isLocked = false;
        }