예제 #1
0
    // Contains the diffrent ways to move players.
    #region Move Player Methods

    // Moves a player to a x,y location.
    private void MovePlayerDirect(int x, int y, FantPlayer fp)
    {
        gridPlayer[fp.Poss.x, fp.Poss.y] = null;
        gridPlayer[x, y]      = fp;
        fp.transform.position = new Vector3(OffSetX(x), OffSetY(y) + 3f, -1);
        fp.Poss = new Vector2Int(x, y);
        SpriteRenderer sr = fp.GetComponent <SpriteRenderer>();

        sr.sortingOrder = -y;
    }
예제 #2
0
 // Plugs all of the players stats into fields.
 private void ShowPlayerStats(FantPlayer player)
 {
     actionText.text   = ("Action: " + player.Actions.ToString());
     raceText.text     = ("Race: " + player.Race.ToString());
     classText.text    = ("Class: " + player.tag);
     passingText.text  = ("Passing: " + player.Passing);
     movingText.text   = ("Moving: " + player.Moving);
     shootingText.text = ("Shooting: " + player.Shooting);
     combatText.text   = ("Combat: " + player.Combat);
     defenseText.text  = ("Defense: " + player.Defence);
 }
예제 #3
0
    // When you select a peice it will go though to logic to figure out if its on your team, if the player can move etc.
    private void SelectPiece(int x, int y)
    {
        //out of bounds
        if (x < 0 || x >= gridPlayer.GetLength(0) || y < 0 || y >= gridPlayer.GetLength(1))
        {
            return;
        }

        //gets access to the player
        FantPlayer fp = gridPlayer[x, y];

        if (fp != null)
        {
            selectedPlayer = fp;
            DeleteTileMods();
            Debug.Log(selectedPlayer.name);
            ShowPlayerStats(selectedPlayer);
            if (IsOnTeam(selectedPlayer))
            {
                if (selectedPlayer.Actions < 2)
                {
                    selectedPlayer.Poss = new Vector2Int(x, y);
                    canAct = true;
                    if (selectedPlayer.HasBall)
                    {
                        CoverActionsBar(2);
                    }
                    else
                    {
                        CoverActionsBar(1);
                    }
                }
            }
            else
            {
                CoverActionsBar(0);
            }
        }
    }
예제 #4
0
    private void DoPass()
    {
        if (selectedPlayer.Actions > 2)
            return;

        passingPlayer = selectedPlayer;

        Vector2 passPoss = (Camera.main.ScreenToWorldPoint(Input.mousePosition));
        passPoss.x = (int)(passPoss.x / 5);
        passPoss.y = (int)((passPoss.y - 15) / 5);
        for (int x = 0; x < gridTile.GetLength(0); x++)
        {
            for (int y = 0; y < gridTile.GetLength(1); y++)
            {
                if (gridTileMod[x, y] != null)
                {
                    if (x == passPoss.x && y == passPoss.y)
                    {

                        gridPlayer[selectedPlayer.Poss.x, selectedPlayer.Poss.y] = null;
                        gridPlayer[x, y] = selectedPlayer;


                        DeleteTileMods();


                        passingPlayer.HasBall = false;
                        selectedPlayer.HasBall = true;

                        passingPlayer.Actions -= 1;
                        CoverActionsBar(0);
                        actionAttack = false;
                        ShowPlayerStats(selectedPlayer);

                    }
                }
            }
        }
    }
예제 #5
0
    private void SeePass(int playerX, int playerY)
    {
        FantPlayer fp = gridPlayer[playerX, playerY];
        int passDistance = selectedPlayer.Passing + 7;
        List<Vector2> passRadius = new List<Vector2>();
        PlayerRace playerTeam = selectedPlayer.Race;

        // If tile mods have already been drawn it deletes it.
        if (drawnOnMap)
        {
            DeleteTileMods();
        }
        else
        {
            drawnOnMap = true;
        }

        for (int x = 0; x < gridTile.GetLength(0); x++)
        {
            for (int y = 0; y < gridTile.GetLength(1); y++)
            {
                if (gridPlayer[x, y] != null)
                {
                    if (gridPlayer[x, y].Race == playerTeam)
                    {
                        if (playerX + passDistance > x && playerY + passDistance > y && playerX - passDistance < x && playerY - passDistance < y)
                        {
                            passRadius.Add(new Vector2(x, y));
                            gridTileMod[x, y] = Instantiate(tileGreen, new Vector3(OffSetX(x), OffSetY(y), -.5f), Quaternion.identity);
                            gridTileMod[x, y].name = "Green Tile (" + x + ", " + y + ")";
                        }
                    }
                }

            }
        }
    }
