コード例 #1
0
        public void AddSoundsToPlayers(ReplayPlaybackController replayController, Dictionary <string, ReplayAudioEventPlayer> replayEventPlayerForName)
        {
            int audioPlayersCount = MultiplayerUtils.audioPlayerNames.Count;

            for (int i = 0; i < audioPlayersCount; i++)
            {
                List <AudioOneShotEvent> currentOneShotEventList = audioOneShots[i].Count > 0 ? audioOneShots[i] : null;
                List <AudioClipEvent>    currentClipEventList    = audioClipEvents[i].Count > 0 ? audioClipEvents[i] : null;
                List <AudioVolumeEvent>  currentVolumeEventList  = audioVolumeEvents[i].Count > 0 ? audioVolumeEvents[i] : null;
                List <AudioPitchEvent>   currentPitchEventList   = audioPitchEvents[i].Count > 0 ? audioPitchEvents[i] : null;
                List <AudioCutoffEvent>  currentCutoffEventList  = audioCutoffEvents[i].Count > 0 ? audioCutoffEvents[i] : null;

                if (currentOneShotEventList != null && replayController.AudioEventPlayers[i].oneShotEvents == null)
                {
                    replayController.AudioEventPlayers[i].LoadOneShotEvents(currentOneShotEventList);
                }
                else if (currentOneShotEventList != null)
                {
                    replayController.AudioEventPlayers[i].oneShotEvents.AddRange(currentOneShotEventList);
                }

                if (currentClipEventList != null && replayController.AudioEventPlayers[i].clipEvents == null)
                {
                    replayController.AudioEventPlayers[i].LoadClipEvents(currentClipEventList);
                }
                else if (currentClipEventList != null)
                {
                    replayController.AudioEventPlayers[i].clipEvents.AddRange(currentClipEventList);
                }

                if (currentVolumeEventList != null && replayController.AudioEventPlayers[i].volumeEvents == null)
                {
                    replayController.AudioEventPlayers[i].LoadVolumeEvents(currentVolumeEventList);
                }
                else if (currentVolumeEventList != null)
                {
                    replayController.AudioEventPlayers[i].volumeEvents.AddRange(currentVolumeEventList);
                }

                if (currentPitchEventList != null && replayController.AudioEventPlayers[i].pitchEvents == null)
                {
                    replayController.AudioEventPlayers[i].LoadPitchEvents(currentPitchEventList);
                }
                else if (currentPitchEventList != null)
                {
                    replayController.AudioEventPlayers[i].pitchEvents.AddRange(currentPitchEventList);
                }

                if (currentCutoffEventList != null && replayController.AudioEventPlayers[i].cutoffEvents == null)
                {
                    replayController.AudioEventPlayers[i].LoadCutoffEvents(currentCutoffEventList);
                }
                else if (currentCutoffEventList != null)
                {
                    replayController.AudioEventPlayers[i].cutoffEvents.AddRange(currentCutoffEventList);
                }
            }
        }
