示例#1
0
        public static void UpdateGunOffset()
        {
            if (gunOffset == -1)
            {
                GameObject              rig        = Player.FindRigManager();
                PopUpMenuView           menu       = rig.GetComponentInChildren <PopUpMenuView>();
                GameObject              spawnGun   = menu.utilityGunSpawnable.prefab;
                SpawnableMasterListData masterList = spawnGun.GetComponent <SpawnGun>().masterList;

                for (int i = 0; i < masterList.objects.Count; i++)
                {
                    if (masterList.objects[i].title == "Omni Projector")
                    {
                        gunOffset = i;
                    }
                }
            }
        }
示例#2
0
        // Constructor
        public PlayerRep(string name, SteamId steamId)
        {
            this.steamId = steamId;

            // Create this player's "Ford" to represent them, known as their rep
            GameObject ford = Instantiate(fordBundle.LoadAsset("Assets/Ford.prefab").Cast <GameObject>());

            // Makes sure that the rep isn't destroyed per level change.
            DontDestroyOnLoad(ford);

            ImpactPropertiesManager bloodManager = ford.AddComponent <ImpactPropertiesManager>();

            bloodManager.material              = ImpactPropertiesVariables.Material.Blood;
            bloodManager.modelType             = ImpactPropertiesVariables.ModelType.Skinned;
            bloodManager.MainColor             = UnityEngine.Color.red;
            bloodManager.SecondaryColor        = UnityEngine.Color.red;
            bloodManager.PenetrationResistance = 0.8f;
            bloodManager.megaPascalModifier    = 1;
            bloodManager.FireResistance        = 100;
            Collider[] colliders = ford.GetComponentsInChildren <Collider>();
            foreach (Collider c in colliders)
            {
                ImpactProperties blood = c.gameObject.AddComponent <ImpactProperties>();
                blood.material              = ImpactPropertiesVariables.Material.Blood;
                blood.modelType             = ImpactPropertiesVariables.ModelType.Skinned;
                blood.MainColor             = UnityEngine.Color.red;
                blood.SecondaryColor        = UnityEngine.Color.red;
                blood.PenetrationResistance = 0.8f;
                blood.megaPascalModifier    = 1;
                blood.FireResistance        = 100;
                blood.MyCollider            = c;
                blood.hasManager            = true;
                blood.Manager = bloodManager;
            }

            GameObject root = ford.transform.Find("Ford/Brett@neutral").gameObject; // Get the rep's head

            faceAnimator          = new FaceAnimator();
            faceAnimator.animator = root.GetComponent <Animator>();
            faceAnimator.faceTime = 10;

            Transform realRoot = root.transform.Find("SHJntGrp/MAINSHJnt/ROOTSHJnt"); // Then get the head's root joint


            // Assign targets for the IK system
            GameObject pelvisTarget = new GameObject("Pelvis");

            // Create an anchor object to hold the rep's gun
            gunRParent = new GameObject("gunRParent");
            gunRParent.transform.parent           = realRoot.Find("Spine_01SHJnt/Spine_02SHJnt/Spine_TopSHJnt/r_Arm_ClavicleSHJnt/r_AC_AuxSHJnt/r_Arm_ShoulderSHJnt/r_Arm_Elbow_CurveSHJnt/r_WristSHJnt/r_Hand_1SHJnt");
            gunRParent.transform.localPosition    = new Vector3(0.0758f, -0.0459f, -0.0837f);
            gunRParent.transform.localEulerAngles = new Vector3(2.545f, -251.689f, 149.121f);

            GameObject              rig        = Player.FindRigManager();
            PopUpMenuView           menu       = rig.GetComponentInChildren <PopUpMenuView>();
            GameObject              spawnGun   = menu.utilityGunSpawnable.prefab;
            SpawnableMasterListData masterList = spawnGun.GetComponent <SpawnGun>().masterList;

            rightGun = Instantiate(masterList.objects[BWUtil.gunOffset].prefab.transform.Find("Physics/Root/Gun").gameObject);
            rightGun.GetComponent <Rigidbody>().isKinematic = true;
            rightGun.transform.parent        = gunRParent.transform;
            rightGun.transform.localPosition = Vector3.zero;
            rightGun.transform.localRotation = Quaternion.identity;
            rightGunScript = rightGun.GetComponent <Gun>();
            rightGunScript.proxyOverride   = null;
            rightBulletObject              = rightGunScript.overrideMagazine.AmmoSlots[0];
            rightGunScript.roundsPerMinute = 20000;
            rightGunScript.roundsPerSecond = 333;
            GameObject.Destroy(rightGun.GetComponent <ConfigurableJoint>());
            GameObject.Destroy(rightGun.GetComponent <ImpactProperties>());
            GameObject.Destroy(rightGun.transform.Find("attachment_Lazer_Omni").gameObject);

            // Create an anchor object to hold the rep's gun
            gunLParent = new GameObject("gunLParent");
            gunLParent.transform.parent           = realRoot.Find("Spine_01SHJnt/Spine_02SHJnt/Spine_TopSHJnt/l_Arm_ClavicleSHJnt/l_AC_AuxSHJnt/l_Arm_ShoulderSHJnt/l_Arm_Elbow_CurveSHJnt/l_WristSHJnt/l_Hand_1SHJnt");
            gunLParent.transform.localPosition    = new Vector3(-0.0941f, 0.0452f, 0.0945f);
            gunLParent.transform.localEulerAngles = new Vector3(3.711f, -81.86301f, -157.739f);

            leftGun = Instantiate(masterList.objects[BWUtil.gunOffset].prefab.transform.Find("Physics/Root/Gun").gameObject);
            leftGun.GetComponent <Rigidbody>().isKinematic = true;
            leftGun.transform.parent        = gunLParent.transform;
            leftGun.transform.localPosition = Vector3.zero;
            leftGun.transform.localRotation = Quaternion.identity;
            leftGunScript = leftGun.GetComponent <Gun>();
            leftGunScript.proxyOverride = null;
            leftBulletObject            = leftGunScript.overrideMagazine.AmmoSlots[0];
            GameObject.Destroy(leftGun.GetComponent <ConfigurableJoint>());
            GameObject.Destroy(leftGun.transform.Find("attachment_Lazer_Omni").gameObject);
            GameObject.Destroy(leftGun.GetComponent <ImpactProperties>());

            foreach (var renderer in gunLParent.GetComponentsInChildren <Renderer>())
            {
                renderer.enabled = false;
            }

            foreach (var renderer in gunRParent.GetComponentsInChildren <Renderer>())
            {
                renderer.enabled = false;
            }

            foreach (var col in gunLParent.GetComponentsInChildren <Collider>())
            {
                Destroy(col);
            }

            foreach (var col in gunRParent.GetComponentsInChildren <Collider>())
            {
                Destroy(col);
            }

            // If for whatever reason this is needed, show or hide the rep's body and hair
            root.transform.Find("geoGrp/brett_body").GetComponent <SkinnedMeshRenderer>().enabled = showBody;
            //root.transform.Find("geoGrp/brett_hairCards").gameObject.SetActive(showHair);

            // Assign the transforms for the rep
            rigTransforms = BWUtil.GetHumanoidRigTransforms(root);

            // Grab these body parts from the rigTransforms
            head   = rigTransforms.neck.gameObject;
            handL  = rigTransforms.lWrist.gameObject;
            handR  = rigTransforms.rWrist.gameObject;
            pelvis = rigTransforms.spine1.gameObject;

            // Create the nameplate and assign values to the TMP's vars
            namePlate = new GameObject("Nameplate");
            TextMeshPro tm = namePlate.AddComponent <TextMeshPro>();

            tm.text      = name;
            tm.color     = UnityEngine.Color.green;
            tm.alignment = TextAlignmentOptions.Center;
            tm.fontSize  = 1.0f;

            // Prevents the nameplate from being destroyed during a level change
            DontDestroyOnLoad(namePlate);

            MelonCoroutines.Start(AsyncAvatarRoutine(steamId));

            // Gives certain users special appearances
            Extras.SpecialUsers.GiveUniqueAppearances(steamId, realRoot, tm);

            this.ford = ford;
        }