Пример #1
0
 public PerformActionDataModel()
 {
     m_ActionID           = ActionData.ACTION_LIST_ID.NONE;
     m_ActionTargetAmount = GenericActionModel.ACTION_TARGET_AMOUNT.NO_TARGETS;
     m_AttackerData       = null;
     m_DefenderData       = null;
 }
Пример #2
0
 public void AddActionIDToUsableActionList(ActionData.ACTION_LIST_ID aActionID)
 {
     if (!DoesActionExistInList(aActionID))
     {
         m_ActionList.Add(aActionID);
     }
     //else, do something else possibly...?
 }
Пример #3
0
 public PerformActionDataModel(ActionData.ACTION_LIST_ID aActionID,
                               GenericActionModel.ACTION_TARGET_AMOUNT aTargetAmount,
                               GenericCharacter aAttacker)
 {
     m_ActionID           = aActionID;
     m_ActionTargetAmount = aTargetAmount;
     m_AttackerData       = aAttacker;
     m_DefenderData       = aAttacker;
 }
    public void OnActionSelected()
    {
        if (m_UserSelectedButton > -1 && m_UserSelectedButton < 5)
        {
            ActionData.ACTION_LIST_ID actionID = m_Model.GetListOfActions()[m_Model.GetCurrentIndex() + m_UserSelectedButton];

            Debug.Log("Action Selected with the ID: " + actionID + " Button No: " + m_UserSelectedButton + " With current list index: " + m_Model.GetCurrentIndex());

            GameManager.GetCombatManager.OnActionSelected(actionID);
        }

        m_UserSelectedButton = -1;
    }
Пример #5
0
    public bool DoesActionExistInList(ActionData.ACTION_LIST_ID aActionID)
    {
        bool bExists = false;

        for (int i = 0; i < m_ActionList.Count; i++)
        {
            if (m_ActionList[i] == aActionID)
            {
                Debug.Log("Action ID " + aActionID + " already exists for this character: " + m_CharacterName);
                bExists = true;
                break;
            }
        }

        return(bExists);
    }
Пример #6
0
    public PerformActionDataModel CreatePerformActionDataModel(ActionData.ACTION_LIST_ID aActionID)
    {
        GenericActionModel     actionModel     = ActionData.ABILITY_DICTIONARY[aActionID];
        PerformActionDataModel actionDataModel = null;

        switch (actionModel.GetActionTargetAmount())
        {
        case GenericActionModel.ACTION_TARGET_AMOUNT.ALL_TARGETS:
            actionDataModel = new PerformActionDataModel(aActionID, GenericActionModel.ACTION_TARGET_AMOUNT.ALL_TARGETS, GetComponentInParent <GenericCharacterController>().GetCharacterStats());
            break;

        case GenericActionModel.ACTION_TARGET_AMOUNT.MULTI_TARGET_DEFENSIVE:
            actionDataModel = new PerformActionDataModel(aActionID, GenericActionModel.ACTION_TARGET_AMOUNT.MULTI_TARGET_DEFENSIVE, GetComponentInParent <GenericCharacterController>().GetCharacterStats());
            break;

        case GenericActionModel.ACTION_TARGET_AMOUNT.MULTI_TARGET_OFFENSIVE:
            actionDataModel = new PerformActionDataModel(aActionID, GenericActionModel.ACTION_TARGET_AMOUNT.MULTI_TARGET_OFFENSIVE, GetComponentInParent <GenericCharacterController>().GetCharacterStats());
            break;

        case GenericActionModel.ACTION_TARGET_AMOUNT.SINGLE_TARGET:
            GenericCharacter defender;

            if (actionModel.GetActionOffOrDef() == GenericActionModel.ACTION_OFF_OR_DEF.DEFENSIVE)
            {
                defender = GetRandomNonPlayerCharacter();
            }
            else
            {
                defender = GetRandomPlayerCharacter();
            }

            actionDataModel = new PerformActionDataModel(aActionID, GenericActionModel.ACTION_TARGET_AMOUNT.SINGLE_TARGET, GetComponentInParent <GenericCharacterController>().GetCharacterStats(), defender);
            break;

        case GenericActionModel.ACTION_TARGET_AMOUNT.NO_TARGETS:
        default:
            Debug.Log("ERROR: Tried to create an action model through the AI component but the target type is none or null.");
            break;
        }

        return(actionDataModel);
    }