コード例 #2
0
        public void ConstructFromPlayer(MultiplayerPlayerController source)
        {
            //Create a new root object for the player
            this.player = GameObject.Instantiate <GameObject>(ReplayEditor.ReplayEditorController.Instance.playbackController.gameObject);
            UnityEngine.Object.DontDestroyOnLoad(this.player);
            this.player.name = "New Player";
            this.player.transform.SetParent(null);
            this.player.transform.position = PlayerController.Instance.transform.position;
            this.player.transform.rotation = PlayerController.Instance.transform.rotation;
            debugWriter.WriteLine("Created New Player");

            this.replayController = this.player.GetComponentInChildren <ReplayPlaybackController>();

            this.bones = replayController.playbackTransforms.ToArray();

            //UnityEngine.Object.DestroyImmediate(this.player.GetComponentInChildren<ReplayEditor.ReplayPlaybackController>());

            foreach (MonoBehaviour m in this.player.GetComponentsInChildren <MonoBehaviour>())
            {
                if (m.GetType() == typeof(ReplayEditor.ReplayAudioEventPlayer))
                {
                    UnityEngine.Object.Destroy(m);
                }
            }

            this.player.SetActive(true);

            this.board = this.player.transform.Find("Skateboard").gameObject;
            this.board.transform.position = new Vector3(1111111, 111111111, 11111111);
            this.board.name = "New Player Board";

            this.skater = this.player.transform.Find("NewSkater").gameObject;
            this.skater.transform.position = new Vector3(1111111, 111111111, 11111111);
            this.skater.name = "New Player Skater";

            this.hips = this.skater.transform.Find("Skater_Joints").Find("Skater_root");

            this.skaterMeshesObject = this.skater.transform.Find("Skater").gameObject;

            debugWriter.WriteLine("created everything");

            characterCustomizer.enabled = true;
            characterCustomizer.RemoveAllGear();
            foreach (Transform t in skaterMeshesObject.GetComponentsInChildren <Transform>())
            {
                if (t.gameObject != null)
                {
                    GameObject.Destroy(t.gameObject);
                }
            }

            debugWriter.WriteLine("Removed gear");

            debugWriter.WriteLine(characterCustomizer.ClothingParent.name);
            debugWriter.WriteLine(characterCustomizer.RootBone.name);

            characterCustomizer.ClothingParent = this.hips.Find("Skater_pelvis");
            characterCustomizer.RootBone       = this.hips;
            Traverse.Create(characterCustomizer).Field("_bonesDict").SetValue(this.hips.GetComponentsInChildren <Transform>().ToDictionary((Transform t) => t.name));

            characterCustomizer.LoadCustomizations(PlayerController.Instance.characterCustomizer.CurrentCustomizations);

            debugWriter.WriteLine("Added gear back");

            bool foundHat = false, foundShirt = false, foundPants = false, foundShoes = false;

            foreach (Tuple <CharacterGear, GameObject> GearItem in gearList)
            {
                switch (GearItem.Item1.categoryName)
                {
                case "Hat":
                    hatObject = GearItem.Item2;
                    foundHat  = true;
                    break;

                case "Hoodie":
                    shirtObject = GearItem.Item2;
                    foundShirt  = true;
                    break;

                case "Shirt":
                    shirtObject = GearItem.Item2;
                    foundShirt  = true;
                    break;

                case "Pants":
                    pantsObject = GearItem.Item2;
                    foundPants  = true;
                    break;

                case "Shoes":
                    shoesObject = GearItem.Item2;
                    foundShoes  = true;
                    break;
                }
            }

            if (!foundHat)
            {
                CharacterGear newHat = CreateGear(GearCategory.Hat, "Hat", "PAX_1");
                characterCustomizer.LoadGear(newHat);
            }
            if (!foundPants)
            {
                CharacterGear newPants = CreateGear(GearCategory.Pants, "Pants", "PAX_1");
                characterCustomizer.LoadGear(newPants);
            }
            if (!foundShirt)
            {
                CharacterGear newShirt = CreateGear(GearCategory.Shirt, "Shirt", "PAX_1");
                characterCustomizer.LoadGear(newShirt);
            }
            if (!foundShoes)
            {
                CharacterGear newShoes = CreateGear(GearCategory.Shoes, "Shoes", "PAX_1");
                characterCustomizer.LoadGear(newShoes);
            }

            this.usernameObject = new GameObject("Username Object");
            this.usernameObject.transform.SetParent(this.player.transform, false);
            this.usernameObject.transform.localScale = new Vector3(-0.01f, 0.01f, 1f);
            this.usernameObject.AddComponent <MeshRenderer>();
            this.usernameObject.GetComponent <MeshRenderer>().material = Resources.FindObjectsOfTypeAll <Font>()[0].material;
            this.usernameText           = this.usernameObject.AddComponent <TextMesh>();
            this.usernameText.text      = username;
            this.usernameText.fontSize  = 256;
            this.usernameText.font      = Resources.FindObjectsOfTypeAll <Font>()[0];
            this.usernameText.color     = Color.black;
            this.usernameText.alignment = TextAlignment.Center;

            this.shirtMP = new MultiplayerTexture(this.debugWriter, MPTextureType.Shirt);
            this.pantsMP = new MultiplayerTexture(this.debugWriter, MPTextureType.Pants);
            this.hatMP   = new MultiplayerTexture(this.debugWriter, MPTextureType.Hat);
            this.shoesMP = new MultiplayerTexture(this.debugWriter, MPTextureType.Shoes);
            this.boardMP = new MultiplayerTexture(this.debugWriter, MPTextureType.Board);
        }
