Example #1
0
    public void AddCharacter(bool updateFields = true)
    {
        if (updateFields)
        {
            UpdateFields();
        }

        if (!cursor.characters.Contains(currentData))
        {
            cursor.characters.Add(currentData);
            var button = Instantiate(buttonPrefab, content).GetComponentInChildren <CharacterButtonScript>();
            button.character = currentData;
            button.cursor    = cursor;
            button.transform.Find("Clear").GetComponent <Button>().onClick.AddListener(new UnityEngine.Events.UnityAction(() =>
            {
                DeleteCharacter(button.character);
                Destroy(button.gameObject);
            }));
        }

        currentData           = new WorldData.CharacterData();
        currentData.partyData = new WorldData.PartyData();
        charID.text           = charName.text = charBlueprint.text = "";
        charPartyMember.isOn  = false;
        ClearFieldData();
    }
Example #2
0
    // Start is called before the first frame update

    void ClearFieldData()
    {
        currentData           = new WorldData.CharacterData();
        currentData.partyData = new WorldData.PartyData();
        reflectData();
    }
Example #3
0
 private void editCharacter(WorldData.CharacterData data)
 {
     currentData = data;
     ReflectData();
 }
Example #4
0
 public static void EditCharacter(WorldData.CharacterData data)
 {
     instance.editCharacter(data);
 }
Example #5
0
 public void AddCharacter(WorldData.CharacterData data)
 {
     currentData = data;
     AddCharacter(false);
 }
Example #6
0
 public void DeleteCharacter(WorldData.CharacterData character)
 {
     cursor.characters.Remove(character);
 }
Example #7
0
    // add/modify the selected item
    public void ParseCurrent()
    {
        switch (currentMode)
        {
        case Mode.Characters:
            WorldData.CharacterData newChar = new WorldData.CharacterData();
            newChar.ID                        = strings[0];
            newChar.name                      = strings[1];
            newChar.blueprintJSON             = strings[2];
            newChar.faction                   = ints[0];
            newChar.partyData                 = new WorldData.PartyData();
            newChar.partyData.attackDialogue  = strings[3];
            newChar.partyData.defendDialogue  = strings[4];
            newChar.partyData.collectDialogue = strings[5];
            newChar.partyData.buildDialogue   = strings[6];
            newChar.partyData.followDialogue  = strings[7];
            var existingChar = cursor.characters.Find(c => c.ID == newChar.ID);
            if (existingChar != null)
            {
                cursor.characters.Remove(existingChar);
            }

            cursor.characters.Add(newChar);
            SetupMenu();
            break;

        case Mode.Factions:
            if (ints[0] <= 2)
            {
                Debug.LogWarning("Modifying the default three factions");
                //break;
            }

            Faction newFaction = ScriptableObject.CreateInstance <Faction>();
            newFaction.ID          = ints[0];
            newFaction.factionName = strings[0];
            newFaction.color       = colors[0];
            newFaction.shinyColor  = colors[1];
            newFaction.colorName   = strings[1];
            newFaction.relations   = ints[1];
            var factionList     = new List <Faction>(manager.factions);
            var existingFaction = factionList.Find(f => f.ID == newFaction.ID);
            if (existingFaction != null)
            {
                factionList.Remove(existingFaction);
            }

            factionList.Insert(newFaction.ID, newFaction);
            manager.factions = factionList.ToArray();
            if (!File.Exists(System.IO.Path.Combine(Application.streamingAssetsPath, "ResourceDataPlaceholder.txt")))
            {
                File.Create(System.IO.Path.Combine(Application.streamingAssetsPath, "ResourceDataPlaceholder.txt"));
            }

            Directory.CreateDirectory(System.IO.Path.Combine(Application.streamingAssetsPath, "FactionPlaceholder"));
            File.WriteAllText(System.IO.Path.Combine(
                                  System.IO.Path.Combine(Application.streamingAssetsPath, "FactionPlaceholder"), $"{newFaction.factionName}.json"),
                              JsonUtility.ToJson(newFaction)
                              );
            SetupMenu();
            break;

        case Mode.Miscellaneous:
            break;
        }
    }