Пример #7
0
    public void InitCharacterWithJSON(string aJSONFilePath)
    {
        TextAsset file          = Resources.Load(aJSONFilePath) as TextAsset;
        JSONNode  characterJSON = JSON.Parse(file.ToString());

        Debug.Log(characterJSON);

        if (m_CharacterStats == null)
        {
            m_CharacterStats = new GenericCharacter();
        }

        m_CharacterStats.SetIsPlayerControlled(characterJSON["isPlayerControlled"]);
        m_CharacterStats.SetIsCharacterDead(characterJSON["isCharacterDead"]);
        m_CharacterStats.SetCharacterHasMana(characterJSON["doesCharacterHaveMana"]);
        m_CharacterStats.SetCharacterName(characterJSON["characterName"]);
        m_CharacterStats.SetSpriteFilePath(characterJSON["spriteFilePath"]);
        m_CharacterStats.SetSpriteFileName(characterJSON["spriteName"]);
        m_CharacterStats.SetCharacterHealth(characterJSON["characterStats"]["maxHealth"]);
        m_CharacterStats.SetCurrentHealth(characterJSON["characterStats"]["currentHealth"]);
        m_CharacterStats.SetShield(characterJSON["characterStats"]["shield"]);
        m_CharacterStats.SetStrength(characterJSON["characterStats"]["strength"]);
        m_CharacterStats.SetSpellPower(characterJSON["characterStats"]["spellPower"]);

        if (characterJSON["actionListIDs"].IsArray)
        {
            for (int i = 0; i < characterJSON["actionListIDs"].AsArray.Count; i++)
            {
                //TODO: Check if ability is in the dictionary first before trying to add to character
                //NOTE: I might already be doing that in another function that gets called when I add it.
                //What in the C# wizardy f**k is this
                ActionData.ACTION_LIST_ID action = (ActionData.ACTION_LIST_ID)System.Enum.Parse(typeof(ActionData.ACTION_LIST_ID), characterJSON["actionListIDs"][i]);

                m_CharacterStats.AddActionIDToUsableActionList(action);
            }
        }

        //Oh god here we go again with the magic
        m_CharacterStats.AddEquipmentToCharacter(
            (ItemData.ITEM_ID)System.Enum.Parse(typeof(ItemData.ITEM_ID), characterJSON["equipmentSlots"]["chest"])
            );
        m_CharacterStats.AddEquipmentToCharacter(
            (ItemData.ITEM_ID)System.Enum.Parse(typeof(ItemData.ITEM_ID), characterJSON["equipmentSlots"]["helm"])
            );
        m_CharacterStats.AddEquipmentToCharacter(
            (ItemData.ITEM_ID)System.Enum.Parse(typeof(ItemData.ITEM_ID), characterJSON["equipmentSlots"]["weapon"])
            );
        m_CharacterStats.AddEquipmentToCharacter(
            (ItemData.ITEM_ID)System.Enum.Parse(typeof(ItemData.ITEM_ID), characterJSON["equipmentSlots"]["ring"])
            );

        //Unload this somewhere....? at some point in time? Not sure where, but somewhere...

        string spritePath = m_CharacterStats.GetSpriteFilePath() + "/" + m_CharacterStats.GetSpriteFileName();

        m_SpriteRenderer.sprite = Resources.Load <Sprite>(spritePath);

        Resources.UnloadAsset(file);

        GameManager.GetPlayerManager.AddCharacterToList(m_CharacterStats);
    }
Пример #8
0
 public void OnActionSelected(ActionData.ACTION_LIST_ID aActionID)
 {
     m_CurrentSelectedAction = aActionID;
 }
