public static void PrintStartPosition(Sea enemyMap, Sea playerMap) { int cursorLeft = START_LEFT_CURSOR; int cursorTop = 0; bool enemyTitle = true; string nickname = UserInterface.InputNickName(); PrintMapBorders(cursorLeft, cursorTop, enemyTitle, nickname); cursorLeft = START_LEFT_CURSOR - 1; cursorTop = START_TOP_CURSOR - 1;; PrintTableEnemy(cursorLeft, cursorTop); cursorLeft = START_LEFT_CURSOR; cursorTop = START_TOP_CURSOR; PrintShipEnemy(enemyMap, cursorLeft, cursorTop); enemyTitle = false; cursorTop = 0; cursorLeft = DISTANCE_BETWEEN_MAP; PrintMapBorders(cursorLeft, cursorTop, enemyTitle, nickname); cursorLeft = DISTANCE_BETWEEN_MAP - 1; cursorTop = START_TOP_CURSOR - 1; PrintTablePlayer(cursorLeft, cursorTop); cursorLeft = DISTANCE_BETWEEN_MAP; cursorTop = START_TOP_CURSOR; PrintMap(playerMap, cursorLeft, cursorTop); }
private static void a4ex3() { Sea a = new Sea(); a.Area = 10; a.Depth = a.Area; //Test that values can be assigned, retrieved. }
public int CountShips(Sea sea, int[] rt, int[] lb) { int l = lb[0]; int b = lb[1]; int r = rt[0]; int t = rt[1]; if (!sea.HasShips(rt, lb)) { return(0); } if (l == r && b == t) { return(1); } int x = l + (r - l) / 2; int y = b + (t - b) / 2; return (CountShips(sea, new int[] { r, t }, new int[] { x + 1, y + 1 }) + CountShips(sea, new int[] { x, t }, new int[] { l, y + 1 }) + CountShips(sea, new int[] { x, y }, new int[] { l, b }) + CountShips(sea, new int[] { r, y }, new int[] { x + 1, b })); }
public Game(bool isHost) { InitializeComponent(); fourship.IsChecked = true; HorizontalOrientation.IsChecked = true; _shipToggles = new ShipToggles(); _seaPlayer = new Sea(playerSquare); _seaOpponent = new Sea(opponentSquare); AddTooggles(); if (isHost) { _stateGame = StateGame.OpponentWaiting; SetEnableControls(_stateGame); ClientManager.Instance.Callback.SetHandler <CurentGameResponse>(GetOpponent); } else { _stateGame = StateGame.PreparationGame; SetEnableControls(_stateGame); } ClientManager.Instance.Callback.SetHandler <SendOpponentIsReadyResponse>(ResultOpponentSendReady); ClientManager.Instance.Callback.SetHandler <StartGameResponse>(StartGame); ClientManager.Instance.Callback.SetHandler <EndGameResponse>(EndGameGame); ClientManager.Instance.Callback.SetHandler <ShotResponse>(ResultFire); ClientManager.Instance.Callback.SetHandler <AbortGameResponse>(AbortGame); }
public int CountShips(Sea sea, int[] topRight, int[] bottomLeft) { // Divide and Conquer. if (!sea.HasShips(topRight, bottomLeft)) { return(0); } if (topRight[0] == bottomLeft[0] && topRight[1] == bottomLeft[1]) { return(1); } if (topRight[0] > bottomLeft[0]) { // Divide into left and right parts. int mid = bottomLeft[0] + (topRight[0] - bottomLeft[0]) / 2; int left = CountShips(sea, new int[] { mid, topRight[1] }, bottomLeft); int right = CountShips(sea, topRight, new int[] { mid + 1, bottomLeft[1] }); return(left + right); } else { // Divide into bottom and top parts. int mid = bottomLeft[1] + (topRight[1] - bottomLeft[1]) / 2; int bottom = CountShips(sea, new int[] { topRight[0], mid }, bottomLeft); int top = CountShips(sea, topRight, new int[] { bottomLeft[0], mid + 1 }); return(bottom + top); } }
public void TestMethod1() { Sea sea = new Sea(); sea.RefY2 = 380; var points = sea.SeaLevelPoints(); }
public (IAction?, Province) Perform(Province province, Player active) { if (province is Sea Sea && Sea.Occupied && !Sea.Soldiers.Any) { return(this, Sea.Revolt()); } return(this, province.CanSoldiersSurvive ? province : province.Revolt()); }
private void Awake() { if (Instance == null) { DontDestroyOnLoad(this); Instance = this; } }
// contructors public Game() { rules = new Rules(); character = new Character(); forest = new Forest(); sea = new Sea(); desert = new Desert(); }
private void GetPlayerMap() { PlayerSea playerMapManualInput = null; switch (_introducedMethod) { case MethodShipsBuild.AutoRandom: _playerMap = new Sea(10); _playerMap.BuildAllTypeOfShips(); break; case MethodShipsBuild.Manual: playerMapManualInput = new PlayerSea(10); bool isPossibleSetting; int shipCount = 1; TypeOfShips deckCount = TypeOfShips.FourDecker; Console.Clear(); for (int i = 0; i < RandomCoords.COUNT_OF_SHIPS_TYPE; i++) { for (int j = 0; j < shipCount; j++) { UserInterface.PrintManualInputShips(playerMapManualInput); Console.SetCursorPosition(0, 0); Direction shipDirection; Position shipPosition = UserInterface.InputShipPosition(deckCount, out shipDirection); isPossibleSetting = playerMapManualInput.BuildOneTypeOfShips(deckCount, shipPosition, shipDirection); if (!isPossibleSetting) { UserInterface.ClearBottom(0, 45, 7); UserInterface.ShowMessage(Constants.IMPOSSIBLE_SETTING, 0, 0); System.Threading.Thread.Sleep(3000); j--; continue; } UserInterface.PrintManualInputShips(playerMapManualInput); } deckCount--; shipCount++; } break; default: break; } if (_playerMap == null) { _playerMap = playerMapManualInput; } }
public Game(Player player1, Player player2, int gamemode) { _player1 = player1 ?? throw new ArgumentNullException("player1"); _player2 = player2 ?? throw new ArgumentNullException("player2"); CurrentPlayer = _player1; _playerOneSea = new Sea(_player1); _playerTwoSea = new Sea(_player2); _gameMode = gamemode; }
private void Init() { Sea = new Sea(this); ShipsManager = new ShipsManager(Sea); Computer = new Computer(Sea); Human = new Human(); Panel.Controls.Clear(); ShipsManager.CreateShips(); AddTilesToPanel(); }
public static void SearchRandomCoords(Sea playerMap) { bool wasShot; do { GetRandomCoords(playerMap); wasShot = playerMap.WasShot(); } while (wasShot); }
// Use this for initialization void Start() { if (instance != this) { instance = this; } seaRend = gameObject.GetComponent <Renderer>(); s_color = seaRend.material.color; s_target = s_color; }
public (IAction[], Province) Perform(Province province, Player active) { if (province is Sea Sea && Sea.Occupied && !Sea.Soldiers.Any) { return(new[] { this }, Sea.Revolt().Item1); } if (!province.CanSoldiersSurvive) { return(new[] { this }, province.Revolt().Item1); } return(new[] { this }, province); }
public FormGame() { _playerMap = null; _enemyMap = null; _isTargetEnemy = false; _isTargetPlayer = false; _isAliveEnemyAfterRigthShot = false; _isAlivePlayerAfterRigthShoot = false; _isEasyLevel = false; _enemysMind = null; _name = null; _playerMapManualInput = new PlayerSea(COUNT_ALL_SHIPS); _startShipPosition = new Position(-1, -1); }
private void FillSea(Sea sea) { var sea_array = sea.GetAll(); for (int i = 0; i < sea_array.Length; i++) { for (int j = 0; j < sea_array.Length; j++) { if (sea_array[i][j] == 0) { gameGrid.Rows[i].Cells[j].SetColor(Color.Black); } } } }
public WinScreen(Game game, Player player) : base(game) { _player = player; Position = new Vector2 (20, GraphicsDevice.Viewport.Bounds.Height-400); Scale = 0.5f; _dog = new Dog (game, new Vector2 (300, GraphicsDevice.Viewport.Bounds.Height-330), 0.4f); _sea = new Sea(game, new Vector2(0,600)); _harborButton = new Button (game, new Vector2 ((GraphicsDevice.Viewport.Bounds.Width/2)+50, (GraphicsDevice.Viewport.Bounds.Height/2)-200), "HarborButton", "harbor", _player); _bookButton = new Button (game, new Vector2 ((GraphicsDevice.Viewport.Bounds.Width/2)-50, (GraphicsDevice.Viewport.Bounds.Height/2)-200), "BookButton", "fishbook", _player); _mapButton = new Button (game, new Vector2 ((GraphicsDevice.Viewport.Bounds.Width/2)-150, (GraphicsDevice.Viewport.Bounds.Height/2)-200), "MapButton", "map", _player); Game1.cursor = new Cursor (game); }
private void ProcessShot(Sea sea, Position shot) { List <Ship> fleet = new List <Ship>(); if (sea is BootSea) { fleet = robotShips; } else { fleet = playerShips; } bool isShip = sea.RespondToHit(shot); if (isShip) { foreach (Ship ship in fleet) { foreach (Position position in ship.GetBody()) { if (position.Equals(shot)) { bool destoroyed = ship.RespondToHit(shot); if (destoroyed) { if (sea is BootSea) { robotFleet++; } else { playerFleet++; } } } } } // foreach (Gift gift in robotGifts) // { // if (gift.StartPosition.Equals(playerShotPosition)) // { // gift.RespondToHit(); // } // } } }
// objelere degdiginde yapilmasi gereken islemleri yapar void OnTriggerEnter(Collider other) { sea = FindObjectOfType <Sea>(); BackColliderControl(other); DamageColliderControl(other); BarrelColliderControl(other); StartCoroutine(AdvantageColliderControl(other)); StartCoroutine(CoinWin(other)); HealthColliderControl(other); }
public void TestSea() { XmlConfig xml = new XmlConfig(); Sea sea = new Sea(xml.UseConfigFile("width"), xml.UseConfigFile("height")); //sea.PrintGround(); sea.CreatureList.Add(e1); sea.CreatureList.Add(p1); Console.WriteLine("places creatures..."); sea.PlaceCreatures(); Console.WriteLine("position of enemies"); sea.PrintShips(10); Console.WriteLine($"Xpoition: {sea.CreatureList[0].Xposition} - Yposition: {sea.CreatureList[0].Yposition}"); }
public static void PrintMap(Sea map, int cursorLeft, int cursorTop) { for (int i = 0; i < map.GetLengthMapCells(0); i++) { Console.SetCursorPosition(cursorLeft, cursorTop); for (int j = 0; j < map.GetLengthMapCells(1); j++) { switch (map[i, j]) { case MapCondition.MissedShot: Console.ForegroundColor = ConsoleColor.DarkRed; Console.Write($"{(char)Symbol.MissedShot} "); break; case MapCondition.NoneShot: Console.ForegroundColor = ConsoleColor.White; Console.Write("- "); break; case MapCondition.ShipSafe: Console.ForegroundColor = ConsoleColor.Green; Console.Write($"{(char)Symbol.ShipSafe}"); break; case MapCondition.ShipInjured: Console.ForegroundColor = ConsoleColor.Magenta; Console.Write($"{(char)Symbol.ShipInjured} "); break; case MapCondition.ShipDestroyed: Console.ForegroundColor = ConsoleColor.Red; Console.Write($"{(char)Symbol.DestroyedShip} "); break; default: break; } } cursorTop++; Console.WriteLine(); } Console.CursorTop = 0; }
public ConsoleGame(UserActions numberUserAction, MethodShipsBuild introducedMethod, Intelligence enemysMind, bool isEasyLevel) { _numberUserAction = numberUserAction; _introducedMethod = introducedMethod; _enemysMind = enemysMind; _isEasyLevel = isEasyLevel; _playerMap = null; _enemyMap = null; _isPlayerWinner = false; _isAlivePlayerAfterRigthShoot = false; _enemyTurn = "ENEMY'S TURN!"; _yourTurn = "YOUR TURN!"; _isEasyLevel = false; _isTargetPlayer = false; _isTargetEnemy = false; _isNewGame = true; }
public static void PrintManualInputShips(Sea playerMap) { int cursorLeft = DISTANCE_BETWEEN_MAP; int cursorTop = 0; bool enemyTitle = false; PrintMapBorders(cursorLeft, cursorTop, enemyTitle, ""); cursorLeft = DISTANCE_BETWEEN_MAP - 1; cursorTop = START_TOP_CURSOR - 1; PrintTablePlayer(cursorLeft, cursorTop); cursorLeft = DISTANCE_BETWEEN_MAP; cursorTop = START_TOP_CURSOR; PrintMap(playerMap, cursorLeft, cursorTop); }
public virtual void MakeTheShot(ref bool isAlivePlayerAfterShoot, Sea playerMap) { if (!isAlivePlayerAfterShoot) { RandomCoords.SearchRandomCoords(playerMap); _isTargetPlayer = playerMap.HitTarget(ref isAlivePlayerAfterShoot); if (_isTargetPlayer) { SaveCoordsSuccessfulTarget(playerMap); } } else { GetTargetCoords(playerMap); _isTargetPlayer = playerMap.HitTarget(ref isAlivePlayerAfterShoot); } }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here // add palm trees this.elements.Add(new PalmTree(this.Content, new Vector3(-10, 9, 0), -0.2f, 0.5f, 0, 1)); this.elements.Add(new PalmTree(this.Content, new Vector3(10, 7, 0), 0, 0, -0.3f, 1)); // add island this.elements.Add(new Island(this.Content, 10, 0.7f, 3, 25, graphics.GraphicsDevice, new Vector3(0, -2, 0), 0, 0, 0)); // add sea this.elements.Add(new Boat(this.Content, graphics.GraphicsDevice, new Vector3(50, 0, 0), MathHelper.ToRadians(270), 0, 0, 0.05f)); //this.elements.Add(new Flag(this.Content, new Vector3(0, 7, 0), 0, 0, 0, 0.5f)); this.elements.Add(new Lighthouse(this.Content, new Vector3(0, 7, 0), 0, 0, 0, 0.01f)); //this.elements.Add(new Skybox(this.Content)); //this.skybox = new Tropikalna_wyspa.Skybox("Images\\Islands", this.Content); this.elements.Add(new Skybox(this.Content)); this.elements.Add(new ReflectionSphere(this.Content, new Vector3(0, 15, -50), 5)); this.elements.Add(new Sphere(this.Content, new Vector3(-20, 0, -20), 1, 10, 4)); this.sea = new Sea(this.Content, this.camera, 4000, 0.03f, 0, graphics.GraphicsDevice, 150); this.elements.Add(sea); base.Initialize(); }
private void AddButtonsCell(int startCoordY, int startCoordX, int maxWidth, ButtonMap[,] buttonsCell, Sea map, bool isEnemyClickButton) { int oY = 0; int oX = 0; for (int Y = startCoordY; Y < MAX_PIXEL_HEIGTH; Y += CELL_SIZE) { for (int X = startCoordX; X < maxWidth; X += CELL_SIZE) { ButtonMap buttonCell = new ButtonMap(oX, oY); buttonCell.Location = new Point(X, Y); buttonCell.Size = new Size(CELL_SIZE, CELL_SIZE); buttonCell.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.75F, System.Drawing.FontStyle.Bold); buttonCell.FlatStyle = FlatStyle.Flat; buttonCell.FlatAppearance.BorderSize = 2; buttonCell.FlatAppearance.BorderColor = Color.Orange; buttonCell.CellCondition = map[oY, oX]; buttonsCell[oY, oX] = buttonCell; Controls.Add(buttonCell); if (isEnemyClickButton) { buttonCell.Click += new EventHandler(ClickButtonCellEnemy); } else { buttonCell.Click += new EventHandler(ClickSettingShipButton); } oX++; } oX = 0; oY++; } }
public override void MakeTheShot(ref bool isAlivePlayerAfterShoot, Sea playerMap) { bool wasShot = false; if (!isAlivePlayerAfterShoot) { do { if (_plentyShots.Count <= 0) { RandomCoords.SearchRandomCoords(playerMap); //break;// } else { Position currentPos = _plentyShots.Dequeue(); playerMap.TargetCoordX = currentPos.OX; playerMap.TargetCoordY = currentPos.OY; wasShot = playerMap.WasShot(); } } while (wasShot); _isTargetPlayer = playerMap.HitTarget(ref isAlivePlayerAfterShoot); if (_isTargetPlayer) { SaveCoordsSuccessfulTarget(playerMap); } } else { GetTargetCoords(playerMap); _isTargetPlayer = playerMap.HitTarget(ref isAlivePlayerAfterShoot); } }
//Factory Method public Logistics LogisticsFactory(LogistcisEnum logisticsModel) { Logistics logistics = null; switch (logisticsModel) { case LogistcisEnum.Railway: logistics = new Railway(); break; case LogistcisEnum.Sea: logistics = new Sea(); break; case LogistcisEnum.Road: logistics = new Road(); break; default: break; } return(logistics); }
// Use this for initialization void Start() { m_sea=new Sea(); }
protected override void Update(GameTime gameTime) { if (S.clicked_key(Keys.Escape)) { Exit(); } S.update(); if (isAfterIntro) { if (S.clicked_key(Keys.Enter)) { graphics.ToggleFullScreen(); } if (IsActive) { S.camera.Update(); } if (UpdateEvent != null) { UpdateEvent(gameTime); } ufps = 1000 / gameTime.ElapsedGameTime.TotalMilliseconds; if (S.kb.IsKeyDown(Keys.N)) { player.Frame = 7800; } if (S.kb.IsKeyDown(Keys.Space)) { if (S.kb.IsKeyDown(Keys.T)) { player.change_bvh("Skeletons\\L\\144_20", true); } else if (S.kb.IsKeyDown(Keys.R)) { player.change_bvh("Skeletons\\C\\07_05", true); } } Window.Title = player.Frame.ToString() + " --- " + ufps.ToString() + " -- " + dfps.ToString(); } else { if (S.clicked_key(Keys.L)) { sea = new Sea(S.cm.Load <Texture2D>("lava1"), S.cm.Load <Texture2D>("lava2"), S.cm.Load <Texture2D>("lava3"), S.cm.Load <Texture2D>("lava2")); isAfterIntro = true; } else if (S.clicked_key(Keys.S)) { sea = new Sea(S.cm.Load <Texture2D>("sea1"), S.cm.Load <Texture2D>("sea2"), S.cm.Load <Texture2D>("sea3"), S.cm.Load <Texture2D>("sea2")); isAfterIntro = true; } } base.Update(gameTime); }
public int Load(SceneNode _node, ShaderType type) { BaseShader shader = null; switch (type) { case ShaderType.Sky: if (Reference.Viewer.IsDrawSky) { shader = new Sky(Reference.Viewer, ParentNode); } break; case ShaderType.Sea: if (Reference.Viewer.IsDrawSea) { if (Reference.Viewer.SeaQuality == Viewer.ShaderLevelType.Low) shader = new Sea(Reference.Viewer, ParentNode); } break; case ShaderType.AdvancedSea: if (Reference.Viewer.IsDrawSea) { if (Reference.Viewer.SeaQuality == Viewer.ShaderLevelType.High) shader = new AdvancedSea(Reference.Viewer, ParentNode); } break; case ShaderType.Shadow: if (Reference.Viewer.IsDrawSky) { } break; } int res = -1; if (shader != null) { // Load shader. //Reference.Device.FileSystem.WorkingDirectory = Util.ApplicationDataDirectory + @"\media"; res = shader.Load(); if (res > 0) { if (shaders.ContainsKey(type)) { Reference.Log.Debug("[SHADER]: " + type.ToString() + " Read multi."); } else { lock (shaders) { shaders.Add(type, shader); } lock (shaderIndex) { shaderIndex.Add(type, res); } } } else { Reference.Log.Debug("[SHADER]: " + type.ToString() + " Shader don't load."); } } return res; }
public void GetTargetCoords(Sea playerMap) { bool wasShot = true; playerMap.TargetCoordY = _cleanShotPosition.OY; playerMap.TargetCoordX = _cleanShotPosition.OX; do { if (_targetDirection > Direction.Left) { _targetDirection = Direction.Up; } switch (_targetDirection) { case Direction.Up: playerMap.TargetCoordY -= _counterSuccessfulShot; break; case Direction.Right: playerMap.TargetCoordX += _counterSuccessfulShot; break; case Direction.Down: playerMap.TargetCoordY += _counterSuccessfulShot; break; case Direction.Left: playerMap.TargetCoordX -= _counterSuccessfulShot; break; default: break; } if ((playerMap.TargetCoordX < 0) || (playerMap.TargetCoordX >= RandomCoords.MAP_SIZE) || (playerMap.TargetCoordY < 0) || (playerMap.TargetCoordY >= RandomCoords.MAP_SIZE)) { if (_counterSuccessfulShot >= RandomCoords.COUNT_OF_COORDS) { playerMap.TargetCoordY = _cleanShotPosition.OY; playerMap.TargetCoordX = _cleanShotPosition.OX; _targetDirection += RandomCoords.COUNT_OF_COORDS; continue; } else { playerMap.TargetCoordY = _cleanShotPosition.OY; playerMap.TargetCoordX = _cleanShotPosition.OX; _counterSuccessfulShot = 1; _targetDirection++; continue; } } wasShot = playerMap.WasShot(); if ((_counterSuccessfulShot < RandomCoords.SECCESSFUL_SHOT) && wasShot) { _targetDirection++; _counterSuccessfulShot = 1; playerMap.TargetCoordY = _cleanShotPosition.OY; playerMap.TargetCoordX = _cleanShotPosition.OX; } else { if (wasShot && _counterSuccessfulShot >= RandomCoords.SECCESSFUL_SHOT) { int counter = (int)_targetDirection + RandomCoords.SECCESSFUL_SHOT; _targetDirection = (Direction)counter; _counterSuccessfulShot = 1; playerMap.TargetCoordY = _cleanShotPosition.OY; playerMap.TargetCoordX = _cleanShotPosition.OX; } } } while (wasShot); }