Exemplo n.º 1
0
 public void Move() //Unfinished
 {
     for (int Steps = 0; Steps < Stats[0] + 2; Steps++)
     {
         if (PitchHandler.Pitch[Position[0], Position[1]].GetTackleZones(Team) > 0)
         {
             Console.WriteLine("Need to dodge");
             inTackleZone = true;
         }
         else
         {
             inTackleZone = false;
         }
         Console.WriteLine("Movement left: " + (Stats[0] - Steps));
         Console.WriteLine("Press Enter to end action");
         ConsoleKey input = Console.ReadKey().Key;
         if (input == ConsoleKey.Enter)
         {
             Used = true;
             return;
         }
         int[] movement = InputHandler.Move8(input);
         int[] newPos   = new int[] { Position[0] + movement[0], Position[1] + movement[1] };
         if (newPos[0] >= 0 && newPos[1] >= 0 && newPos[0] < PitchHandler.Pitch.GetLength(0) && newPos[1] < PitchHandler.Pitch.GetLength(1) && PitchHandler.Pitch[newPos[0], newPos[1]].StoredPlayer == null)
         {
             MovePlayerToTileAtPosition(new int[] { newPos[0], newPos[1] });
             Cursor.Position = new int[] { Position[0], Position[1] };
             if (inTackleZone && !DodgeRoll(PitchHandler.Pitch[Position[0], Position[1]].GetTackleZones(Team)))
             {
                 Proned = true;
                 TurnHandler.TurnOver();
                 return;
             }
             RenderHandler.RenderPitch();
         }
         else
         {
             Steps--;
             continue;
         }
     }
     Used = true;
 }
Exemplo n.º 2
0
        public static string ChoiceMenu(List<string> choices)
        {
            int CursorPosition = 0;
            while (true)
            {
                RenderHandler.RenderPitch();

                for (int i = 0; i < choices.Count; i++)
                {
                    if (CursorPosition == i)
                    {
                        Console.WriteLine(">{0}<", choices[i]);
                    }
                    else
                    {
                        Console.WriteLine(" {0}", choices[i]);
                    }
                }
                if (CursorPosition == choices.Count)
                {
                    Console.WriteLine(">{0}<", "Exit");
                }
                else
                {
                    Console.WriteLine(" {0}", "Exit");
                }

                ConsoleKey input = Console.ReadKey().Key;
                CursorPosition = (CursorPosition + InputHandler.Move2(input)) % (choices.Count + 1);
                if (CursorPosition < 0) CursorPosition = choices.Count;
                if (input == ConsoleKey.Enter)
                {
                    if (CursorPosition == choices.Count)
                    {
                        return "Exit";
                    }
                    return choices[CursorPosition];
                }
            }
        }
Exemplo n.º 3
0
 public static void StartTurn(string team) //Unfinished
 {
     ActiveTeam       = team;
     AvailableActions = new List <string> {
         "Move", "Block", "Blitz", "Pass", "Handover"
     };
     while (true)
     {
         RenderHandler.RenderPitch();
         string SelectedChoice = Cursor.MoveCursorOnPitch();
         Player SelectedPlayer = PitchHandler.Pitch[Cursor.Position[0], Cursor.Position[1]].StoredPlayer;
         if (SelectedPlayer == null && SelectedPlayer.Team != team && SelectedPlayer.Used && SelectedPlayer.Stunned)
         {
             continue;
         }
         switch (SelectedChoice)
         {
         case "Move":
             SelectedPlayer.Move();
             break;
         }
     }
 }
Exemplo n.º 4
0
        public static string MoveCursorOnPitch(string onTeam = null)
        {
            while (true)
            {
                if (!LastTileHadPlayer && HoldingPlayer != null)
                {
                    PitchHandler.Pitch[Position[0], Position[1]].StoredPlayer = null;
                }
                ConsoleKey input    = Console.ReadKey().Key;
                int[]      movement = InputHandler.Move8(input);
                if (input == ConsoleKey.Enter)
                {
                    if (HoldingPlayer != null && PitchHandler.Pitch[Position[0], Position[1]].StoredPlayer == null)
                    {
                        PitchHandler.Pitch[Position[0], Position[1]].StoredPlayer = HoldingPlayer;
                        HoldingPlayer.Position = new int[] { Position[0], Position[1] };
                        HoldingPlayer          = null;
                        continue;
                    }
                    return(InputHandler.ChoiceMenu(TurnHandler.AvailableActions));
                }
                if (onTeam == null)
                {
                    Position[0] = (Position[0] + movement[0]) % PitchHandler.Pitch.GetLength(0);
                    if (Position[0] < 0)
                    {
                        Position[0] = (PitchHandler.Pitch.GetLength(0) - 1);
                    }
                }
                else if (onTeam == "Home")
                {
                    Position[0] = (Position[0] + movement[0]) % 13;
                    if (Position[0] < 0)
                    {
                        Position[0] = 12;
                    }
                }
                else if (onTeam == "Away")
                {
                    Position[0] = ((Position[0] + movement[0] - 13) % 13) + 13;
                    if (Position[0] < 13)
                    {
                        Position[0] = (PitchHandler.Pitch.GetLength(0) - 1);
                    }
                }
                Position[1] = (Position[1] + movement[1]) % PitchHandler.Pitch.GetLength(1);
                if (Position[1] < 0)
                {
                    Position[1] = (PitchHandler.Pitch.GetLength(1) - 1);
                }


                if (PitchHandler.Pitch[Position[0], Position[1]].StoredPlayer != null)
                {
                    LastTileHadPlayer = true;
                    RenderHandler.RenderPitch();
                    PitchHandler.Pitch[Position[0], Position[1]].StoredPlayer.WritePlayerData();
                }
                else if (HoldingPlayer != null)
                {
                    LastTileHadPlayer = false;
                    PitchHandler.Pitch[Position[0], Position[1]].StoredPlayer = HoldingPlayer;
                    RenderHandler.RenderPitch();
                }
                else
                {
                    RenderHandler.RenderPitch();
                }
            }
        }
