Item Databases, Basic Combat and Learning Go
Decided I needed to learn something new again, Go was on the list and it has some nice concurrency and threading which is something I was missing with Python and is a nightmare to handle in C++ so I set about learning it. I am deciding on a project to work on, possibly a video hosting system for the site with auto upload and directory watching client. Could use it for recording dev stuff for the game prototypes I will be making going forward.
Today I added the Item Database to the Philosopher project. It's a dictionary that can lookup via string an item inside. Items are a basic class that hold information and getters and setters for whatever function the item may be used for. They have a constructor which you just pass in the information to create 'em. Pretty simple so I can just do this.
void ConstructItemDB()
{
// Constructor: string itemName, string element, int tier, int defExp, int atkExp, int elementExp, Sprite sprite
// Materials
items.Add("Ruby", new Item("Ruby", "Fire", 1, 1, 0, 1, Resources.Load<Sprite>("Items/Ruby")));
items.Add("Sapphire", new Item("Sapphire", "Water", 1, 0, 1, 1, Resources.Load<Sprite>("Items/Sapphire.png")));
items.Add("Emerald", new Item("Emerald", "Air", 1, 1, 0, 1, Resources.Load<Sprite>("Items/Emerald.png")));
items.Add("Onyx", new Item("Onyx", "Earth", 1, 1, 1, 0, Resources.Load<Sprite>("Items/Onyx.png")));
items.Add("Amethyst", new Item("Amethyst", "Lightning", 1, 1, 0, 1, Resources.Load<Sprite>("Items/Amethyst.png")));
items.Add("Iron", new Item("Iron", "Metal", 1, 1, 0, 1, Resources.Load<Sprite>("Items/Iron.png")));
// Pet creation items
items.Add("Well Used Umbrella", new Item("Well Used Umbrella", "Water", 2, 1, 0, 5, Resources.Load<Sprite>("Items/Umbrella.png")));
items.Add("Burning Heart", new Item("Burning Heart", "Fire", 2, 0, 2, 5, Resources.Load<Sprite>("Items/BurningHeart.png")));
items.Add("Catylic Wind", new Item("Catylic Wind", "Air", 2, 1, 1, 5, Resources.Load<Sprite>("Items/CatylicWind.png")));
items.Add("Mountain Soulstone", new Item("Mountain Soulstone", "Earth", 2, 2, 0, 5, Resources.Load<Sprite>("Items/MountainSoulstone.png")));
items.Add("Bottled Lightning", new Item("Bottled Lightning", "Lightning", 2, 0, 2, 5, Resources.Load<Sprite>("Items/BottledLightning.png")));
items.Add("Living Iron", new Item("Living Iron", "Metal", 2, 1, 0, 5, Resources.Load<Sprite>("Items/LivingIron.png")));
// Catalysts
items.Add("Philosopher's Stone", new Item("Philosopher's Stone", "Neutral", 5, 0, 0, 0, Resources.Load<Sprite>("Items/PhilosophersStone.png")));
}
Which lead me to writing the recipes on the Alchemy Table:
Then I got in a long embarrassing fight with Unity about Position and Rotation. We did not agree on how it would be sensibly handled. Hours were spent trying to get the bastard to do what I wanted it to and move my player damage trigger to the right place in order to figure out what enemies to apply damage to. I managed to bang on it enough and figured out I should be addressing Euler Angle as trying to address the Rotation's Quaternion directly was not allowing me to modify ANGLE so much as an arbitrary 0-1f value that unity uses to represent the angle.
Eventually I decided to just google it instead of thinking I was going mad. transform.rotation.localEulerAngle() was what I wanted. NOT transform.localRotation or transform.rotation.
I had a similar fight with the transform.position, wherein I was addressing the GLOBAL position rather than the parent-local position. It was unclear to me, as in the code I was just accessing transform.position and assigning it a Vector3. I was unaware transform.localPosition was a thing(likewise for localRotation and localEulerAngle). So that was fun. My expectation was that transform.position was local and there would be a seperate accessor for global, explicitly. Nope, global was implicit and local explicit. What a fool I was.
Anyway, after the cage match with the transform I managed to bang out combat.
Which lead to me then implementing enemies taking damage, dying, dropping items and respawning.
Hence the Emerald there.
I have a really simple damage calculation right now, which I should maybe rework when I am adding some polish.
int defenseMod = 0;
if(element == atkElement)
{
defenseMod += (elementTier * 10) / damage;
}
if (hitPoints > 0)
{
hitPoints -= (damage-(defense + defenseMod));
if (hitPoints <= 0)
{
Death(playerAttack);
}
}
It'll do for now, though.
It's nearly 8pm now so I am gonna bugger off.
Cheers.