Beispiel #1
0
    public CharacterPresetData CreateOriginCharacterPresetFromOriginCharacterData(OriginCharacterDataSO data)
    {
        Debug.Log("CharacterPresetLibrary.CreateOriginCharacterPresetFromOriginCharacterData() called, " +
                  "building origin preset from origin data with name: " + data.characterName);

        CharacterPresetData newPreset = new CharacterPresetData();

        // Origin Data
        newPreset.characterName        = data.characterName;
        newPreset.characterDescription = data.characterDescription;
        newPreset.backgrounds.AddRange(data.characterBackgrounds);
        newPreset.modelRace = data.characterRace;

        // Combat data
        newPreset.knownAbilities       = data.knownAbilities;
        newPreset.knownRacialAbilities = data.knownRacialAbilities;
        newPreset.knownPassives        = data.knownPassives;
        newPreset.knownRacialPassives  = data.knownRacialPassives;
        newPreset.knownTalents         = data.knownTalents;
        newPreset.mhWeapon             = data.mhWeapon;
        newPreset.ohWeapon             = data.ohWeapon;

        // Model elements
        foreach (string modelElement in data.modelViewElements)
        {
            newPreset.activeModelElements.Add(new ModelElementData(modelElement));
        }

        return(newPreset);
    }
Beispiel #2
0
    public void BuildTalentTextsFromCharacterPresetData(MenuCharacter character, CharacterPresetData data)
    {
        Debug.Log("MainMenuManager.BuildAttributeTextsFromCharacterPresetData() called...");

        // disable all text first
        character.attributeOneText.gameObject.SetActive(false);
        character.attributeTwoText.gameObject.SetActive(false);
        character.attributeThreeText.gameObject.SetActive(false);

        List <TextMeshProUGUI> textViews = new List <TextMeshProUGUI>()
        {
            character.attributeOneText,
            character.attributeTwoText,
            character.attributeThreeText
        };

        int nextFreeTextIndex = 0;

        foreach (TalentPairing tp in data.knownTalents)
        {
            textViews[nextFreeTextIndex].gameObject.SetActive(true);
            textViews[nextFreeTextIndex].text = tp.talentType.ToString() + " +" + tp.talentStacks.ToString();
            nextFreeTextIndex++;
        }
    }
Beispiel #3
0
    public void BuildMyViewsFromCharacterPresetData(CharacterPresetData data)
    {
        // Set data
        SetMyCharacterData(data);

        // Set name text
        SetPresetName(data.characterName);

        // Set background texts
        MainMenuManager.Instance.BuildBackgroundTextsFromCharacterPresetData(this, data);

        // Build model
        CharacterModelController.BuildModelFromCharacterPresetData(myModel, data);

        // Set Scaling on model
        //CharacterModelController.AutoSetModelScaleFromRace(myModel);

        // Modify abilities/passives on panel
        MainMenuManager.Instance.BuildCharacterAbilityTabsFromPresetData(this, data);

        // modify attribute texts
        MainMenuManager.Instance.BuildTalentTextsFromCharacterPresetData(this, data);

        // Set Description text
        MainMenuManager.Instance.BuildDescriptionTextCharacterPresetData(this, data);

        // Build Race Tab
        MainMenuManager.Instance.BuildRaceTabFromCharacterPresetData(this, data.modelRace);

        // Build Racial Ability + Passive tabs
        MainMenuManager.Instance.BuildRacialAbilityAndPassiveTabsFromPresetData(this, data);
    }
Beispiel #4
0
    public void OnNextPresetButtonClicked()
    {
        Debug.Log("MenuCharacter.OnNextPresetButtonClicked() called...");

        // Prevent player from selecting the same origin character twice
        CharacterPresetData        nextCharacter = CharacterPresetLibrary.Instance.GetNextOriginPreset(currentCharacterPreset);
        List <CharacterPresetData> currentlySelectedCharacters = new List <CharacterPresetData>();

        foreach (MenuCharacter mc in MainMenuManager.Instance.allMenuCharacters)
        {
            currentlySelectedCharacters.Add(mc.currentCharacterPreset);
        }

        if (nextCharacter.characterName != "Random")
        {
            while (currentlySelectedCharacters.Contains(nextCharacter))
            {
                nextCharacter = CharacterPresetLibrary.Instance.GetNextOriginPreset(nextCharacter);
                if (nextCharacter.characterName == "Random")
                {
                    break;
                }
            }
        }

        BuildMyViewsFromCharacterPresetData(nextCharacter);

        // refresh button highlight
        EventSystem.current.SetSelectedGameObject(null);
    }