Пример #9
0
    public void OnCharacterSelected(GenericCharacter aGenericCharacter)
    {
        if (m_CombatState == COMBAT_STATE.PLAYER_TURN)
        {
            //If it is the players turn, and we are selecting a player party member
            if (aGenericCharacter.IsPlayerControlled())
            {
                //Do we have something selected already and is it not equal to the new selection?
                if (m_CurrentSelectedCharacter != aGenericCharacter)
                {
                    //If we don't have a selected action and are just swapping characters
                    if (m_CurrentSelectedAction == ActionData.ACTION_LIST_ID.NONE)
                    {
                        m_CurrentSelectedCharacter = aGenericCharacter;

                        m_CombatUIController.GetInterfaceModel().UpdateListOfActions();
                    }
                    else
                    {
                        //If we have an action and users selected...
                        //Create perform action data and send it to be used
                        //If it's single target, do this, else, the rest will be automatically sorted
                        if (ActionData.ABILITY_DICTIONARY[m_CurrentSelectedAction].GetActionTargetAmount() == GenericActionModel.ACTION_TARGET_AMOUNT.SINGLE_TARGET)
                        {
                            PerformActionDataModel performActionDataModel = new PerformActionDataModel(m_CurrentSelectedAction, GenericActionModel.ACTION_TARGET_AMOUNT.SINGLE_TARGET,
                                                                                                       m_CurrentSelectedCharacter, aGenericCharacter);

                            m_ActionController.PerformAction(performActionDataModel);
                        }
                        else if (ActionData.ABILITY_DICTIONARY[m_CurrentSelectedAction].GetActionTargetAmount() == GenericActionModel.ACTION_TARGET_AMOUNT.MULTI_TARGET_DEFENSIVE)
                        {
                            PerformActionDataModel performActionDataModel = new PerformActionDataModel(m_CurrentSelectedAction, GenericActionModel.ACTION_TARGET_AMOUNT.MULTI_TARGET_DEFENSIVE,
                                                                                                       m_CurrentSelectedCharacter);
                            m_ActionController.PerformAction(performActionDataModel);
                        }
                        else
                        {
                            //Won't attack everyone on your team, perhaps change this?
                            if (ActionData.ABILITY_DICTIONARY[m_CurrentSelectedAction].GetActionTargetAmount() == GenericActionModel.ACTION_TARGET_AMOUNT.MULTI_TARGET_OFFENSIVE &&
                                !aGenericCharacter.IsPlayerControlled())
                            {
                                PerformActionDataModel performActionDataModel = new PerformActionDataModel(m_CurrentSelectedAction, ActionData.ABILITY_DICTIONARY[m_CurrentSelectedAction].GetActionTargetAmount(),
                                                                                                           m_CurrentSelectedCharacter);
                            }
                            else
                            {
                                Debug.Log("Can't offensive on teammates");
                            }
                        }


                        m_CurrentSelectedAction = ActionData.ACTION_LIST_ID.NONE;

                        //TODO: Clean this up
                        m_CombatUIController.SetAllUIInactive();
                        m_CombatUIController.SetEndTurnUIActive();
                        m_CombatUIController.SetMainSelectionState();
                    }
                }
            }
            //If it's the player turn, and we are selecting an enemy
            else
            {
                if (m_CurrentSelectedCharacter != null)
                {
                    if (m_CurrentSelectedCharacter != aGenericCharacter)
                    {
                        //If we don't have something selected
                        if (m_CurrentSelectedAction == ActionData.ACTION_LIST_ID.NONE)
                        {
                            //do nothing I guess...?
                        }
                        else
                        {
                            if (ActionData.ABILITY_DICTIONARY[m_CurrentSelectedAction].GetActionTargetAmount() == GenericActionModel.ACTION_TARGET_AMOUNT.SINGLE_TARGET)
                            {
                                PerformActionDataModel performActionDataModel = new PerformActionDataModel(m_CurrentSelectedAction, ActionData.ABILITY_DICTIONARY[m_CurrentSelectedAction].GetActionTargetAmount(),
                                                                                                           m_CurrentSelectedCharacter, aGenericCharacter);
                                m_ActionController.PerformAction(performActionDataModel);
                            }
                            else
                            {
                                if (ActionData.ABILITY_DICTIONARY[m_CurrentSelectedAction].GetActionTargetAmount() == GenericActionModel.ACTION_TARGET_AMOUNT.MULTI_TARGET_OFFENSIVE)
                                {
                                    PerformActionDataModel performActionDataModel = new PerformActionDataModel(m_CurrentSelectedAction, ActionData.ABILITY_DICTIONARY[m_CurrentSelectedAction].GetActionTargetAmount(),
                                                                                                               m_CurrentSelectedCharacter);

                                    m_ActionController.PerformAction(performActionDataModel);
                                }
                                else
                                {
                                    Debug.Log("Can't use defensive on enemies.");
                                }
                            }


                            m_CurrentSelectedAction = ActionData.ACTION_LIST_ID.NONE;

                            //TODO: Clean this up
                            m_CombatUIController.SetAllUIInactive();
                            m_CombatUIController.SetEndTurnUIActive();
                            m_CombatUIController.SetMainSelectionState();
                        }
                    }
                }
            }
        }
    }
Пример #10
0
 public void SetActionID(ActionData.ACTION_LIST_ID aActionID)
 {
     m_ActionID = aActionID;
 }
Пример #11
0
 public virtual void DecideActionToUseAlgorithm()
 {
     m_CurrentSelectedActionID = ActionData.ACTION_LIST_ID.NONE;
 }
Пример #12
0
 public void UseCurrentAction(ActionData.ACTION_LIST_ID aActionID)
 {
 }