private Vector3 memoryPosition; // 引く時のPositionを private void Start() { input = new PlayerInput(); move = new PlayerTeleport(); drawLine = new DrawLine(line); rope = new DrawrRope(line); pull = new ControllerPull(); cursorFunction = new CursorPosition(); runaway = new PlayerRunaway(); anchorAction = new AnchorShoot(); postProcess = eye.GetComponent <PostProcessingBehaviour>(); cameraFade = new CameraFade(); playerMap = new PlayerMap( ); lineMt = line.GetComponent <Renderer>().material; banCurcor.SetActive(false); cursor = pointCursor; goleMapSwitch = true; arrowCursor.SetActive(false); hibana.gameObject.SetActive(false); pullBody.SetActive(false); map.SetActive(false); particle.SetActive(false); viveDevice = SteamVR_Controller.Input((int)viveRightController.GetComponent <SteamVR_RenderModel>().index); fadeMt = fadeObject.GetComponent <MeshRenderer>().material; FadeInStart(); }
public void SetMapTile(PlayerMap map, PlayerMapTile tile) { if (tile.fightId == null) { return; } missionRequest.type = $"C_{map.mapId}"; missionRequest.mapId = map.mapId; missionRequest.posX = tile.posX; missionRequest.posY = tile.posY; fightTitle.text = $"{map.name} {tile.posX}x{tile.posY}"; fightService.GetFight((long)tile.fightId, data => { fight = data; loading = false; UpdateFight(); CheckButton(); }); if (tile.fightRepeatable != true) { Destroy(missionBtn.gameObject); missionButtonVisible = false; missionPossible = false; } missionPossible = tile.fightRepeatable == true && tile.victoriousFight == true; InitTeam(); }
void AssignNextPlayer(int rewiredPlayerId) { if (playerMap.Count >= maxPlayers) { // Debug.LogError("Max player limit already reached!"); return; } int gamePlayerId = GetNextGamePlayerId(); var player = new PlayerMap(rewiredPlayerId, gamePlayerId); playerMap.Add(new PlayerMap(rewiredPlayerId, gamePlayerId)); Player rewiredPlayer = ReInput.players.GetPlayer(rewiredPlayerId); rewiredPlayer.controllers.maps.SetMapsEnabled(false, "Joining"); // Enable UI control for this Player now that he has joined rewiredPlayer.controllers.maps.SetMapsEnabled(true, "Ready"); PlayerInput playerInput = Instantiate(PlayerPrefab, SpawnPoints[gamePlayerId].position, Quaternion.identity).GetComponent <PlayerInput>(); playerInput.IndicatorColor = PlayerColors[rewiredPlayerId]; playerInput.PlayerId = rewiredPlayerId; }
public void SetUp() { this.cells = new Dictionary <Point, Cell>(); for (var x = 0; x < this.width; x++) { for (var y = 0; y < this.height; y++) { var coordinate = new Point(x, y); var cell = new Cell(coordinate, this.cells); this.cells.Add(coordinate, cell); } } this.gameMap = new GameMap("TestPlayer", "OpponentPlayer", width, height); gameMap.Phase = 2; this.player = this.gameMap.GetBattleshipPlayer(PlayerType.One); this.opponent = this.gameMap.GetBattleshipPlayer(PlayerType.Two); this.playerMap = this.gameMap.GetPlayerMap(PlayerType.One); this.opponentMap = this.gameMap.GetPlayerMap(PlayerType.Two); PlacePlayerShips(); this.gameMap.Place(PlayerType.Two, ShipType.Battleship, new Point(1, 0), Direction.East); this.gameMap.Place(PlayerType.Two, ShipType.Carrier, new Point(0, 0), Direction.North); this.player.Energy = 50; }
public bool CanPlace(Point point, Direction direction, PlayerMap playerMap) { var startCell = playerMap.GetCellAtPoint(point); var length = 0; var cell = startCell; while (length < _cells.Length) { if (!cell.CanPlace()) { return(false); } length++; if (!cell.HasNeighbour(direction)) { break; } cell = cell.Neighbour(direction); } return(length == _cells.Length); }
void ProcessJson(string strJson, string strTitle) { m_listPlayerMap.Clear(); if (m_listFile.Count != 0) { for (int i = 0; i < m_listFile.Count; ++i) { Destroy(m_listFile[i]); } m_listFile.Clear(); } JsonData jsonvale = JsonMapper.ToObject(strJson); for (int i = 0; i < jsonvale.Count; ++i) { PlayerMap playermap = new PlayerMap(jsonvale[i]["_id"].ToString(), jsonvale[i]["title"].ToString(), jsonvale[i]["owner"].ToString(), jsonvale[i]["bestScore"]["score"].ToString(), jsonvale[i]["bestScore"]["user"].ToString()); m_listPlayerMap.Add(playermap); if (strTitle.Equals(jsonvale[i]["title"].ToString(), System.StringComparison.OrdinalIgnoreCase)) { CreateFile(i); } } Debug.Log("오브젝트 수 : " + m_listPlayerMap.Count); }
void ProcessJson(string strJson) { m_listPlayerMap.Clear(); if (m_listFile.Count != 0) { for (int i = 0; i < m_listFile.Count; ++i) { Destroy(m_listFile[i]); } m_listFile.Clear(); } JsonData jsonvale = JsonMapper.ToObject(strJson); for (int i = 0; i < jsonvale.Count; ++i) { PlayerMap playermap = new PlayerMap(jsonvale[i]["_id"].ToString(), jsonvale[i]["title"].ToString(), jsonvale[i]["owner"].ToString(), jsonvale[i]["bestScore"]["score"].ToString(), jsonvale[i]["bestScore"]["user"].ToString()); m_listPlayerMap.Add(playermap); CreateFile(i); } Debug.Log("오브젝트 수 : " + m_listPlayerMap.Count); }
private Ki GetCurrentKi() { var idx = GetTurn() % PlayerMap.Count; var keyValuePair = PlayerMap.ElementAt(idx); return(keyValuePair.Key); }
public void Place(Point point, Direction direction, PlayerMap playerMap) { var startCell = playerMap.GetCellAtPoint(point); var cells = new List <Cell>(); try { var length = 0; var cell = startCell; while (length < _cells.Length) { cells.Add(cell); cell.Place(direction, this); _cells[length] = cell; cell = cell.Neighbour(direction); length++; } Placed = true; } catch { cells.ForEach(x => x.OccupiedBy = null); throw; } }
private void Update(PlayerMap playerMap, bool currentMap) { var idx = PlayerMaps.FindIndex(m => m.mapId == playerMap.mapId); if (idx >= 0) { if (PlayerMaps[idx].CancellationTokenSource != null) { PlayerMaps[idx].CancellationTokenSource.Cancel(); } PlayerMaps[idx] = playerMap; } else { PlayerMaps.Add(playerMap); } if (currentMap) { CurrentPlayerMap = playerMap; signalBus.Fire(new CurrentMapSignal(CurrentPlayerMap)); } if (playerMap.secondsToReset != null) { ReloadMap(playerMap).SuppressCancellationThrow(); } }
public void GivenMapWithShipPlaced_WhenPlacingShipOverlappingOtherShip_DoesNotAddShipToCells() { const int width = 5; const int height = 5; var map = new PlayerMap(width, height, this.player); var coordinate = new Point(width / 2, height / 2); var ship = ShipStub.FullStub(this.player); map.Place(ship, coordinate, Direction.East); var overLappingShip = ShipStub.FullStub(this.player); try { map.Place(overLappingShip, coordinate, Direction.East); } catch (Exception) { //No-Op } var cellsWithOccupants = map.Cells.Where(x => x.Occupied); foreach (var cellsWithOccupant in cellsWithOccupants) { Assert.That(!overLappingShip.Cells.Contains(cellsWithOccupant)); } }
public void AddPlayer(SimPlayerSpec spec) { var player = new SimPlayer(spec); PlayerMap.Add(player.ID, player); EntityMap.Add(player.ID, player); }
private void Start() { currentMap = mapService.CurrentPlayerMap; UpdateMap(); RecenterCamera(); signalBus.Subscribe <CurrentMapSignal>(ConsumeCurrentMapSignal); signalBus.Subscribe <MissionSignal>(ConsumeMissionSignal); }
private static bool BottomRightEmpty(PlayerMap map, PlayerMapTile tile) { var posY = tile.posY + 1; var posX = tile.posY % 2 == 0 ? tile.posX : tile.posX + 1; var neighbourTile = map.tiles.Find(t => t.posY == posY && t.posX == posX); return(neighbourTile == null || neighbourTile.type == MapTileType.NONE); }
public void addMap(PlayerMap mapPlayer) { listMap.Remove(mapPlayer.id); listMap[mapPlayer.id] = mapPlayer; maps.Delete(mapPlayer); maps.Add(mapPlayer); maps.Save(); }
public void GivenWidthAndHeight_WhenConstructing_CreatesMapWithCorrectNumberOfCells() { const int width = 5; const int height = 5; var map = new PlayerMap(width, height, this.player); Assert.AreEqual(width * height, map.Cells.Count()); }
public void GivenMap_WhenPlacingShipWithDirectionLeadingToOutOfBounds_ThrowsException(Direction direction) { const int width = 1; const int height = 1; var map = new PlayerMap(width, height, this.player); var coordinate = new Point(width / 2, height / 2); var ship = ShipStub.FullStub(this.player, new WeaponStub(player, 1, WeaponType.SingleShot)); Assert.Throws <InvalidOperationException>(() => map.Place(ship, coordinate, direction)); }
public Player GetPlayer(int playerId) { if (!PlayerMap.ContainsKey(playerId)) { return(null); } int playerIndex = PlayerMap[playerId]; return(Players[playerIndex]); }
public void GivenMap_WhenShootingWeaponAtOwnMap_ThrowsException() { const int width = 5; const int height = 5; var map = new PlayerMap(width, height, this.player); var coordinate = new Point(width / 2, height / 2); var weapon = new WeaponStub(this.player); Assert.Throws <InvalidOperationException>(() => map.Shoot(coordinate, weapon)); }
public void GivenPlayer_WhenConstructing_AddsPlayerAsOwner() { var owner = new BattleshipPlayer("TestPlayer", 'A', PlayerType.One); const int width = 5; const int height = 5; var map = new PlayerMap(width, height, owner); Assert.AreEqual(owner, map.Owner); }
public void GivenMap_WhenPlacingShipWithInvalidDirection_ThrowsException(Direction direction) { const int width = 5; const int height = 5; var map = new PlayerMap(width, height, this.player); var coordinate = new Point(width / 2, height / 2); var ship = ShipStub.FullStub(this.player); Assert.Throws <InvalidOperationException>(() => map.Place(ship, coordinate, direction)); }
public void GivenMap_WhenPlacingShipOfOtherPlayer_ThrowsException() { const int width = 5; const int height = 5; var map = new PlayerMap(width, height, this.player); var coordinate = new Point(width / 2, height / 2); var otherPlayer = new BattleshipPlayer("OtherPlayer", 'A', PlayerType.One); var ship = ShipStub.FullStub(otherPlayer); Assert.Throws <InvalidOperationException>(() => map.Place(ship, coordinate, Direction.East)); }
private bool IsYourChess(Player player, int x, int y) { var chess = this[x, y]; if (PlayerMap.ContainsKey(chess)) { return(PlayerMap[chess].Equals(player)); } return(false); }
public void GivenMap_WhenShootingWeaponAtCoordinatesOutsideOfMap_ThrowsException() { const int width = 5; const int height = 5; var map = new PlayerMap(width, height, this.player); var coordinate = new Point(-1, -1); var otherPlayer = new BattleshipPlayer("OtherPlayer", 'A', PlayerType.One); var weapon = new WeaponStub(otherPlayer); Assert.Throws <ArgumentException>(() => map.Shoot(coordinate, weapon)); }
private void ConsumeCurrentMapSignal(CurrentMapSignal signal) { var mapChanged = signal.CurrentMap.mapId != currentMap.mapId; currentMap = signal.CurrentMap; UpdateMap(); if (mapChanged) { RecenterCamera(); } }
//Movement functions public void f_translate(PlayerUnit unit, PlayerMap pMap, int displaceX, int displaceY) { //moves a playerunit to a new location. displaceX,Y are how far the unit is move in those directions. pMap.remove_unit(unit); //pMap.restore_old_tile(unit.get_x(), unit.get_y()); unit.set_x(Math.Max(Math.Min(unit.get_x() + displaceX, 4), 0)); //must be between 0 and 4, inclusive unit.set_y(Math.Max(Math.Min(unit.get_y() + displaceY, 3), 0)); //must be between 0 and 3, inclusive pMap.place_unit(unit); //pMap.select_move_highlight(unit.get_x(), unit.get_y()); //<--highlights new tile correctly. unit.status.trigger_move(unit); }
private async UniTask ReloadMap(PlayerMap playerMap) { playerMap.CancellationTokenSource = new CancellationTokenSource(); await UniTask.Delay( playerMap.ResetTime - DateTime.Now, cancellationToken : playerMap.CancellationTokenSource.Token ); playerMap.CancellationTokenSource = null; Debug.Log($"Updating mission {playerMap.mapId}"); serverAPI.DoGet <PlayerMap>($"/map/{playerMap.mapId}", data => Update(data, data.mapId == CurrentPlayerMap.mapId)); }
public bool AddPlayer(Player player) { this.Players.Add(player); int index = Players.Count - 1; if (PlayerMap.ContainsKey(player.PlayerId)) { throw new PlayerAlreadyEnteredException(player); } this.PlayerMap.Add(player.PlayerId, index); return(true); }
//checks for targets. for enemy's checkUp ticks. public bool f_check_targets(PlayerMap pMap, Enemy unit) { //returns false if there are no targets left in the area. EnemyMove move = unit.nextMove; //index: //0: rectangular //1: 1x1 self //2: 3x3 centerless cross //3: 3x3 cross switch (move.get_highlightType()) { case 0: //standard rectangular for (int c = unit.nextX; c < (unit.nextX + move.get_ysize()); c++) { for (int r = unit.nextY; r < (unit.nextY + move.get_xsize()); r++) { if (pMap.search_unit(c, r) != null) { return(true); } } } break; case 2: //3x3 centerless cross. if (pMap.search_unit(unit.nextX - 1, unit.nextY) != null) { return(true); } if (pMap.search_unit(unit.nextX + 1, unit.nextY) != null) { return(true); } if (pMap.search_unit(unit.nextX, unit.nextY - 1) != null) { return(true); } if (pMap.search_unit(unit.nextX, unit.nextY + 1) != null) { return(true); } break; } return(false); }
public void GivenMap_WhenShootingWeaponAtCoordinatesInMap_CallsShootOnWeapon() { const int width = 5; const int height = 5; var map = new PlayerMap(width, height, this.player); var coordinate = new Point(width / 2, height / 2); var otherPlayer = new BattleshipPlayer("OtherPlayer", 'A', PlayerType.One); var weapon = new WeaponStub(otherPlayer); map.Shoot(coordinate, weapon); Assert.True(weapon.ShootCalled); Assert.NotNull(weapon.Target); }
void Start() { // set the camera position Camera.main.transform.position = new Vector3(3, 3, -10); Camera.main.orthographicSize = 10; // add the map component pMap = this.gameObject.AddComponent<PlayerMap>(); // load the map pMap.loadMap(); //add the player component players = new Player[2]; players[0] = new Player(); players[1] = new Player(); // replace with load from user input or xml file for campaign players[0].sName = "A"; players[1].sName = "B"; players[0].cColor = Color.white; players[1].cColor = Color.grey; currentPlayer = 0; // add text label obj_player_name = new GameObject("HUD Player Name"); gtxt_player_name = (GUIText) obj_player_name.AddComponent(typeof(GUIText)); obj_player_money = new GameObject("HUD Player Money"); gtxt_player_money = (GUIText) obj_player_money.AddComponent(typeof(GUIText)); // set label properties //change gui text to the players color. gtxt_player_name.font = (Font) Resources.Load("Fonts/Arial"); gtxt_player_name.fontSize = 20; gtxt_player_name.material.color = players[currentPlayer].cColor; gtxt_player_name.text = "Player: " + players[currentPlayer].sName; gtxt_player_name.transform.position = new Vector3(0.06f, 0.96f, 0); gtxt_player_money.font = (Font) Resources.Load("Fonts/Arial"); gtxt_player_money.fontSize = 20; gtxt_player_money.material.color = players[currentPlayer].cColor; gtxt_player_money.text = "Money: " + players[currentPlayer].iMoney; gtxt_player_money.transform.position = new Vector3(0.06f, 0.92f, 0); }