コード例 #3
0
        override public void ConstructPlayer()
        {
            //Create a new root object for the player
            this.player = GameObject.Instantiate <GameObject>(ReplayEditorController.Instance.playbackController.gameObject);

            UnityEngine.Object.DontDestroyOnLoad(this.player);
            this.player.name = "New Player";
            this.player.transform.SetParent(null);
            this.player.transform.position = PlayerController.Instance.transform.position;
            this.player.transform.rotation = PlayerController.Instance.transform.rotation;
            debugWriter.WriteLine("Created New Player");

            this.replayController = this.player.GetComponentInChildren <ReplayPlaybackController>();

            this.bones = replayController.playbackTransforms.ToArray();

            this.player.SetActive(true);

            this.board = this.player.transform.Find("Skateboard").gameObject;
            this.board.transform.position = new Vector3(0, 0, 0);
            this.board.name = "New Player Board";

            this.skater = this.player.transform.Find("NewSkater").gameObject;
            this.skater.transform.position = new Vector3(0, 0, 0);
            this.skater.name = "New Player Skater";

            debugWriter.WriteLine("created everything");

            Traverse.Create(characterCustomizer).Field("_bonesDict").SetValue(bones.ToDictionary((Transform t) => t.name));
            characterCustomizer.enabled = true;

            characterCustomizer.LoadLastPlayer();

            this.usernameObject = new GameObject("Username Object");
            this.usernameObject.transform.SetParent(this.player.transform, false);
            this.usernameObject.transform.localScale = new Vector3(-0.01f, 0.01f, 1f);
            this.usernameObject.AddComponent <MeshRenderer>();
            this.usernameObject.GetComponent <MeshRenderer>().material = Resources.FindObjectsOfTypeAll <Font>()[0].material;
            this.usernameText           = this.usernameObject.AddComponent <TextMesh>();
            this.usernameText.text      = username;
            this.usernameText.fontSize  = 256;
            this.usernameText.font      = Resources.FindObjectsOfTypeAll <Font>()[0];
            this.usernameText.color     = Color.black;
            this.usernameText.alignment = TextAlignment.Center;

            mainCameraTransform = Camera.main.transform;

            if (replayEventPlayerForName == null)
            {
                replayEventPlayerForName = new Dictionary <string, ReplayAudioEventPlayer>();
                for (int i = 0; i < MultiplayerUtils.audioPlayerNames.Count; i++)
                {
                    foreach (ReplayAudioEventPlayer audioPlayer in replayController.AudioEventPlayers)
                    {
                        if (audioPlayer.name.Equals(MultiplayerUtils.audioPlayerNames[i]))
                        {
                            replayEventPlayerForName.Add(MultiplayerUtils.audioPlayerNames[i], audioPlayer);
                            break;
                        }
                    }
                }
            }
        }
コード例 #4
0
        override public void ConstructPlayer()
        {
            //Create a new root object for the player
            this.player = GameObject.Instantiate <GameObject>(ReplayEditorController.Instance.playbackController.gameObject);

            UnityEngine.Object.DontDestroyOnLoad(this.player);
            this.player.name = "New Player";
            this.player.transform.SetParent(null);
            this.player.transform.position = PlayerController.Instance.transform.position;
            this.player.transform.rotation = PlayerController.Instance.transform.rotation;
            debugWriter.WriteLine("Created New Player");

            this.replayController = this.player.GetComponentInChildren <ReplayPlaybackController>();

            this.bones = replayController.playbackTransforms.ToArray();

            this.player.SetActive(true);

            this.board = this.player.transform.Find("Skateboard").gameObject;
            this.board.transform.position = new Vector3(0, 0, 0);
            this.board.name = "New Player Board";

            this.skater = this.player.transform.Find("NewSkater").gameObject;
            this.skater.transform.position = new Vector3(0, 0, 0);
            this.skater.name = "New Player Skater";

            debugWriter.WriteLine("created everything");

            Traverse.Create(characterCustomizer).Field("_bonesDict").SetValue(bones.ToDictionary((Transform t) => t.name));
            characterCustomizer.enabled = true;

            foreach (GearPrefabController gearPrefabController in this.player.GetComponentsInChildren <GearPrefabController>())
            {
                GameObject.Destroy(gearPrefabController.gameObject);
            }

            characterCustomizer.LoadLastPlayer();
            characterCustomizer.SetShoesVisible(true);

            this.usernameObject = new GameObject("Username Object");
            this.usernameObject.transform.SetParent(this.player.transform, false);
            this.usernameObject.transform.localScale = new Vector3(-0.01f, 0.01f, 1f);
            this.usernameObject.AddComponent <MeshRenderer>();
            this.usernameObject.GetComponent <MeshRenderer>().material = Resources.FindObjectsOfTypeAll <Font>()[0].material;
            this.usernameText           = this.usernameObject.AddComponent <TextMesh>();
            this.usernameText.text      = username;
            this.usernameText.fontSize  = 256;
            this.usernameText.font      = Resources.FindObjectsOfTypeAll <Font>()[0];
            this.usernameText.color     = Color.black;
            this.usernameText.alignment = TextAlignment.Center;

            this.shirtMPTex = new MultiplayerRemoteTexture(MPTextureType.Shirt, this.debugWriter);
            this.pantsMPTex = new MultiplayerRemoteTexture(MPTextureType.Pants, this.debugWriter);
            this.hatMPTex   = new MultiplayerRemoteTexture(MPTextureType.Hat, this.debugWriter);
            this.shoesMPTex = new MultiplayerRemoteTexture(MPTextureType.Shoes, this.debugWriter);

            this.deckMPTex  = new MultiplayerRemoteTexture(MPTextureType.Deck, this.debugWriter);
            this.gripMPTex  = new MultiplayerRemoteTexture(MPTextureType.Grip, this.debugWriter);
            this.wheelMPTex = new MultiplayerRemoteTexture(MPTextureType.Wheels, this.debugWriter);
            this.truckMPTex = new MultiplayerRemoteTexture(MPTextureType.Trucks, this.debugWriter);

            this.headMPTex = new MultiplayerRemoteTexture(MPTextureType.Head, this.debugWriter);
            this.bodyMPTex = new MultiplayerRemoteTexture(MPTextureType.Body, this.debugWriter);
        }