// Called from playerScript when player chose his/her command
    public void StartThisTurnProgression()
    {
        // RNG a command for enemy
        enemyObjectScript.PickingEnemyCommand();

        // Bind the command chosen and start to initiate this round's combat
        enemyCommand  = enemyObjectScript.GetChosenEnemyCommand();
        playerCommand = playerObjectScript.GetPlayerChosenCommand();
        myCombatUIManager.ThisTurnCombatCommandResult(playerCommand, enemyCommand);

        myCombatUIManager.PreCombatUIProcedure();

        // Activate all Pre-Combat abilities (Faster unit activates first)
        int playerSpeed = playerChar.GetThisCharSpeed();
        int enemySpeed  = enemyChar.GetThisCharSpeed();

        if (playerSpeed >= enemySpeed)
        {
            PreCombatEndCombatSkillActivation(playerChar, 0, ActivationTime.beforeCombat);
        }
        else
        {
            PreCombatEndCombatSkillActivation(enemyChar, 0, ActivationTime.beforeCombat);
        }
    }
    IEnumerator BattleOutcome(Character attackingChar, CombatCommand attackingCommand, Character targetChar, CombatCommand targetCommand, int damage)
    {
        attackingChar.AttackAnimation();
        yield return(new WaitForSeconds(ATTACK_ANIMATION_DAMAGE_DELAY));

        attackingChar.PlayAttackSFX();
        targetChar.ThisCharacterTakingDamage(damage);
        myCombatUIManager.DisplayDuringCombatText(attackingChar.gameObject, attackingCommand, targetCommand);
    }
    public void SendCommand(GameConst.CommandType cmdType, Int32 playerId, IMessage parm)
    {
        var cmd = new CombatCommand
        {
            Id   = (Int32)cmdType,
            Parm = parm.ToByteString(),
        };

        NetManager.Send((Int16)ProtocType.CombatCommand, cmd);
    }
        private void AddCombatCommand(Socket cfd, CombatCommand combatCommand)
        {
            var room = this.GetPlayerRoom(cfd);

            if (room == null)
            {
                return;
            }
            room.AddCommand(cfd, combatCommand.Id, combatCommand.Parm);
        }
    // -Public API-

    // Map the event type and input data to a CombatCommand
    public CombatCommand Map(InputEventType eventType)
    {
        CombatCommand command = CombatCommand.None;

        if (m_CombatMap.ContainsKey(eventType))
        {
            command = m_CombatMap[eventType];
        }

        return(command);
    }
Example #6
0
    public void Write(CombatCommand command)
    {
        // If we've reached that maximum size, shift the beginning index
        // If we've already shifted the begin index, shift it nonetheless
        if (m_BeginIndex == 0 && m_EndIndex >= m_Commands.Count || m_BeginIndex != 0)
        {
            m_BeginIndex = (m_BeginIndex + 1) % m_Commands.Count;

            // We don't need to add again, we've already added
            m_EndIndex = m_EndIndex % m_Commands.Count;
        }

        m_Commands[m_EndIndex] = command;

        m_EndIndex++;
    }
    private void OnInputReceived(InputEventType eventType)
    {
        if (m_Controller == null)
        {
            return;
        }
        if (m_Converter == null)
        {
            UnityEngine.Debug.LogWarning("No converter map bound to the CombatInputConverter!");
            return;
        }

        CombatCommand command = m_Converter.Map(eventType);

        m_Controller.ReceiveCommand(command);
    }
Example #8
0
    public CombatConverterMap ToConverterMap()
    {
        CombatConverterMap converter = new CombatConverterMap();

        Dictionary <InputEventType, CombatCommand> converterMap = new Dictionary <InputEventType, CombatCommand>();

        foreach (InputPairConfig config in m_InputMap)
        {
            InputEventType inputEvent    = (InputEventType)Enum.Parse(typeof(InputEventType), config.m_InputKey);
            CombatCommand  combatCommand = (CombatCommand)Enum.Parse(typeof(CombatCommand), config.m_CombatCommand);

            converterMap.Add(inputEvent, combatCommand);
        }
        converter.SetCombatMap(converterMap);

        return(converter);
    }