예제 #6
0
    // Generates a player at an x and y position and is given a type.
    private void GeneratePlayer(int x, int y, PlayerType type, PlayerRace race)
    {
        GameObject go = null;
        int        startingPassing  = 0;
        int        startingMoving   = 0;
        int        startingShooting = 0;
        int        startingCombat   = 0;
        int        startingDefence  = 0;

        #region Switch: Race & Type W/ Benefits

        switch (race)
        {
        case PlayerRace.Human:
            switch (type)
            {
            case PlayerType.PointGuard:
                go               = Instantiate(playerPassGaurd);
                startingCombat   = -1;
                startingDefence  = 0;
                startingMoving   = 1;
                startingPassing  = 2;
                startingShooting = 0;
                break;

            case PlayerType.ShootingGuard:
                go               = Instantiate(playerScoringGuard);
                startingCombat   = 0;
                startingDefence  = -1;
                startingMoving   = 0;
                startingPassing  = 1;
                startingShooting = 2;
                break;

            case PlayerType.SmallForward:
                go               = Instantiate(playerTallForward);
                startingCombat   = 1;
                startingDefence  = 0;
                startingMoving   = 2;
                startingPassing  = 0;
                startingShooting = -1;
                break;

            case PlayerType.PowerForward:
                go               = Instantiate(playerHulkForward);
                startingCombat   = 1;
                startingDefence  = 2;
                startingMoving   = 0;
                startingPassing  = 0;
                startingShooting = -1;
                break;

            case PlayerType.Center:
                go               = Instantiate(playerSmallTitan);
                startingCombat   = 2;
                startingDefence  = 2;
                startingMoving   = -2;
                startingPassing  = 0;
                startingShooting = -2;
                break;

            default:
                Debug.LogError("Human instaniate error");
                break;
            }
            break;

        case PlayerRace.Orc:
            switch (type)
            {
            case PlayerType.PointGuard:
                go               = Instantiate(playerPazzer);
                startingCombat   = -1;
                startingDefence  = 0;
                startingMoving   = 1;
                startingPassing  = 2;
                startingShooting = 0;
                break;

            case PlayerType.ShootingGuard:
                go               = Instantiate(playerShootzer);
                startingCombat   = 0;
                startingDefence  = -1;
                startingMoving   = 0;
                startingPassing  = 1;
                startingShooting = 2;
                break;

            case PlayerType.SmallForward:
                go               = Instantiate(playerSmallDunker);
                startingCombat   = 1;
                startingDefence  = 0;
                startingMoving   = 2;
                startingPassing  = 0;
                startingShooting = -1;
                break;

            case PlayerType.PowerForward:
                go               = Instantiate(playerBuffOrc);
                startingCombat   = 1;
                startingDefence  = 2;
                startingMoving   = 0;
                startingPassing  = 0;
                startingShooting = -1;
                break;

            case PlayerType.Center:
                go               = Instantiate(playerBigBoi);
                startingCombat   = 2;
                startingDefence  = 2;
                startingMoving   = -2;
                startingPassing  = 0;
                startingShooting = -2;
                break;

            default:
                Debug.LogError("Orc instaniate error");
                break;
            }
            break;

        default:
            Debug.LogError("Instaniate player error");
            break;
        }
        #endregion

        FantPlayer fp = go.GetComponent <FantPlayer>();
        fp.Poss = new Vector2Int(x, y);
        MovePlayerDirect(x, y, fp);
        fp.SetStats(startingPassing, startingMoving, startingShooting, startingCombat, startingDefence, race, new Vector2Int(x, y));
        go.transform.SetParent(transform.GetChild(1));
        go.tag  = type.ToString();
        go.name = (race.ToString() + ": " + type.ToString());
        //gridPlayer[x, y] = fp;
    }
예제 #7
0
 // Checks if a player is on the clients team.
 private bool IsOnTeam(FantPlayer player)
 {
     return(player.Race == teamRace);
 }
