Exemplo n.º 1
0
    public void UserPressedPiece(SC_PieceLogic piece)
    {
        {
            if (currentTurn == SC_DefiendVariables.Turn.blueTurn)
            {
                SC_View.Instance.HideValidPlacements();
                ResetValidCoordinates();
                currentSelectedPiece.piece = piece;

                if (SC_Globals.GamePhase == SC_Globals.GameSituation.setPieces)
                {
                    MarkValidTiles();
                }

                else if ((SC_Globals.GamePhase == SC_Globals.GameSituation.Running))//&& (piece.canMove == SC_DefiendVariables.Moveable.can))
                {
                    //if (piece.canMove == SC_DefiendVariables.Moveable.can)
                    if (piece.whoAmI == SC_DefiendVariables.whoAmI.Blue)
                    {
                        MarkValidTilesAtRunning();
                    }
                    else if (piece.whoAmI == SC_DefiendVariables.whoAmI.Red)
                    {
                        fight(GameBoard[piece.currentTileRow][piece.currentTileCol].tile.GetComponent <SC_TileLogic>());
                    }
                }
            }
        }
    }
Exemplo n.º 2
0
    public void DeployEnemyPieces()
    {
        bool findSlot = true;
        int  _colRand, _rowRand;

        for (int i = 0; i < 40; i++)
        {
            SC_PieceLogic _tmpEnemy = blueTeam["Soldier (" + i + ")"].GetComponent <SC_PieceLogic>();
            while (findSlot)
            {
                _rowRand = UnityEngine.Random.Range(0, 4);
                _colRand = UnityEngine.Random.Range(0, 10);
                //print("rowRand= " + _rowRand + " _colRand= " + _colRand);

                if (SC_Logic.Instance.GameBoard[_rowRand][_colRand].tileStatus == SC_DefiendVariables.TileStatus.Empty)
                {
                    findSlot = false;
                    SC_Logic.Instance.GameBoard[_rowRand][_colRand].tileStatus = SC_DefiendVariables.TileStatus.BlueOccupied;
                    SC_Logic.Instance.GameBoard[_rowRand][_colRand].piece      = _tmpEnemy;
                    _tmpEnemy.transform.position = SC_Logic.Instance.GameBoard[_rowRand][_colRand].tile.transform.position;
                }
                //break;
            }
            findSlot = true;
        }
    }
Exemplo n.º 3
0
 public void movePieceToNewLocation(SC_PieceLogic piece, SC_TileLogic tile)
 {
     SC_Logic.Instance.EmptyPieceTile(piece);
     piece.transform.position = tile.transform.position;
     //print("tile row = " + tile.Row + " tile col= " + tile.Col);
     SC_Logic.Instance.GameBoard[tile.Row][tile.Col].tileStatus = SC_DefiendVariables.TileStatus.BlueOccupied;
     if (SC_Globals.currentSitutation == SC_Globals.GameSituation.setPieces)
     {
         disableHintColorBeforeGameStart();
     }
 }
Exemplo n.º 4
0
    private void MovePieceWhenDefeatEnemy(SC_PieceLogic attack, SC_TileLogic tile)
    {
        GameBoard[attack.currentTileRow][attack.currentTileCol].piece = null;
        GameBoard[tile.Row][tile.Col].tileStatus = GameBoard[attack.currentTileRow][attack.currentTileCol].tileStatus;
        GameBoard[attack.currentTileRow][attack.currentTileCol].tileStatus = SC_DefiendVariables.TileStatus.Empty;
        attack.currentTileRow = tile.Row;
        attack.currentTileCol = tile.Col;
        GameBoard[tile.Row][tile.Col].piece = attack;

        SC_View.Instance.movePieceToNewLocation(attack, tile);
    }