Example #9
0
    public void PickingEnemyCommand()
    {
        int generateNumber = Random.Range(1, 300);

        if (generateNumber % 3 == 0)
        {
            chosenEnemyCommand = CombatCommand.attack;
        }
        else if (generateNumber % 3 == 1)
        {
            chosenEnemyCommand = CombatCommand.powerAttack;
        }
        else
        {
            chosenEnemyCommand = CombatCommand.guard;
        }
    }
Example #10
0
    // END : Pre-Combat



    // START : During Combat
    // Displaying combat outcome based on turn
    public void DisplayDuringCombatText(GameObject unitTurn, CombatCommand turnUnitCommand, CombatCommand targetCommand)
    {
        int    targetSufferedDamage = -1;
        string thisUnitTurnName     = "Dummy";
        string targetName           = "Dummy2";

        if (unitTurn == playerChar.gameObject)
        {
            thisUnitTurnName     = "Player";
            targetName           = "Enemy";
            targetSufferedDamage = enemyChar.GetThisTurnCharDamage();
        }
        else if (unitTurn == enemyChar.gameObject)
        {
            thisUnitTurnName     = "Enemy";
            targetName           = "Player";
            targetSufferedDamage = playerChar.GetThisTurnCharDamage();
        }

        switch (turnUnitCommand)
        {
        case CombatCommand.attack:
            turnOutcome.text = thisUnitTurnName + " attacks!\nDealing " + targetSufferedDamage.ToString() + " to " + targetName + "!";
            break;

        case CombatCommand.powerAttack:
            if (targetCommand == CombatCommand.attack || targetCommand == CombatCommand.powerAttack)
            {
                turnOutcome.text = thisUnitTurnName + " uses power attack!\nDealing " + targetSufferedDamage.ToString() + " to " + targetName + "!";
            }
            else if (targetCommand == CombatCommand.guard)
            {
                turnOutcome.text = thisUnitTurnName + " uses power attack!\nHowever, the " + targetName + " guarded the attack. Dealing no damage!";
            }
            break;

        case CombatCommand.guard:
            turnOutcome.text = thisUnitTurnName + " uses guard!";
            break;

        default:
            Debug.LogError("Error processing combat outcome.");
            break;
        }
    }
Example #11
0
    // END : Start of Combat



    // START : Pre-Combat (Display of command result)
    // Combat Command text change based on player and enemy commands
    public void ThisTurnCombatCommandResult(CombatCommand playerCommand, CombatCommand enemyCommand)
    {
        string playerCommandString = playerCommand.ToString();
        string enemyCommandString  = enemyCommand.ToString();

        if (playerCommand == CombatCommand.powerAttack)
        {
            playerCommandString = "Power attack";
        }
        if (enemyCommand == CombatCommand.powerAttack)
        {
            enemyCommandString = "Power attack";
        }

        // Change the first letter to upper case followed by the rest of the string (substring)
        playerCommandString = char.ToUpper(playerCommandString[0]) + playerCommandString.Substring(1);
        enemyCommandString  = char.ToUpper(enemyCommandString[0]) + enemyCommandString.Substring(1);

        playerCommandText.text = playerCommandString;
        enemyCommandText.text  = enemyCommandString;
    }
Example #12
0
        internal void ExecuteCommand(Command command, GameObject gameObject)
        {
            if (command != null)
            {
                if (command is ICommandWithUndo)
                {
                    commandsStack.Push((ICommandWithUndo)command); //only push commands with undo to the stack
                }

                lastCommand = command; //I added this bit to store the last command so even if
                                       //it isn't added to the stack, you can still reference it (GUI)

                if (command is CombatCommand)
                {
                    CombatCommand cc = (CombatCommand)command;
                    cc.TakeCombatAction(gameObject);
                    //Debug.Log(cc.commandName);
                }
                else
                {
                    command.Execute(gameObject);
                }
            }
        }
Example #13
0
    // -ICombatController-
    public void ReceiveCommand(CombatCommand command)
    {
        switch (command)
        {
        case CombatCommand.Right:
            m_MovementAmount = 1.0f;
            break;

        case CombatCommand.Left:
            m_MovementAmount = -1.0f;
            break;

        case CombatCommand.Heavy:
        case CombatCommand.Light:
            m_ComboLife = 0.0f;
            m_CombatBuffer.Write(command);
            break;
        }

        // Check for combos
        string activeCombo = FindActiveCombo();

        DispatchCombo(activeCombo);
    }
Example #14
0
 void CommandSelector()
 {
     mostRecentCommand = CommandQueue[CommandQueue.Count - 1];
     print(mostRecentCommand);
 }
 public void OnClickExecuteCommand(int commandInt)
 {
     chosenCommand = (CombatCommand)commandInt;      // Cast Int to Enum
     myCombatManager.StartThisTurnProgression();
 }
    public void AttemptToUseSkill(ActivationTime currentTime, CombatCommand unitCommand, CombatCommand opponentCommand)
    {
        float randomValue = Random.Range(0f, 100f);

        switch (currentTime)
        {
        case ActivationTime.beforeCombat:
            for (int i = 0; i < thisCharacterSkills.Count; i++)
            {
                if (thisCharacterSkills[i].GetMinActivationRNG() < randomValue && thisCharacterSkills[i].GetMaxActivationRNG() >= randomValue)
                {
                    if (thisCharacterSkills[i].GetSkillActivationTime() != currentTime)
                    {
                        continue;
                    }

                    ProcessThisCharacterSkillActivation(currentTime, i);
                    break;
                }
            }
            break;

        case ActivationTime.duringCombatOffense:
            for (int i = 0; i < thisCharacterSkills.Count; i++)
            {
                if (thisCharacterSkills[i].GetMinActivationRNG() < randomValue && thisCharacterSkills[i].GetMaxActivationRNG() >= randomValue)
                {
                    if (thisCharacterSkills[i].GetSkillActivationTime() != currentTime)
                    {
                        continue;
                    }
                    if (thisCharacterSkills[i].GetCommandThatTriggersSkill() != unitCommand)
                    {
                        continue;
                    }

                    ProcessThisCharacterSkillActivation(currentTime, i);
                    break;
                }
            }
            break;

        // Dealing with all the counters and retaliates
        case ActivationTime.duringCombatDefense:
            for (int i = 0; i < thisCharacterSkills.Count; i++)
            {
                if (thisCharacterSkills[i].GetMinActivationRNG() < randomValue && thisCharacterSkills[i].GetMaxActivationRNG() >= randomValue)
                {
                    if (thisCharacterSkills[i].GetSkillActivationTime() != currentTime)
                    {
                        continue;
                    }
                    if (thisCharacterSkills[i].GetCommandThatTriggersSkill() != unitCommand)
                    {
                        continue;
                    }
                    if (thisCharacterSkills[i].GetOpponentCommandThatTriggers() != opponentCommand)
                    {
                        continue;
                    }

                    ProcessThisCharacterSkillActivation(currentTime, i);
                    break;
                }
            }
            break;

        case ActivationTime.afterCombat:
            for (int i = 0; i < thisCharacterSkills.Count; i++)
            {
                if (thisCharacterSkills[i].GetMinActivationRNG() < randomValue && thisCharacterSkills[i].GetMaxActivationRNG() >= randomValue)
                {
                    if (thisCharacterSkills[i].GetSkillActivationTime() != currentTime)
                    {
                        continue;
                    }

                    ProcessThisCharacterSkillActivation(currentTime, i);
                    break;
                }
            }
            break;

        default:
            Debug.LogError("Error in processing skill.");
            break;
        }
    }