diff options
author | chai <215380520@qq.com> | 2023-10-27 11:05:14 +0800 |
---|---|---|
committer | chai <215380520@qq.com> | 2023-10-27 11:05:14 +0800 |
commit | 766cdff5ffa72b65d7f106658d1603f47739b2ba (patch) | |
tree | 34d7799a94dfa9be182825577583c0fa6dc935f7 /GameCode/CharacterCreator.cs |
+ init
Diffstat (limited to 'GameCode/CharacterCreator.cs')
-rw-r--r-- | GameCode/CharacterCreator.cs | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/GameCode/CharacterCreator.cs b/GameCode/CharacterCreator.cs new file mode 100644 index 0000000..55d31ed --- /dev/null +++ b/GameCode/CharacterCreator.cs @@ -0,0 +1,101 @@ +using System; +using UnityEngine; + +public class CharacterCreator : MonoBehaviour +{ + public PlayerFace currentPlayerFace; + + public GameObject objectToEnable; + + public int playerID; + + public int portraitID; + + public bool ready; + + public PlayerActions playerActions; + + public GeneralInput.InputType inputType; + + public MenuControllerHandler.MenuControl currentControl = MenuControllerHandler.MenuControl.Unassigned; + + public MenuControllerHandler.MenuControl lastControl = MenuControllerHandler.MenuControl.Unassigned; + + public Action<MenuControllerHandler.MenuControl> SwitchAction; + + public CharacterCreatorNavigation nav; + + private void Start() + { + nav = GetComponentInChildren<CharacterCreatorNavigation>(); + } + + private void Update() + { + if (currentControl != lastControl) + { + SwitchAction?.Invoke(currentControl); + } + lastControl = currentControl; + } + + public void Close() + { + CharacterCreatorHandler.instance.ReleasePortrait(portraitID); + if (playerActions == null) + { + base.gameObject.SetActive(value: false); + MainMenuHandler.instance.Open(); + } + else + { + objectToEnable.SetActive(value: true); + base.gameObject.SetActive(value: false); + } + } + + public void Finish() + { + CharacterCreatorHandler.instance.ReleasePortrait(portraitID); + CharacterCreatorHandler.instance.SetFacePreset(portraitID, currentPlayerFace); + CharacterCreatorHandler.instance.SelectFace(0, currentPlayerFace, portraitID); + if (playerActions == null) + { + base.gameObject.SetActive(value: false); + MainMenuHandler.instance.Open(); + } + else + { + objectToEnable.SetActive(value: true); + base.gameObject.SetActive(value: false); + } + } + + internal void SetOffset(Vector2 offset, CharacterItemType itemType, int slotID) + { + if (itemType == CharacterItemType.Eyes) + { + currentPlayerFace.eyeOffset = offset; + } + if (itemType == CharacterItemType.Mouth) + { + currentPlayerFace.mouthOffset = offset; + } + if (itemType == CharacterItemType.Detail) + { + if (slotID == 0) + { + currentPlayerFace.detailOffset = offset; + } + if (slotID == 1) + { + currentPlayerFace.detail2Offset = offset; + } + } + } + + internal void SpawnFace(PlayerFace currentFace) + { + GetComponentInChildren<CharacterCreatorItemEquipper>().SpawnPlayerFace(currentFace); + } +} |