Beispiel #5
0
    // Character Preset Data Save + Load Logic
    public void SaveCharacterPresetDataToPersistency(CharacterPresetData charData)
    {
        Debug.Log("PersistencyManager.SaveCharacterPresetDataToPersistency() called...");

        string jsonString = ConvertObjectToJsonString(charData);

        File.WriteAllText(SAVE_FOLDER_CUSTOM_CHARACTERS + "/" + charData.characterName + ".txt", jsonString);
    }
Beispiel #6
0
    private void CreatePresetButton(CharacterPresetData data)
    {
        Debug.Log("MainMenuManager.CreatePresetButton() called for: " + data.characterName);

        LoadPresetButton newButton = Instantiate(loadPresetDataButtonPrefab, loadPresetWindowButtonParent).GetComponent <LoadPresetButton>();

        newButton.InitializeSetup(data);
        activeLoadPresetButtons.Add(newButton);
    }
Beispiel #7
0
    public void BuildDescriptionTextCharacterPresetData(MenuCharacter character, CharacterPresetData data)
    {
        Debug.Log("MainMenuManager.BuildDescriptionText() called...");

        // enable text view
        character.presetDescriptionText.gameObject.SetActive(true);

        // set text
        character.presetDescriptionText.text = data.characterDescription;
    }
Beispiel #8
0
    public void BuildCharacterAbilityTabsFromPresetData(MenuCharacter character, CharacterPresetData data)
    {
        Debug.Log("MainMenuManager.BuildCharacterAbilityTabs() called...");

        // Place all menu tabs in a list
        List <MenuAbilityTab> allTabs = new List <MenuAbilityTab>
        {
            character.tabOne,
            character.tabTwo,
            character.tabThree,
            character.tabFour
        };

        // used for placing elements sequentially
        int nextFreeIndex = 0;

        // Disable all tab views
        character.tabOne.gameObject.SetActive(false);
        character.tabTwo.gameObject.SetActive(false);
        character.tabThree.gameObject.SetActive(false);
        character.tabFour.gameObject.SetActive(false);

        // Build abilities first
        foreach (AbilityDataSO abilityData in data.knownAbilities)
        {
            // enable tab
            allTabs[nextFreeIndex].gameObject.SetActive(true);

            // build in next available slot
            allTabs[nextFreeIndex].SetUpAbilityTabAsAbility(abilityData);

            // increment next slot index
            nextFreeIndex++;
        }

        // Build passives first
        foreach (StatusPairing passiveData in data.knownPassives)
        {
            // enable tab
            allTabs[nextFreeIndex].gameObject.SetActive(true);

            // build in next available slot
            allTabs[nextFreeIndex].SetUpAbilityTabAsPassive(passiveData.statusData, passiveData.statusStacks);

            // increment next slot index
            nextFreeIndex++;
        }
    }
Beispiel #9
0
    public void BuildBackgroundTextsFromCharacterPresetData(MenuCharacter character, CharacterPresetData data)
    {
        Debug.Log("MainMenuManager.BuildBackgroundTextsFromCharacterPresetData() called...");

        // disable all text first
        character.backgroundTextOne.gameObject.SetActive(false);
        character.backgroundTextTwo.gameObject.SetActive(false);

        List <TextMeshProUGUI> textViews = new List <TextMeshProUGUI>()
        {
            character.backgroundTextOne,
            character.backgroundTextTwo
        };

        int nextFreeTextIndex = 0;

        foreach (CharacterData.Background bg in data.backgrounds)
        {
            textViews[nextFreeTextIndex].gameObject.SetActive(true);
            textViews[nextFreeTextIndex].text = bg.ToString();
            nextFreeTextIndex++;
        }
    }
Beispiel #10
0
    public CharacterPresetData GetOriginCharacterPresetByName(string characterName)
    {
        Debug.Log("CharacterPresetLibrary.GetOriginCharacterPresetByName() called, searching for: " + characterName);

        CharacterPresetData dataReturned = null;

        foreach (CharacterPresetData preset in allOriginCharacterPresets)
        {
            if (preset.characterName == characterName)
            {
                dataReturned = preset;
                break;
            }
        }

        if (dataReturned == null)
        {
            Debug.Log("CharacterPresetLibrary.GetOriginCharacterPresetByName() did not find any preset data that matches the name " +
                      characterName + ", returning null...");
        }

        return(dataReturned);
    }
