Added char create basics

This commit is contained in:
BOT Alex 2023-08-21 03:58:07 +02:00
parent d4dd41ff9b
commit 2767f3a62b
4 changed files with 2474 additions and 1 deletions

View File

@ -0,0 +1,52 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using TMPro;
using UnityEngine;
using Random = UnityEngine.Random; // WTF, C# is awesome! Fuck Python
public class CharecterCreationManager : MonoBehaviour
{
// Yes, I am using a vector to store RGB values. You can't stop me!
public Vector3 SelectedColor;
// RGB GameObjects
[SerializeField] private TMP_InputField[] RGB_GOs;
public SpriteRenderer charecterPreview;
private void OnEnable()
{
SelectedColor = new Vector3(Random.Range(0, 256), Random.Range(0, 256), Random.Range(0, 256));
for (int i = 0; i < 3; i++)
{
RGB_GOs[i].text = SelectedColor[i].ToString();
}
RerenderCharecterPreview();
}
public void TextChange(string rawType)
{
Enum.TryParse(rawType, out RGBType type); // Unity events compatible
FilterInputs(type);
SelectedColor[(int)type] = Convert.ToByte(RGB_GOs[(int)type].text);
RerenderCharecterPreview();
}
void RerenderCharecterPreview()
{
charecterPreview.color = new Color(SelectedColor.x / 255, SelectedColor.y / 255, SelectedColor.z / 255);
}
// Cry about it
public void FilterInputs(RGBType type) => RGB_GOs[(int)type].text = (Convert.ToInt16(RGB_GOs[(int)type].text) < 0) ? Math.Abs(Convert.ToInt16(RGB_GOs[(int)type].text)).ToString() : RGB_GOs[(int)type].text;
}
public enum RGBType
{
R, G, B
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9ca2b2b03406fb347a3a44658c1ba464
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +1,14 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
public class JsonManager : MonoBehaviour
{
public static string JsonDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "ZData", "SmallSchoolPlatformer");
public int Save { get; set; }
public void LoadChar()
{