Exemplo n.º 5
0
 static void Main(string[] args)
 {
     TurnHandler.initMatch();
     RenderHandler.RenderPitch();
 }
Exemplo n.º 6
0
        public static void SetupTeam(string team)
        {
            List <Player> ActiveReserves;
            List <Player> ActiveOnField;

            if (team == "Home")
            {
                ActiveOnField   = HomeOnField;
                ActiveReserves  = HomeReserves;
                Cursor.Position = new int[] { 0, 0 };
            }
            else
            {
                ActiveOnField   = AwayOnField;
                ActiveReserves  = AwayReserves;
                Cursor.Position = new int[] { 13, 0 };
            }
            AvailableActions = new List <string> {
                "Open the reserves", "Move Player", "Return the Player on this tile to the reserves", "End Setup"
            };
            while (true)
            {
                RenderHandler.RenderPitch();
                string SelectedChoice = Cursor.MoveCursorOnPitch(team);
                switch (SelectedChoice)
                {
                case "Open the reserves":
                    Player SelectedPlayer = GetPlayerFromList(ActiveReserves);
                    ActiveReserves.Remove(SelectedPlayer);
                    ActiveOnField.Add(SelectedPlayer);
                    Cursor.HoldingPlayer = SelectedPlayer;
                    break;

                case "Return the Player on this tile to the reserves":
                    if (PitchHandler.Pitch[Cursor.Position[0], Cursor.Position[1]].StoredPlayer != null)
                    {
                        ActiveOnField.Remove(PitchHandler.Pitch[Cursor.Position[0], Cursor.Position[1]].StoredPlayer);
                        ActiveReserves.Add(PitchHandler.Pitch[Cursor.Position[0], Cursor.Position[1]].StoredPlayer);
                        PitchHandler.Pitch[Cursor.Position[0], Cursor.Position[1]].StoredPlayer = null;
                    }
                    break;

                case "Move Player":
                    Cursor.HoldingPlayer = PitchHandler.Pitch[Cursor.Position[0], Cursor.Position[1]].StoredPlayer;
                    PitchHandler.Pitch[Cursor.Position[0], Cursor.Position[1]].StoredPlayer = null;
                    break;

                case "End Setup":
                    int onLoS     = 0;
                    int inWideTop = 0;
                    int inWideBot = 0;
                    foreach (Player player in ActiveOnField)
                    {
                        if ((player.Position[0] == 12 || player.Position[0] == 13) && (player.Position[1] > 3 || player.Position[1] < 11))
                        {
                            onLoS++;
                        }
                        if (player.Position[1] <= 3)
                        {
                            inWideTop++;
                        }
                        if (player.Position[1] >= 11)
                        {
                            inWideBot++;
                        }
                    }
                    if (inWideBot > 2 || inWideTop > 2)
                    {
                        Console.WriteLine("You may only have two players in the widezones");
                        Console.ReadKey();
                        break;
                    }
                    else if (onLoS < 0)     //Fix count, debug rn
                    {
                        Console.WriteLine("You must have at least 3 players on the line of scrimage");
                        Console.WriteLine("(You currently have: {0} players on the line of scrimage)", onLoS);
                        Console.ReadKey();
                        break;
                    }
                    else if (ActiveOnField.Count > 11)
                    {
                        Console.WriteLine("You cannot have more than 11 players on the field");
                        Console.ReadKey();
                        break;
                    }
                    else if (ActiveOnField.Count < 0)     //Fix playercount, debug rn
                    {
                        Console.WriteLine("You must place as many players as you can on the field (up to 11 players)");
                        Console.ReadKey();
                        break;
                    }
                    else
                    {
                        return;
                    }
                }
            }
        }