65 lines
1.8 KiB
C#
65 lines
1.8 KiB
C#
using System.Linq;
|
|
using Assets.PixelFantasy.Common.Scripts.CollectionScripts;
|
|
using UnityEngine;
|
|
|
|
namespace Assets.PixelFantasy.Common.Scripts.CharacterScripts
|
|
{
|
|
public abstract class CharacterBuilderBase : MonoBehaviour
|
|
{
|
|
public SpriteCollection SpriteCollection;
|
|
public string Head = "Human";
|
|
public string Ears = "Human";
|
|
public string Eyes = "Human";
|
|
public string Body = "Human";
|
|
public string Hair;
|
|
public string Armor;
|
|
public string Helmet;
|
|
public string Weapon;
|
|
public string Firearm;
|
|
public string Shield;
|
|
public string Cape;
|
|
public string Back;
|
|
public string Mask;
|
|
public string Horns;
|
|
|
|
public Texture2D Texture { get; protected set; }
|
|
|
|
public void Awake()
|
|
{
|
|
Rebuild();
|
|
}
|
|
|
|
public abstract void Rebuild(bool forceMerge = false);
|
|
|
|
public void Reset()
|
|
{
|
|
Head = Ears = Eyes = Body = Hair = Armor = Helmet = Weapon = Firearm = Shield = Cape = Back = Mask = Horns = "";
|
|
Head = "Human";
|
|
Ears = "Human";
|
|
Eyes = "Human";
|
|
Body = "Human";
|
|
|
|
Rebuild();
|
|
}
|
|
|
|
public void Randomize()
|
|
{
|
|
Eyes = Randomize("Eyes");
|
|
Helmet = Randomize("Helmet", 20);
|
|
Armor = Randomize("Armor", 20);
|
|
Weapon = Randomize("Weapon");
|
|
Shield = Randomize("Shield", 50);
|
|
|
|
Rebuild();
|
|
}
|
|
|
|
private string Randomize(string part, int emptyChance = 0)
|
|
{
|
|
var options = SpriteCollection.Layers.Single(i => i.Name == part).Textures;
|
|
|
|
if (Random.Range(0, 100) < emptyChance && Random.Range(0, options.Count + 1) == 0) return "";
|
|
|
|
return options[Random.Range(0, options.Count)].name;
|
|
}
|
|
}
|
|
} |