Exemplo n.º 5
0
    public void DeployEnemyPieces()
    {
        //EnemyArray = new SC_PieceLogic[40];
        bool findSlot = true;
        int  _colRand, _rowRand;
        int  RandCount = 0;

        print("SC_Logic.DeployEnemy()");
        for (int i = 0; i < 40; i++)
        {
            SC_PieceLogic _tmpEnemy = SC_Globals.Instance.EnemyPieces["Enemy (" + i + ")"];
            while (findSlot)
            {
                _rowRand = UnityEngine.Random.Range(6, 10);
                _colRand = UnityEngine.Random.Range(0, 10);
                //print("rowRand= " + _rowRand + " _colRand= " + _colRand);

                if (RandCount > 300)
                {
                    for (int j = 6; j < 10; j++)     //rows
                    {
                        for (int k = 0; k < 10; k++) //columns
                        {
                            if (SC_Logic.Instance.GameBoard[j][k].tileStatus == SC_DefiendVariables.TileStatus.Empty)
                            {
                                SC_PieceLogic _tmpEnemyAfterRand = SC_Globals.Instance.EnemyPieces["Enemy (" + i + j + k + ")"];
                                findSlot = false;
                                SC_Logic.Instance.GameBoard[j][k].tileStatus = SC_DefiendVariables.TileStatus.RedOccupied;
                                SC_Logic.Instance.GameBoard[j][k].piece      = _tmpEnemyAfterRand;
                                _tmpEnemyAfterRand.transform.position        = SC_Logic.Instance.GameBoard[j][k].tile.transform.position;
                                _tmpEnemyAfterRand.currentTileRow            = j;
                                _tmpEnemyAfterRand.currentTileCol            = k;
                            }
                        }
                    }
                }

                if (RandCount < 300 && SC_Logic.Instance.GameBoard[_rowRand][_colRand].tileStatus == SC_DefiendVariables.TileStatus.Empty)
                {
                    findSlot = false;
                    SC_Logic.Instance.GameBoard[_rowRand][_colRand].tileStatus = SC_DefiendVariables.TileStatus.RedOccupied;
                    SC_Logic.Instance.GameBoard[_rowRand][_colRand].piece      = _tmpEnemy;
                    _tmpEnemy.transform.position = SC_Logic.Instance.GameBoard[_rowRand][_colRand].tile.transform.position;
                    _tmpEnemy.currentTileRow     = _rowRand;
                    _tmpEnemy.currentTileCol     = _colRand;
                }
                //break;
            }
            enemyArray.Add(_tmpEnemy);
            findSlot = true;
        }
    }
Exemplo n.º 6
0
    public void CheckIfUserWantsToFight(SC_PieceLogic redPiece, SC_TileLogic tile)
    {
        print("redPiece= " + redPiece.name + " maybe blue= " + currentSelectedPiece.piece.name);

        if (currentSelectedPiece.piece != null)
        {
            if ((Math.Abs(currentSelectedPiece.piece.currentTileRow - redPiece.currentTileRow) == 0) && (Math.Abs(currentSelectedPiece.piece.currentTileCol - redPiece.currentTileCol) == 1) ||
                (Math.Abs(currentSelectedPiece.piece.currentTileRow - redPiece.currentTileRow) == 1) && (Math.Abs(currentSelectedPiece.piece.currentTileCol - redPiece.currentTileCol) == 0))
            {
                fight(tile);
            }
        }
    }
Exemplo n.º 7
0
 private void KillPiece(SC_PieceLogic defender, SC_TileLogic tile)
 {
     GameBoard[defender.currentTileRow][defender.currentTileCol].tileStatus = SC_DefiendVariables.TileStatus.Empty;
     GameBoard[defender.currentTileRow][defender.currentTileCol].piece      = null;
     GameBoard[tile.Row][tile.Col].tileStatus = SC_DefiendVariables.TileStatus.Empty;
     GameBoard[tile.Row][tile.Col].piece      = null;
     defender.currentTileRow = -1;
     defender.currentTileCol = -1;
     SC_View.Instance.KillPiece(defender);
     if (currentTurn == SC_DefiendVariables.Turn.RedTurn)
     {
         enemyArray.Remove(defender);
     }
 }
