Beispiel #1
0
        public FireResult fireAtPlayer(int target)
        {
            ShipPlacement potentialShip  = new ShipPlacement(ShipType.battle, 0, new List <int[]>(), false);           //Just random Values assign
            char          postTargetSign = ownBoard.fireAtBoard(target, ref potentialShip);
            FireType      result         = FireType.miss;
            ShipType      shipHit        = ShipType.battle;

            if (postTargetSign == GameConstants.HITCHAR || postTargetSign == GameConstants.SUNKCHAR)              // We got a hit
            {
                hitsLeft--;
                result = postTargetSign == GameConstants.HITCHAR ? FireType.hit : FireType.sunk;
            }

            //	Main.GameMaster.singleton.debugPrint (playerInfo.username + " lives: " + hitsLeft);
            if (hitsLeft == 0)
            {
                death();
            }

            return(new FireResult(result, ownBoard.generateEnigmaBoard(), potentialShip, target));
        }
Beispiel #2
0
        public char fireAtBoard(int target, ref ShipPlacement potentialShip)
        {
            BoardUtils.printCharBoard(charBoard);
            int[] pos = BoardUtils.numberToCoord(target);
            //	Main.GameMaster.singleton.debugPrint ("Fire at: " + pos[0] + "." + pos[1] + "   ****************");
            char hitSign = charBoard [pos [0], pos [1]];

            if (char.IsNumber(hitSign) && hitSign != GameConstants.EMPTYCHAR)              // We got a new hit
            {
                hitSign = handleHit(pos, ref potentialShip);
            }
            else if (hitSign == GameConstants.EMPTYCHAR)
            {
                charBoard [pos [0], pos [1]] = GameConstants.MISSCHAR;
            }
            else               //We hit a target we have already hit before
            {
                hitSign = GameConstants.MISSCHAR;
            }

            //	Main.GameMaster.singleton.debugPrint ("Target sign: " + hitSign);
            return(hitSign);
        }
Beispiel #3
0
 public FireResult(FireType statusType, char[,] ShipPlacement, ShipPlacement ship, int target)
 {
     this.statusType = statusType; this.ship = ship; this.postBoard = postBoard; this.target = target;
 }