コード例 #1
0
    public void DeployEnemyPieces()
    {
        bool findSlot = true;
        int  _colRand, _rowRand;
        int  counter = 0;

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

                if (SC_MultiPlayer_Logic.Instance.gameBoard[_rowRand][_colRand].tileStatus == SC_DefiendVariables.TileStatus.Empty)
                {
                    findSlot = false;
                    SC_MultiPlayer_Logic.Instance.gameBoard[_rowRand][_colRand].tileStatus = SC_DefiendVariables.TileStatus.BlueOccupied;
                    SC_MultiPlayer_Logic.Instance.gameBoard[_rowRand][_colRand].piece      = _tmpEnemy;
                    _tmpEnemy.transform.position = SC_MultiPlayer_Logic.Instance.gameBoard[_rowRand][_colRand].tile.transform.position;
                    _tmpEnemy.currentTileRow     = _rowRand;
                    _tmpEnemy.currentTileCol     = _colRand;
                }
                //break;
                if (counter == 200)
                {
                    break;
                }
            }
            counter  = 0;
            findSlot = true;
        }
    }
コード例 #2
0
    public void DeployEnemyPieces()
    {
        bool findSlot = true;
        int  _colRand, _rowRand;
        int  RandCount = 0;
        int  j = 6, k = 0;

        print("SC_MultiPlayer_Logic.DeployEnemy()");
        for (int i = 0; i < 40; i++)
        {
            SC_MultiPlayer_PieceLogic _tmpEnemy = SC_MultiPlayer_Globals.Instance.EnemyPieces["Enemy (" + i + ")"];
            SC_MultiPlayer_Logic.Instance.gameBoard[j][k].tileStatus = SC_DefiendVariables.TileStatus.RedOccupied;
            SC_MultiPlayer_Logic.Instance.gameBoard[j][k].piece      = _tmpEnemy;
            _tmpEnemy.transform.position = SC_MultiPlayer_Logic.Instance.gameBoard[j][k].tile.transform.position;
            _tmpEnemy.currentTileRow     = j;
            _tmpEnemy.currentTileCol     = k;

            if (k == 9)
            {
                k = 0;
                j++;
            }
            else
            {
                k++;
            }



            enemyArray.Add(_tmpEnemy);
            findSlot = true;
        }
    }
コード例 #3
0
    public void UserPressedPiece(SC_MultiPlayer_PieceLogic piece)
    {
        if (currentTurn == SC_DefiendVariables.Turn.blueTurn || !doneRestarting)
        {
            SC_MultiPlayer_View.Instance.HideValidPlacements();
            ResetValidCoordinates();
            currentSelectedPiece.piece = piece;
            //if (piece.onTile)
            //    currentSelectedPiece.tile = gameBoard[piece.currentTileRow][piece.currentTileCol].tile;
            if (SC_MultiPlayer_Globals.GamePhase == SC_MultiPlayer_Globals.GameSituation.setPieces)
            {
                MarkValidTiles();
            }

            else if ((SC_MultiPlayer_Globals.GamePhase == SC_MultiPlayer_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_MultiPlayer_TileLogic>());
                }
            }
        }
    }
コード例 #4
0
    public void CheckIfUserWantsToFight(SC_MultiPlayer_PieceLogic redPiece, SC_MultiPlayer_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);
            }
            SwitchTurn();
        }
    }
コード例 #5
0
 private void KillPiece(SC_MultiPlayer_PieceLogic defender, SC_MultiPlayer_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_MultiPlayer_View.Instance.KillPiece(defender);
     if (defender.whoAmI == SC_DefiendVariables.whoAmI.Red)
     {
         enemyArray.Remove(defender);
         //enemyArrayCount--;
     }
 }