예제 #8
0
    private void DoAttack()
    {
        if (selectedPlayer.Actions > 2)
        {
            return;
        }

        int attackingPlayerCombat = selectedPlayer.Combat;

        attackingPlayer = selectedPlayer;

        Vector2 enemyPos = (Camera.main.ScreenToWorldPoint(Input.mousePosition));

        enemyPos.x = (int)(enemyPos.x / 5);
        enemyPos.y = (int)((enemyPos.y - 15) / 5);
        for (int x = 0; x < gridTile.GetLength(0); x++)
        {
            for (int y = 0; y < gridTile.GetLength(1); y++)
            {
                if (gridTileMod[x, y] != null)
                {
                    if (x == enemyPos.x && y == enemyPos.y)
                    {
                        selectedPlayer = gridPlayer[x, y];

                        DeleteTileMods();

                        int attackRoll = Random.Range(0, 101); //Decides what the combat role is
                        int modifier   = attackingPlayerCombat - selectedPlayer.Defence;

                        switch (modifier)
                        {
                        case 2:
                            if (attackRoll >= 0 && attackRoll <= 15)
                            {
                                //MissGraze();
                                Debug.Log("Miss");
                            }
                            if (attackRoll >= 16 && attackRoll <= 89)
                            {
                                KnockBack();
                                Debug.Log("Back");
                            }
                            if (attackRoll >= 90 && attackRoll <= 100)
                            {
                                KnockOut();
                                Debug.Log("KO");
                            }
                            break;

                        case 1:
                            if (attackRoll >= 0 && attackRoll <= 25)
                            {
                                //MissGraze();
                                Debug.Log("Miss");
                            }
                            if (attackRoll >= 26 && attackRoll <= 95)
                            {
                                KnockBack();
                                Debug.Log("Back");
                            }
                            if (attackRoll >= 90 && attackRoll <= 100)
                            {
                                KnockOut();
                                Debug.Log("KO");
                            }
                            break;

                        case 0:
                            if (attackRoll >= 0 && attackRoll <= 30)
                            {
                                //MissGraze();
                                Debug.Log("Miss");
                            }
                            if (attackRoll >= 31 && attackRoll <= 98)
                            {
                                KnockBack();
                                Debug.Log("Back");
                            }
                            if (attackRoll >= 99 && attackRoll <= 100)
                            {
                                KnockOut();
                                Debug.Log("KO");
                            }
                            break;

                        case -1:
                            if (attackRoll >= 0 && attackRoll <= 35)
                            {
                                //MissGraze();
                                Debug.Log("Miss");
                            }
                            if (attackRoll >= 36 && attackRoll <= 99)
                            {
                                KnockBack();
                                Debug.Log("Back");
                            }
                            if (attackRoll >= 100)
                            {
                                KnockOut();
                                Debug.Log("KO");
                            }
                            break;

                        case -2:
                            if (attackRoll >= 0 && attackRoll <= 69)
                            {
                                //MissGraze();
                                Debug.Log("Miss");
                            }
                            if (attackRoll >= 70 && attackRoll <= 100)
                            {
                                KnockBack();
                                Debug.Log("Back");
                            }
                            break;
                        }

                        selectedPlayer.Actions += 1;
                        CoverActionsBar(0);
                        actionAttack = false;
                        ShowPlayerStats(selectedPlayer);
                    }
                }
            }
        }
    }
예제 #9
0
    // Moves a player to a position tile to tile with pathing around people.
    private void MovePlayer(int x, int y, FantPlayer fp)
    {
        Vector2Int currentPos = new Vector2Int(fp.Poss.x, fp.Poss.y);
        Vector2Int targetPos  = new Vector2Int(x, y);
        Direction  moveDirection;

        #region Find Direction
        if (currentPos.x > targetPos.x)
        {
            if (currentPos.y > targetPos.y)
            {
                moveDirection = Direction.DownLeft;
            }
            else
            {
                moveDirection = Direction.UpLeft;
            }
        }
        else
        {
            if (currentPos.y > targetPos.y)
            {
                moveDirection = Direction.DownRight;
            }
            else
            {
                moveDirection = Direction.UpRight;
            }
        }
        #endregion

        switch (moveDirection)
        {
        case Direction.UpRight:
            while (currentPos != targetPos)
            {
                if (gridPlayer[currentPos.x + 1, currentPos.y] == null)
                {
                    fp.transform.position = new Vector2(OffSetX(currentPos.x + 1), OffSetY(currentPos.y));
                }
                else
                {
                    if (gridPlayer[currentPos.x, currentPos.y + 1] == null)
                    {
                        fp.transform.position = new Vector2(OffSetX(currentPos.x), OffSetY(currentPos.y + 1));
                    }
                }
            }
            break;

        case Direction.UpLeft:
            break;

        case Direction.DownRight:
            break;

        case Direction.DownLeft:
            break;

        default:
            break;
        }
    }
예제 #10
0
    // Contains the diffrent ways to move players.
    #region Move Player Methods

    // Moves a player to a x,y location.
    private void MovePlayerDirect(int x, int y, FantPlayer fp)
    {
        fp.transform.position = new Vector3(OffSetX(x), OffSetY(y) + 3f, -1);
        SpriteRenderer sr = fp.GetComponent<SpriteRenderer>();
        sr.sortingOrder = -y;
    }