Пример #1
0
    // Start is called before the first frame update
    void Start()
    {
        p1Command = BeatInput.Command.None;
        p2Command = BeatInput.Command.None;
        p1Ready   = false;
        p2Ready   = false;
        p1Offset  = 0.0;
        p2Offset  = 0.0;

        p1Notes = new List <NoteType>();
        p2Notes = new List <NoteType>();
    }
Пример #2
0
    public void SetCommand(PlayerNum player, BeatInput.Command Command)
    {
        switch (player)
        {
        case PlayerNum.Player1:
            p1Command = Command;
            break;

        case PlayerNum.Player2:
            p2Command = Command;
            break;
        }
    }
Пример #3
0
    // Checks whether the player input a BeatInput.Command which is a subset of the arrows on the beat
    public bool CheckSync(BeatInput.Command input, BeatInput.Command[] synced_moves)
    {
        sync = false;

        for (int i = 0; i < synced_moves.GetLength(0); ++i)
        {
            if (input == synced_moves[i])
            {
                sync = true;
                break;
            }
        }

        return(sync);
    }
Пример #4
0
    void Beat(double beatNum)
    {
        // Aggregate note types
        char[] p1ActualC = "    ".ToCharArray();
        foreach (NoteType note in p1Notes)
        {
            switch (note)
            {
            case NoteType.left:
                p1ActualC[0] = '<';
                break;

            case NoteType.up:
                p1ActualC[1] = '^';
                break;

            case NoteType.down:
                p1ActualC[2] = 'v';
                break;

            case NoteType.right:
                p1ActualC[3] = '>';
                break;

            default:
                break;
            }
        }
        string p1Actual = new string(p1ActualC);

        // Aggregate note types
        char[] p2ActualC = "    ".ToCharArray();
        foreach (NoteType note in p2Notes)
        {
            switch (note)
            {
            case NoteType.left:
                p2ActualC[0] = '<';
                break;

            case NoteType.up:
                p2ActualC[1] = '^';
                break;

            case NoteType.down:
                p2ActualC[2] = 'v';
                break;

            case NoteType.right:
                p2ActualC[3] = '>';
                break;

            default:
                break;
            }
        }
        string p2Actual = new string(p2ActualC);

        string p1Attempted = BeatInput.CommandToArrows(p1Command);
        string p2Attempted = BeatInput.CommandToArrows(p2Command);

        string p1Message;

        if (p1Actual == "    ")
        {
            p1Message = "   ";
        }
        else if (p1Attempted == p1Actual)
        {
            p1Message = "HIT";
            if (leftPlayer.combo_points < maxSync)
            {
                leftPlayer.combo_points += 1;
            }
        }
        else
        {
            p1Message = "MISS";
        }
        string p2Message;

        if (p2Actual == "    ")
        {
            p2Message = "   ";
        }
        else if (p2Attempted == p2Actual)
        {
            p2Message = "HIT";
            if (rightPlayer.combo_points < maxSync)
            {
                rightPlayer.combo_points += 1;
            }
        }
        else
        {
            p2Message = "MISS";
        }


        // GetComponent<TextMesh>().text = p1Attempted + p2Attempted + "\n" + p1Actual + p2Actual + "\n" + Mathf.Round(1000F*(float)p1Offset).ToString() + " " + Mathf.Round(1000F * (float)p2Offset).ToString();
        GetComponent <TextMesh>().text = p1Message + "   " + p2Message + "\n" + leftPlayer.combo_points + "    " + rightPlayer.combo_points;
        GetComponent <TextMesh>().text.Replace("\n", "\\n");

        leftPlayer.DetermineAction(p1Command);
        rightPlayer.DetermineAction(p2Command);


        p1Command = BeatInput.Command.None;
        p2Command = BeatInput.Command.None;
        p1Notes.Clear();
        p2Notes.Clear();
    }
Пример #5
0
    // Takes a keyboard/DDR pad BeatInput.Command and converts it into the appropriate move
    // for the player
    public Attack DetermineAction(BeatInput.Command comm_code)
    {
        prev_action = action;
        switch (comm_code)
        {
        case (BeatInput.Command.None):
            action = Attack.Noop;           // Both players
            break;

        case (BeatInput.Command.Up):
            action = Attack.HighBlock;      // Both players
            break;

        case (BeatInput.Command.Right):

            if (right_facing)
            {
                action = Attack.Jab;                    // Left player
            }
            else
            {
                action = Attack.Backdash;               // Right player
            }
            break;

        case (BeatInput.Command.Left):

            if (right_facing)
            {
                action = Attack.Backdash;                    // Left player
            }
            else
            {
                action = Attack.Jab;                         // Right player
            }
            break;

        case (BeatInput.Command.Down):
            action = Attack.LowBlock;       // Both players
            break;

        case (BeatInput.Command.UpLeft):

            if (right_facing)
            {
                action = Attack.Uppercut;                    // Left player
            }
            else
            {
                action = Attack.HighPunch;                   // Right player
            }
            break;

        case (BeatInput.Command.UpRight):

            if (right_facing)
            {
                action = Attack.HighPunch;                    // Left player
            }
            else
            {
                action = Attack.Uppercut;                     // Right player
            }
            break;

        case (BeatInput.Command.LeftRight):
            action = Attack.BodyCheck;      // Both players
            break;

        case (BeatInput.Command.UpDown):
            action = Attack.Projectile;     // Both players
            break;

        case (BeatInput.Command.DownLeft):

            if (right_facing)
            {
                action = Attack.SpinKick;                    // Left player
            }
            else
            {
                action = Attack.LowKick;                     // Right player
            }
            break;

        case (BeatInput.Command.DownRight):

            if (right_facing)
            {
                action = Attack.LowKick;                    // Left player
            }
            else
            {
                action = Attack.SpinKick;                   // Right player
            }
            break;
        }

        return(action);
    }