Пример #1
0
 void Awake()
 {
     m_TurnManager = GameObject.FindGameObjectWithTag(Tags.BATTLE_CONTROLLER).GetComponent<PCTurnManagerComponent>();
     m_Transform = GetComponent<RectTransform>();
     m_CurrentEntity = null;
     m_CurrentDecisionState = PCTurnManagerComponent.DecisionState.IDLE;
 }
Пример #2
0
 void OnGUI()
 {
     PCBattleEntity entity = m_TurnManager.currentEntity;
     PCTurnManagerComponent.DecisionState decisionState = m_TurnManager.decisionState;
     if (m_CurrentEntity != entity || m_CurrentDecisionState != decisionState) {
         m_CurrentEntity = entity;
         m_CurrentDecisionState = decisionState;
         PopulateActions (entity, decisionState);
     }
 }
Пример #3
0
    void PopulateActions(PCBattleEntity entity, PCTurnManagerComponent.DecisionState state)
    {
        // destroy old buttons
        while (m_Transform.childCount > 0) {
            Transform transform = m_Transform.GetChild(0);
            transform.SetParent(null);
            GameObject.Destroy(transform.gameObject);
        }

        if (entity == null) {
            return;
        }

        foreach (ICombatSkill skill in entity.SkillSet.skills) {
            GameObject actionPrefabInstance = (GameObject)Instantiate(m_ActionPrefab);
            RectTransform rect = actionPrefabInstance.GetComponent<RectTransform>();
            ActionGUIComponent actionGUI = actionPrefabInstance.GetComponent<ActionGUIComponent>();
            actionGUI.CombatSkill = skill;
            rect.SetParent(m_Transform);
        }
    }
Пример #4
0
    void PopulateTargets(PCBattleEntity entity, PCTurnManagerComponent.DecisionState state)
    {
        // destroy old buttons
        while (m_Transform.childCount > 0) {
            Transform transform = m_Transform.GetChild(0);
            transform.SetParent(null);
            GameObject.Destroy(transform.gameObject);
        }

        if (entity == null || state != PCTurnManagerComponent.DecisionState.TARGET) {
            return;
        }

        List<SelectableTarget> selectableTargets = m_TurnManager.currentTargetManager.targetList;
        foreach (SelectableTarget selectableTarget in selectableTargets) {
            GameObject actionPrefabInstance = (GameObject)Instantiate(m_TargetPrefab);
            RectTransform rect = actionPrefabInstance.GetComponent<RectTransform>();
            TargetGUIComponent targetGUI = actionPrefabInstance.GetComponent<TargetGUIComponent>();
            targetGUI.SelectableTarget = selectableTarget;
            rect.SetParent(m_Transform);
        }
    }
    private void LoadCharacters(Character[] pcChars, Character[] enemyChars)
    {
        // combine
        mAllEntities = new BattleEntity[pcChars.Length + enemyChars.Length];
        mPcEntities = new PCBattleEntity[pcChars.Length];
        mEnemyEntities = new EnemyBattleEntity[enemyChars.Length];

        for(int i=0; i < mPcEntities.Length; i++) {
            if (pcChars[i] is PCCharacter) {
                mPcEntities[i] = new PCBattleEntity((PCCharacter)pcChars[i], this);
                mAllEntities[i] = mPcEntities[i];
            }
        }

        for(int i=0; i < mEnemyEntities.Length; i++) {
            if (enemyChars[i] is EnemyCharacter) {
                mEnemyEntities[i] = new EnemyBattleEntity((EnemyCharacter)enemyChars[i], this);
                mAllEntities[pcChars.Length + i] = mEnemyEntities[i];
            }
        }
        // create row specifics
        BuildRowEntities();
    }
Пример #6
0
 public MoveEvent(PCBattleEntity srcEntity, PCCharacter.RowPosition srcRow, PCCharacter.RowPosition destRow)
 {
     this.mSrcEntity = srcEntity;
     this.mSrcRow = srcRow;
     this.mDestRow = destRow;
 }
Пример #7
0
 /// <summary>
 /// Queues the PC into the turn list.
 /// </summary>
 /// <param name="pc">Pc.</param>
 public void QueuePC(PCBattleEntity pc)
 {
     bool isNewPC = (mTurnQueue.Count == 0);
     mTurnQueue.Enqueue(pc);
     // if we see we are the added new pc, lets make sure we are in
     // the correct decision state
     if(isNewPC) {
         decisionState = DecisionState.SKILL;
         currentSelectedSkill = null;
     }
 }
Пример #8
0
    private static void PopulateSelfRowTargets(List<SelectableTarget> entityList, 
	                                                  HashSet<BattleEntity> entitySet,
	                                                  PCBattleEntity sourceEntity)
    {
        SelectableTarget rowTarget = new SelectableTarget(ROW_CURRENT_NAME, new List<BattleEntity>(), ResolvedTargetEnum.SELF_ROW);
        PCCharacter.RowPosition rowPos = sourceEntity.pcCharacter.rowPosition;
        foreach(BattleEntity entity in entitySet) {
            if(entity.isPC && ((PCBattleEntity)entity).pcCharacter.rowPosition == rowPos) {
                rowTarget.entities.Add(entity);
            }
        }

        if(rowTarget.entities.Count > 0) {
            entityList.Add(rowTarget);
        }
    }
Пример #9
0
    /// <summary>
    /// Populates the selectable targets.
    /// </summary>
    /// <param name="entityList">Entity list.</param>
    /// <param name="origin">Origin.</param>
    /// <param name="entitySet">Entity set.</param>
    /// <param name="skill">Skill.</param>
    private static void PopulateSelectableTargets(List<SelectableTarget> entityList, 
	                                              PCBattleEntity origin, 
	                                              HashSet<BattleEntity> entitySet, 
	                                              ICombatSkill skill)
    {
        switch(skill.TargetRule.primaryTargetType) {
        case TargetingType.ALL:
            PopulateAllTargets(entityList, entitySet);
            break;
        case TargetingType.ROW:
            PopulateRowTargets(entityList, entitySet);
            break;
        case TargetingType.SELF:
            PopulateSelfTargets(entityList, entitySet, origin);
            break;
        case TargetingType.SELF_ROW:
            PopulateSelfRowTargets(entityList, entitySet, origin);
            break;
        case TargetingType.SINGLE:
            PopulateSingleTargets(entityList, entitySet);
            break;
        }
    }
Пример #10
0
 public PCMoveOperation(PCBattleEntity srcEntity, PCCharacter.RowPosition destRow)
 {
     this.mSrcEntity = srcEntity;
     this.mSrcRow = srcEntity.pcCharacter.rowPosition;
     this.mDestRow = destRow;
 }