Exemplo n.º 8
0
 private void KillPiece(SC_PieceLogic defender, SC_TileLogic tile)
 {
     print("KillPiece");
     GameBoard[defender.currentTileRow][defender.currentTileCol].tileStatus = SC_DefiendVariables.TileStatus.Empty;
     GameBoard[defender.currentTileRow][defender.currentTileCol].piece      = null;
     GameBoard[tile.Row][tile.Col].tileStatus = SC_DefiendVariables.TileStatus.Empty;
     GameBoard[tile.Row][tile.Col].piece      = null;
     defender.currentTileRow = -1;
     defender.currentTileCol = -1;
     SC_View.Instance.KillPiece(defender);
     if (defender.whoAmI == SC_DefiendVariables.whoAmI.Red)
     {
         enemyArray.Remove(defender);
         //enemyArrayCount--;
     }
 }
Exemplo n.º 9
0
    public void UserPressedPiece(SC_PieceLogic piece)
    {
        SC_View.Instance.HideValidPlacements();
        ResetValidCoordinates();
        currentSelectedPiece.piece = piece;
        if (piece.onTile)
        {
            currentSelectedPiece.tile = GameBoard[piece.currentTileRow][piece.currentTileCol].tile;
        }
        if (SC_Globals.GamePhase == SC_Globals.GameSituation.setPieces)
        {
            MarkValidTiles();
        }

        else if ((SC_Globals.GamePhase == SC_Globals.GameSituation.Running))     //&& (piece.canMove == SC_DefiendVariables.Moveable.can))
        {
            //if (piece.canMove == SC_DefiendVariables.Moveable.can)
            MarkValidTilesAtRunning();
        }
    }
Exemplo n.º 10
0
    private void MovePieceWhenDefeatEnemy(SC_PieceLogic attack, SC_TileLogic tile)
    {
        GameBoard[attack.currentTileRow][attack.currentTileCol].piece = null;
        GameBoard[tile.Row][tile.Col].tileStatus = GameBoard[attack.currentTileRow][attack.currentTileCol].tileStatus;
        GameBoard[attack.currentTileRow][attack.currentTileCol].tileStatus = SC_DefiendVariables.TileStatus.Empty;
        attack.currentTileRow = tile.Row;
        attack.currentTileCol = tile.Col;
        GameBoard[tile.Row][tile.Col].piece = attack;
        if (attack.whoAmI == SC_DefiendVariables.whoAmI.Blue)
        {
            SC_View.Instance.movePieceToNewLocation(attack, tile);
        }


        if (attack.whoAmI == SC_DefiendVariables.whoAmI.Red)
        {
            SC_View.Instance.movePieceToNewLocation(attack, tile);
            //if(attack.whoAmI == SC_DefiendVariables.whoAmI.Red)
            //StartCoroutine(ShowRedPieceStrengh(attack));
            redWinnerPiece = attack;
            ShowRedPieceStrength();
        }
    }
Exemplo n.º 11
0
    public bool HasValidMove(SC_PieceLogic piece)
    {
        if (piece.canMove == SC_DefiendVariables.Moveable.cant)
        {
            return(true);
        }
        int numberOfPossiblie = 0;

        currentSelectedPiece.piece = piece;
        //currentSelectedPiece.tile = GameBoard[piece.currentTileRow][piece.currentTileCol].tile;
        MarkValidTilesAtRunning();
        for (int i = 0; i < 4; i++)
        {
            if (validCoordinates[i].Row != -1)
            {
                numberOfPossiblie++;
            }
        }
        if (numberOfPossiblie > 0)
        {
            return(false);
        }
        return(true);
    }
Exemplo n.º 12
0
 public gameBoard()
 {
     tileStatus = SC_DefiendVariables.TileStatus.Empty;
     piece      = null;
     tile       = null;
 }
Exemplo n.º 13
0
 public void UserPressedPiece(SC_PieceLogic sC_PieceLogic)
 {
     SC_Logic.Instance.UserPressedPiece(sC_PieceLogic);
 }
