I'm trying to build a dictionary for a small database of items I need in my game,the idea is the following:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class ItemClass : MonoBehaviour {
public string name;
public string description;
public int id;
public int uses;
public tk2dSpriteAnimator animations;
public tk2dSprite sprite;
public ItemClass(string name,string description,int id,int uses,tk2dSpriteAnimator animations,tk2dSprite sprite)
{
this.name = name;
this.description = description;
this.id = id;
this.uses = uses;
this.animations =animations;
this.sprite = sprite;
}
}
public class ItemsDatabase : MonoBehaviour {
public Dictionary <string,ItemClass> dictionary = new Dictionary <string, ItemClass>();
public ItemClass carraca = new ItemClass("Carraca de la Folga","Brilla como un dia festivo",0,1,null,null);
public ItemClass silbato = new ItemClass("Silbato Noctámbula del Cónclave","Un Silbato para unirlos a todos en El Pálpito",0,2,null,null);
void start ()
{
dictionary.Add(carraca.name,carraca);
dictionary.Add(silbato.name,silbato);
}
}
I want to be able to have a 2dtksprite for display on the inventory and a tk2dSpriteAnimator for when I hover start an animation, my question is how can i reference the individual sprites/animations for my ItemClass to accomplish this?,thanks in advanced.