From 766cdff5ffa72b65d7f106658d1603f47739b2ba Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Fri, 27 Oct 2023 11:05:14 +0800 Subject: + init --- GameCode/CharacterCreator.cs | 101 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 GameCode/CharacterCreator.cs (limited to 'GameCode/CharacterCreator.cs') 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 SwitchAction; + + public CharacterCreatorNavigation nav; + + private void Start() + { + nav = GetComponentInChildren(); + } + + 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().SpawnPlayerFace(currentFace); + } +} -- cgit v1.1-26-g67d0