Exemplo n.º 14
0
 public void movePieceToNewLocation(SC_PieceLogic piece, SC_TileLogic tile)
 {
     //Vector3.MoveTowards(tile.transform.position, piece.transform.position,50f);
     //piece.transform.position = Vector2.MoveTowards(piece.transform.position, tile.transform.position, 50f);
     piece.transform.position = tile.transform.position;
 }
Exemplo n.º 15
0
 internal void KillPiece(SC_PieceLogic defender)
 {
     defender.goBack();
     SC_Globals.Instance.unityObjects[defender.name].SetActive(false);
 }
Exemplo n.º 16
0
 public void UserWantsToFIght(SC_PieceLogic sC_PieceLogic)
 {
     SC_Logic.instance.CheckIfUserWantsToFight(sC_PieceLogic, SC_Logic.Instance.GameBoard[sC_PieceLogic.currentTileRow][sC_PieceLogic.currentTileCol].tile.GetComponent <SC_TileLogic>());
 }
Exemplo n.º 17
0
    public void fight(SC_TileLogic tile)
    {
        SC_PieceLogic attack   = currentSelectedPiece.piece;
        SC_PieceLogic defender = GameBoard[tile.Row][tile.Col].piece;

        print("currentAttacker= " + currentTurn + "[" + attack.currentTileRow + "][" + attack.currentTileCol + "].strengh = " + attack.pieceStrengh);
        print("currentAttacker= " + currentTurn + "[" + defender.currentTileRow + "][" + defender.currentTileCol + "].strengh = " + defender.pieceStrengh);
        if ((attack.pieceStrengh == SC_Globals.SoldierRank.spy) && (defender.pieceStrengh == SC_Globals.SoldierRank.ten))
        {
            //spy captured your marshell
            KillPiece(defender, tile);
            MovePieceWhenDefeatEnemy(attack, tile);
            SwitchTurn();
        }
        else if ((defender.pieceStrengh == SC_Globals.SoldierRank.bomb) && (attack.pieceStrengh == SC_Globals.SoldierRank.three))
        {
            //defuse the bomb!
            KillPiece(defender, tile);
            MovePieceWhenDefeatEnemy(attack, tile);
            SwitchTurn();
        }

        else if (defender.pieceStrengh == SC_Globals.SoldierRank.flag)
        {
            print("GAMEOVER");
            SC_Globals.GamePhase = SC_Globals.GameSituation.Finished;
            SC_View.Instance.EndGamePanel.SetActive(true);
            if (defender.whoAmI == SC_DefiendVariables.whoAmI.Blue)
            {
                SC_View.Instance.EndGameText.GetComponent <Text>().text = "Winner: Red"; //Red won!
            }
            SC_View.Instance.EndGameText.GetComponent <Text>().text = "Winner: Blue";    //blue won!
        }

        else if (defender.pieceStrengh == SC_Globals.SoldierRank.bomb)
        {
            //red steps on your bomb! he need to die!
            KillPiece(defender, tile);
            KillPiece(attack, tile);
            SwitchTurn();
        }
        else if (defender.pieceStrengh == attack.pieceStrengh)
        {
            //same strength! they r both need to die
            KillPiece(defender, tile);
            KillPiece(attack, tile);
            SwitchTurn();
        }
        else
        {
            if (attack.pieceStrengh > defender.pieceStrengh)
            {
                KillPiece(defender, tile);
                MovePieceWhenDefeatEnemy(attack, tile);
                SwitchTurn();
            }
            else
            {
                KillPiece(attack, tile);
                MovePieceWhenDefeatEnemy(defender, tile);
                SwitchTurn();
                if (defender.whoAmI == SC_DefiendVariables.whoAmI.Blue)
                {
                    GameBoard[tile.Row][tile.Col].tileStatus = SC_DefiendVariables.TileStatus.BlueOccupied;
                }

                else
                {
                    GameBoard[tile.Row][tile.Col].tileStatus = SC_DefiendVariables.TileStatus.RedOccupied;
                }
            }
        }


        currentSelectedPiece.piece = null;
        SC_View.Instance.HideValidPlacements();
    }