コード例 #6
0
    private void MovePieceWhenDefeatEnemy(SC_MultiPlayer_PieceLogic attack, SC_MultiPlayer_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.Red)
        {
            SC_MultiPlayer_View.Instance.movePieceToNewLocation(attack, tile);
            //if(attack.whoAmI == SC_DefiendVariables.whoAmI.Red)
            //StartCoroutine(ShowRedPieceStrengh(attack));
            redWinnerPiece = attack;
            ShowRedPieceStrength();
        }
    }
コード例 #7
0
    public bool HasValidMove(SC_MultiPlayer_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);
    }
コード例 #8
0
 public void UserPressedPiece(SC_MultiPlayer_PieceLogic SC_MultiPlayer_PieceLogic)
 {
     print("piece.name= " + SC_MultiPlayer_PieceLogic.name);
     SC_MultiPlayer_Logic.Instance.UserPressedPiece(SC_MultiPlayer_PieceLogic);
 }
コード例 #9
0
 public void UserWantsToFIght(SC_MultiPlayer_PieceLogic SC_MultiPlayer_PieceLogic)
 {
     SC_MultiPlayer_Logic.instance.CheckIfUserWantsToFight(SC_MultiPlayer_PieceLogic, SC_MultiPlayer_Logic.Instance.gameBoard[SC_MultiPlayer_PieceLogic.currentTileRow][SC_MultiPlayer_PieceLogic.currentTileCol].tile.GetComponent <SC_MultiPlayer_TileLogic>());
 }
コード例 #10
0
 public void UserPressedPiece(SC_MultiPlayer_PieceLogic SC_MultiPlayer_PieceLogic)
 {
     SC_MultiPlayer_Logic.Instance.UserPressedPiece(SC_MultiPlayer_PieceLogic);
 }
コード例 #11
0
    public void fight(SC_MultiPlayer_TileLogic tile)
    {
        SC_MultiPlayer_PieceLogic attack   = currentSelectedPiece.piece;
        SC_MultiPlayer_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_MultiPlayer_Globals.SoldierRank.spy) && (defender.pieceStrengh == SC_MultiPlayer_Globals.SoldierRank.ten))
        {
            //spy captured your marshell
            KillPiece(defender, tile);
            MovePieceWhenDefeatEnemy(attack, tile);
        }
        else if ((defender.pieceStrengh == SC_MultiPlayer_Globals.SoldierRank.bomb) && (attack.pieceStrengh == SC_MultiPlayer_Globals.SoldierRank.three))
        {
            //defuse the bomb!
            KillPiece(defender, tile);
            MovePieceWhenDefeatEnemy(attack, tile);
        }

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

        else if (defender.pieceStrengh == SC_MultiPlayer_Globals.SoldierRank.bomb)
        {
            //red steps on your bomb! he need to die!
            KillPiece(defender, tile);
            KillPiece(attack, tile);
        }
        else if (defender.pieceStrengh == attack.pieceStrengh)
        {
            //same strength! they r both need to die
            KillPiece(defender, tile);
            KillPiece(attack, tile);
        }
        else
        {
            if (attack.pieceStrengh > defender.pieceStrengh)
            {
                KillPiece(defender, tile);
                MovePieceWhenDefeatEnemy(attack, tile);
            }
            else
            {
                KillPiece(attack, tile);
                MovePieceWhenDefeatEnemy(defender, tile);
            }
        }

        SwitchTurn();
        currentSelectedPiece.piece = null;
        SC_MultiPlayer_View.Instance.HideValidPlacements();
    }
コード例 #12
0
 public SC_MultiPlayer_gameBoard()
 {
     tileStatus = SC_DefiendVariables.TileStatus.Empty;
     piece      = null;
     tile       = null;
 }
コード例 #13
0
 internal void KillPiece(SC_MultiPlayer_PieceLogic defender)
 {
     defender.goBack();
     SC_MultiPlayer_Globals.Instance.unityObjects[defender.name].SetActive(false);
 }
コード例 #14
0
 public void movePieceToNewLocation(SC_MultiPlayer_PieceLogic piece, SC_MultiPlayer_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;
 }