public static NPCDatabase Load(string path)
    {
        TextAsset     _xml       = Resources.Load <TextAsset>(path);
        XmlSerializer serializer = new XmlSerializer(typeof(NPCDatabase));
        StringReader  reader     = new StringReader(_xml.text);
        NPCDatabase   items      = serializer.Deserialize(reader) as NPCDatabase;

        reader.Close();
        return(items);
    }
Beispiel #2
0
    // Use this for initialization
    void Start()
    {
        NPCDatabase = GameObject.Find("NPCS").GetComponent <NPCDatabase>();
        controller  = GetComponent <EnemyController>();

        npc = NPCDatabase.FetchNPCByID(controller.ID);

        target = controller.Target;

        distanceFromTarget = controller.DistanceToTarget;
    }
    public NPC AddNPCEntity(NPCData data)
    {
        //NPCPrototype proto = NPCDatabase.GetNPCPrototype(data.type);
        NPCPrototype proto = NPCDatabase.GetNPCPrototype(data.type);

        NPC temp = null;

        temp = new NPC(proto);
        temp.Spawn(GetMapTilePosition(data.TilePosition));
        return(temp);
    }
Beispiel #4
0
    void CreateNPCDatabase()
    {
        Debug.Log("Creating NPC database...");

        npcDatabase = ScriptableObject.CreateInstance <NPCDatabase>();
        Debug.Log(npcDatabase);

        AssetDatabase.CreateAsset(npcDatabase, "Assets/npcdb.asset");
        AssetDatabase.SaveAssets();
        EditorUtility.FocusProjectWindow();
        Selection.activeObject = npcDatabase;
    }
Beispiel #5
0
    void LoadNPCDatabase()
    {
        npcDatabase = AssetDatabase.LoadAssetAtPath <NPCDatabase>(NPCAssetPath);

        if (npcDatabase == null)
        {
            CreateNPCDatabase();
        }
        else
        {
            EditorUtility.FocusProjectWindow();
            Selection.activeObject = npcDatabase;
        }
    }
Beispiel #6
0
    void LoadDatabase()
    {
        itemdb    = ScriptableObject.CreateInstance <ItemDatabase>();
        conddb    = ScriptableObject.CreateInstance <AuraDatabase>();
        perkdb    = ScriptableObject.CreateInstance <PerkDatabase>();
        skilldb   = ScriptableObject.CreateInstance <SkillDatabase>();
        npcdb     = ScriptableObject.CreateInstance <NPCDatabase>();
        factiondb = ScriptableObject.CreateInstance <FactionDatabase>();

        itemdb.ReloadDatabase();
        conddb.ReloadDatabase();
        perkdb.ReloadDatabase();
        skilldb.ReloadDatabase();
        npcdb.ReloadDatabase();
        factiondb.ReloadDatabase();
    }
Beispiel #7
0
    void Start()
    {
        id = 4;

        NPCDatabase = GameObject.Find("NPCS").GetComponent <NPCDatabase>();

        npc = NPCDatabase.FetchNPCByID(id);

        if (npc == null)
        {
            Destroy(gameObject);
        }

        //name = npc.Name;
        health = npc.Health;
        exp    = npc.Exp;
    }
Beispiel #8
0
    // Use this for initialization
    void Start()
    {
        /* If the NPC was already initialized, take the data from NPCDatabase. */
        if (NPCDatabase.npcObjects.ContainsKey(ID))                                         // temporary fix for unity creating another NPC on scene load.
        {                                                                                   // references the NPCDatabase NPC object for info.
            NPC originalNPC = NPCDatabase.npcObjects[ID];                                   // TODO: find a way to switch references to NPC script on the GameObject
            characterName   = originalNPC.characterName;
            characterSprite = originalNPC.characterSprite;
            dialogueSprite  = originalNPC.dialogueSprite;
            quests          = originalNPC.quests;
        }
        else
        {
            if (NPCDatabase.idToInfo.ContainsKey(ID))
            {
                string[][] info = NPCDatabase.idToInfo[ID];
                string     name = info[0][0];
                string     characterSpriteDirectory = info[1][0];
                string     dialogueSpriteDirectory  = info[2][0];

                characterName   = name;
                characterSprite = Resources.Load <Sprite>(characterSpriteDirectory);
                dialogueSprite  = Resources.Load <Sprite>(dialogueSpriteDirectory);
            }
            if (QuestDatabase.NPCIDToQuests.ContainsKey(ID))
            {
                IsQuestGiver = true;
                quests       = QuestDatabase.NPCIDToQuests[ID];                                 // TODO: decide whether you need reference or copy of the list
            }
            else
            {
                IsQuestGiver = false;
                quests       = new List <Quest>();                                              // just create an empty list of quests for no bug when checking for dialogue
            }

            /* Temporary fix, look above for info. */
            NPCDatabase.InitializeNPC(ID, this);
        }
    }
Beispiel #9
0
    // Use this for initialization
    void Start()
    {
        dataArmor  = ArmorDatabase.Load("Armors");
        dataEnemy  = EnemyDatabase.Load("Enemies");
        dataEss    = EssenceDatabase.Load("Essences");
        dataItem   = ItemDatabase.Load("Items");
        dataNpc    = NPCDatabase.Load("NPCs");
        dataPot    = PotionDatabase.Load("Potions");
        dataScroll = ScrollDatabase.Load("Scrolls");
        dataSkill  = SkillDatabase.Load("Skills");
        dataTali   = TalismanDatabase.Load("Talismans");
        dataWep    = WeaponDatabase.Load("Weapons");

        Debug.Log("Database Loaded");
        foreach (Armor arm in dataArmor.armors)
        {
            arm.found = true;
            if (arm.found)
            {
                Debug.Log("Armor 0" + arm.ID + ":" + arm.Name);
            }
        }
    }
Beispiel #10
0
    void Start()
    {
        NPCDatabase = GameObject.Find("NPCS").GetComponent <NPCDatabase>();

        npc = NPCDatabase.FetchNPCByID(id);

        if (npc == null)
        {
            Destroy(gameObject);
        }

        //name = npc.Name;
        health = npc.Health;
        exp    = npc.Exp;

        //Targets the player
        if (GameObject.FindWithTag("Player"))
        {
            target           = GameObject.FindWithTag("Player");
            targetController = (PlayerController)target.GetComponent(typeof(PlayerController));
        }

        //Die();
    }