Beispiel #11
0
    public CharacterPresetData GetPreviousOriginPreset(CharacterPresetData currentPreset)
    {
        Debug.Log("MainMenuManager.GetPreviousOriginPreset() called...");

        CharacterPresetData dataReturned = null;

        int currentListIndex = allOriginCharacterPresets.IndexOf(currentPreset);
        int maxCount         = allOriginCharacterPresets.Count - 1;
        int previousIndex    = 0;

        if (currentListIndex == 0)
        {
            previousIndex = maxCount;
        }
        else
        {
            previousIndex = currentListIndex - 1;
        }

        dataReturned = allOriginCharacterPresets[previousIndex];

        return(dataReturned);
    }
Beispiel #12
0
    public CharacterPresetData GetNextOriginPreset(CharacterPresetData currentPreset)
    {
        Debug.Log("MainMenuManager.GetNextOriginCharacter() called...");

        CharacterPresetData dataReturned = null;

        int currentListIndex = allOriginCharacterPresets.IndexOf(currentPreset);
        int maxCount         = allOriginCharacterPresets.Count - 1;
        int nextIndex        = 0;

        if (currentListIndex == maxCount)
        {
            nextIndex = 0;
        }
        else
        {
            nextIndex = currentListIndex + 1;
        }

        dataReturned = allOriginCharacterPresets[nextIndex];

        return(dataReturned);
    }
Beispiel #13
0
 public void SetMyCharacterData(CharacterPresetData data)
 {
     myPreset = data;
     currentCharacterPreset = data;
 }
Beispiel #14
0
 // Get + Set Char Data
 #region
 public void AddCharacterPresetToOriginList(CharacterPresetData charDataAdded)
 {
     allOriginCharacterPresets.Add(charDataAdded);
 }
Beispiel #15
0
 public void BuildRacialAbilityAndPassiveTabsFromPresetData(MenuCharacter character, CharacterPresetData data)
 {
     character.racialAbilityTab.gameObject.SetActive(false);
     character.racialPassiveTab.gameObject.SetActive(false);
     if (data.knownRacialAbilities.Count > 0)
     {
         character.racialAbilityTab.gameObject.SetActive(true);
         character.racialAbilityTab.SetUpAbilityTabAsAbility(data.knownRacialAbilities[0]);
     }
     if (data.knownRacialPassives.Count > 0)
     {
         character.racialPassiveTab.gameObject.SetActive(true);
         character.racialPassiveTab.SetUpAbilityTabAsPassive(data.knownRacialPassives[0].statusData, data.knownRacialPassives[0].statusStacks);
     }
 }
Beispiel #16
0
 public void InitializeSetup(CharacterPresetData data)
 {
     presetData          = data;
     presetNameText.text = data.characterName;
 }
Beispiel #17
0
    public void PrintPresetData(CharacterPresetData data)
    {
        Debug.Log("Printing character preset data with name: " + data.characterName);

        // Print backgrounds
        Debug.Log("Backgrounds: ");
        foreach (CharacterData.Background bg in data.backgrounds)
        {
            Debug.Log(bg.ToString());
        }

        // Print abilities
        Debug.Log("Known abilities: ");
        foreach (AbilityDataSO ability in data.knownAbilities)
        {
            Debug.Log(ability.abilityName);
        }

        // Print passives
        Debug.Log("Known passives: ");
        foreach (StatusPairing passive in data.knownPassives)
        {
            Debug.Log(passive.statusData.statusName + "(stacks = " + passive.statusStacks.ToString() + ")");
        }

        // Print racial abilities + passives
        Debug.Log("Known racial passives and abiltiies: ");
        foreach (StatusPairing passive in data.knownRacialPassives)
        {
            Debug.Log(passive.statusData.statusName + "(stacks = " + passive.statusStacks.ToString() + ")");
        }
        foreach (AbilityDataSO ability in data.knownRacialAbilities)
        {
            Debug.Log(ability.abilityName);
        }


        // Print talents
        Debug.Log("Known talents: ");
        foreach (TalentPairing tp in data.knownTalents)
        {
            Debug.Log(tp.talentType.ToString() + " +" + tp.talentStacks.ToString());
        }

        // Print weapons
        Debug.Log("Active weapons: ");
        if (data.mhWeapon)
        {
            Debug.Log("Main hand weapon: " + data.mhWeapon.Name);
        }
        if (data.ohWeapon)
        {
            Debug.Log("Off hand weapon: " + data.ohWeapon.Name);
        }

        // Print active model view elements
        Debug.Log("Active model parts: ");
        foreach (ModelElementData modelPart in data.activeModelElements)
        {
            Debug.Log(modelPart.elementName);
        }
    }