Added char create basics
This commit is contained in:
parent
d4dd41ff9b
commit
2767f3a62b
|
@ -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
|
||||||
|
}
|
|
@ -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
|
@ -1,10 +1,14 @@
|
||||||
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class JsonManager : MonoBehaviour
|
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()
|
public void LoadChar()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue