Ejemplo n.º 1
0
    public void TestCombatBuffer()
    {
        CombatBuffer buffer = new CombatBuffer(10);

        for (int iter = 0; iter < 1; iter++)
        {
            for (int i = 0; i < 3; i++)
            {
                buffer.Write(CombatCommand.Down);
            }
            Debug.Assert(buffer.Count == 3);

            for (int i = 0; i < 20; i++)
            {
                buffer.Write(CombatCommand.Down);
            }
            Debug.Assert(buffer.Count == 10);

            buffer.Write(CombatCommand.Right);
            Debug.Assert(buffer.Newest() == CombatCommand.Right);
            Debug.Assert(buffer.Oldest() == CombatCommand.Down);

            Debug.Assert(buffer.Match(new CombatCommand[] { CombatCommand.Down }) == false);
            Debug.Assert(buffer.Match(new CombatCommand[] { CombatCommand.Right, CombatCommand.Down }));
            Debug.Assert(buffer.Match(new CombatCommand[] { CombatCommand.Down, CombatCommand.Down }) == false);

            buffer.Write(CombatCommand.Up);
            Debug.Assert(buffer.Match(new CombatCommand[] { CombatCommand.Up, CombatCommand.Right }));

            buffer.ClearCommands();
            Debug.Assert(buffer.Count == 0);
        }
    }
Ejemplo n.º 2
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);
    }