/// <summary> LocationDisambiguator implementation </summary> public bool IsSelectable(Location loc) { if (currentMode == Mode.Station) { return(GroundDisambiguator.theInstance.IsSelectable(loc)); } if (isPlacing) { // align to RRs or the ground if (currentMode == Mode.FatPlatform) { loc += direction.right90; } if (GroundDisambiguator.theInstance.IsSelectable(loc)) { return(true); } RailRoad rr = RailRoad.get(loc); if (rr == null) { return(false); } return(rr.hasRail(direction) && rr.hasRail(direction.opposite)); } else { return(Platform.get(loc) != null); } }
public override void onClick(MapViewWindow view, Location loc, Point ab) { if (isPlacing) { TrafficVoxel tv = TrafficVoxel.getOrCreate(loc); if (tv == null) { MainWindow.showError("There are obstacles"); //! MainWindow.showError("障害物があります"); return; } if (tv.railRoad == null || tv.railRoad is SingleRailRoad) { new SignalRailRoad(tv, currentType, currentDirection); } else { MainWindow.showError("Can not place on this rail"); } //! MainWindow.showError("設置できない線路です"); } else { SignalRailRoad srr = RailRoad.get(loc) as SignalRailRoad; if (srr != null) { srr.remove(); } } }
public bool canBeBuilt(Location loc) { TrafficVoxel voxel = TrafficVoxel.get(loc); if (voxel == null) { return(false); } RailRoad rr = voxel.railRoad; if (rr == null) { return(false); } RailPattern rp = rr.getPattern(); if (rp.numberOfRails != 2) { return(false); } if (!rp.hasRail(rr.dir1.opposite)) { return(false); } return(rr.dir1.isSharp); }
public RailData(RailRoad railRoad) { buyAmmount = railRoad.buyAmmount; rent = railRoad.rent; isOwned = railRoad.isOwned; playerID = railRoad.playerID; }
/// <summary> /// /// </summary> /// <param name="loc"></param> /// <returns></returns> public bool IsSelectable(Location loc) { RailRoad rr = RailRoad.get(loc); if (rr == null) { return(false); } if (isPlacingMode) { if (rr.Voxel.car == null) { return(true); } Train.TrainCar car = rr.Voxel.car as Train.TrainCar; if (car != null && car.parent == selectedTrain) { // allow selecting the same train to reverse the direction return(true); } return(false); } else { return(rr.Voxel.car != null); } }
public DarwinsVoyage() : base(30) { Name = "Darwin's Voyage"; RequiredTech = new RailRoad(); ObsoleteTech = null; SetSmallIcon(6, 4); Type = Wonder.DarwinsVoyage; }
/// <summary> /// LocationDisambiguator implementation. /// Use the base of the slope to disambiguate. /// </summary> /// <param name="loc"></param> /// <returns></returns> public bool isSelectable(Location loc) { if (!isPlacing) { SlopeRailRoad rr = SlopeRailRoad.get(loc); if (rr != null && rr.level < 2) { return(true); } loc.z++; rr = SlopeRailRoad.get(loc); if (rr != null && rr.level >= 2) { return(true); } return(false); } else { // it is always allowed to place it on or under ground if (World.world.getGroundLevel(loc) >= loc.z) { return(true); } // if the new rail road is at the edge of existing rail, // allow. RailRoad rr = RailRoad.get(loc + direction.opposite); if (rr != null && rr.hasRail(direction)) { return(true); } for (int i = 0; i < 4; i++) { loc += direction; } loc.z++; // run the same test to the other end rr = RailRoad.get(loc); if (rr != null && rr.hasRail(direction.opposite)) { return(true); } return(false); } }
private void setupHandler(TrafficVoxel neighbor, Direction d) { RailRoad rr = neighbor.railRoad; if (rr != null && rr.hasRail(d.opposite)) { // connected? neighbor.onCarChanged += new TrafficVoxelHandler(onCarApproaching); } else { // disconnected? neighbor.onCarChanged -= new TrafficVoxelHandler(onCarApproaching); } }
/// <summary> /// /// </summary> /// <param name="loc"></param> /// <returns></returns> public bool IsSelectable(Location loc) { // if there's any rail roads, fine if (RailRoad.get(loc) != null) { return(true); } // or if we hit the ground if (WorldDefinition.World.GetGroundLevel(loc) >= loc.z) { return(true); } return(false); }
/// <summary> /// Метод возвращает экземпляр класса <see cref="RailRoad"/> или, если в таблице нет такой записи, создаёт её /// </summary> /// <param name="name">Название железной дороги</param> /// <param name="countryName">Название страны</param> /// <returns>Экземпляр класса <see cref="RailRoad"/></returns> public RailRoad GetRailRoad(string name, string countryName) { var railRoad = RailRoads.FirstOrDefault(r => r.Name.Equals(name) && r.Country.Name.Equals(countryName)); if (railRoad == null) { railRoad = new RailRoad { Name = name, Country = GetCountry(countryName) }; RailRoads.Add(railRoad); SaveChanges(); } return(railRoad); }
private void SteppedOnRailRoadSpace(Player[] players, IList <Space> listOfSpaces, int currentPlayerCounter, Player player, Space currentSpace) { RailRoad currentRailroadSpace = (RailRoad)currentSpace; if (currentRailroadSpace.Owned == false) { FreeSpace(players, listOfSpaces, currentPlayerCounter, player, currentRailroadSpace); player.OwnedStations = currentRailroadSpace.Owned == true ? player.OwnedStations + 1 : player.OwnedStations; } else if (currentRailroadSpace.Owned == true && !player.ListOfProperties.Contains(listOfSpaces[player.Position])) { OtherPlayerOwnRailRoad(players, listOfSpaces, player, currentRailroadSpace); } }
public override void remove(Location here, Location to) { if (here == to) { return; } Direction d = here.getDirectionTo(to); for ( ; here != to; here = here.toward(to)) { GarageRail grr = RailRoad.get(here) as GarageRail; if (grr != null && grr.hasRail(d)) { grr.remove(); // destroy it } } }
public void BuyRail(Player player, RailRoad railRoad) { buyRail.gameObject.SetActive(false); player.money -= railRoad.buyAmmount; railRoad.isOwned = true; railRoad.playerID = CurrentPlayerID; Debug.Log("Purchased Railroad"); Debug.Log("You now have: " + player.money); buttonPress = false; propBuy = false; if (doubleRoll == true) { StartCoroutine(RollAgain()); } else { IsDoneInteraction = true; } }
public int get(IBreadthFirstSearch searchMechanism, string start, string destination, int valueLimit) { Node nodeStart; Node nodeDestination; try { nodeStart = RailRoad.getNode(char.Parse(start)); nodeDestination = RailRoad.getNode(char.Parse(destination)); } catch (FormatException formatException) { Logger.error(formatException.Message); throw formatException; } catch (Exception exception) { Logger.fatal(exception.Message); throw exception; } return(searchMechanism.find(nodeStart, nodeDestination, valueLimit)); }
public int get(IShortestPathSearch shortestPath, string start, string destination) { Node nodeStart; Node nodeDestination; try { nodeStart = RailRoad.getNode(char.Parse(start)); nodeDestination = RailRoad.getNode(char.Parse(destination)); } catch (FormatException formatException) { Logger.error(formatException.Message); throw formatException; } catch (Exception exception) { Logger.fatal(exception.Message); throw exception; } return(shortestPath.find(RailRoad, nodeStart, nodeDestination)); }
public override void onClick(MapViewWindow source, Location loc, Point ab) { if (isPlacingMode) { if (this.selectedTrain == null) { return; } // place Train tr = this.selectedTrain; if (tr.isPlaced) { // see if the user has clicked the same train Car c = Car.get(loc); if (c is Train.TrainCar && ((Train.TrainCar)c).parent == tr) { // clicking the same train will be considered to reverse its direction // and change the position of arrow tr.reverse(); resetArrowLocation(); return; } else { MainWindow.showError("This train is already placed"); //; MainWindow.showError("配置済みです"); return; } } RailRoad rr = RailRoad.get(loc); if (rr == null) { MainWindow.showError("Can not place without tracks"); //; MainWindow.showError("線路のないところには配置できません"); return; } if (!tr.place(loc)) { MainWindow.showError("Can not place"); //! MainWindow.showError("配置できません"); } else { playSound(); } } else { // remove RailRoad rr = RailRoad.get(loc); if (rr == null) { MainWindow.showError("There are no tracks"); //! MainWindow.showError("線路がありません"); return; } if (!(rr.voxel.car is Train.TrainCar)) { MainWindow.showError("There are no cars"); //! MainWindow.showError("車両がありません"); return; } ((Train.TrainCar)rr.voxel.car).parent.remove(); playSound(); // successfully removed } }
// Start is called before the first frame update void Start() { theGameManager = GameObject.FindObjectOfType <GameManager>(); sprite = gameObject.GetComponent <SpriteRenderer>(); rail = gameObject.GetComponentInParent <RailRoad>(); }
private void OtherPlayerOwnRailRoad(Player[] players, IList <Space> listOfSpaces, Player player, RailRoad currentRailRoadSpace) { for (int i = 0; i < players.Length; i++) { var otherPlayer = players[i]; if (otherPlayer.ListOfProperties.Contains(listOfSpaces[player.Position])) { PayingMoney(player, (int)currentRailRoadSpace.Rent * otherPlayer.OwnedStations, otherPlayer); } } }
public static new SignalRailRoad get(Location loc) { return(RailRoad.get(loc) as SignalRailRoad); }
public IEnumerator RailRoadHandler(Player player, Tile tile) { RailRoad railRoad = tile.GetComponent <RailRoad>(); if (railRoad.isOwned) { Debug.Log("This railroad is owned."); int playerID = railRoad.playerID; int rent = railRoad.rent; railOwned.rent = rent; Player[] playerArray = GameObject.FindObjectsOfType <Player>(); if (playerID == player.PlayerID) { Debug.Log("You own this railroad"); if (doubleRoll == true) { StartCoroutine(RollAgain()); } else { IsDoneInteraction = true; } } foreach (Player players in playerArray) { if (players.PlayerID == playerID) { railOwned.player = players.PlayerID; int playerPreviousMoney = players.money; players.money += rent; Debug.Log("Payed Player: " + (players.PlayerID + 1) + " " + rent); Debug.Log("Player " + (players.PlayerID + 1) + " had " + playerPreviousMoney + " and now has " + players.money); } } player.money -= rent; railOwned.gameObject.SetActive(true); yield return(new WaitForSeconds(3)); railOwned.gameObject.SetActive(false); Debug.Log(CurrentPlayerMoney); if (doubleRoll == true) { StartCoroutine(RollAgain()); } else { IsDoneInteraction = true; } } else { Debug.Log("landed on unowned railroad"); buyRail.gameObject.SetActive(true); IsDoneInteraction = false; timeLeft -= Time.deltaTime; while (buttonPress == false) { IsDoneInteraction = false; if (timeLeft < 0) { buttonPress = true; } IsDoneInteraction = false; yield return(null); } if (propBuy) { BuyRail(player, railRoad); } if (!propBuy) { buyRail.gameObject.SetActive(false); propBuy = false; buttonPress = false; if (doubleRoll == true) { StartCoroutine(RollAgain()); } else { IsDoneInteraction = true; } } } }
/// <summary> /// /// </summary> /// <param name="source"></param> /// <param name="loc"></param> /// <param name="ab"></param> public override void OnClick(MapViewWindow source, Location loc, Point ab) { if (isPlacingMode) { if (this.selectedTrain == null) { return; } // place Train tr = this.selectedTrain; if (tr.isPlaced) { // see if the user has clicked the same train Car c = Car.Get(loc); if (c is Train.TrainCar && ((Train.TrainCar)c).parent == tr) { // clicking the same train will be considered to reverse its direction // and change the position of arrow tr.reverse(); resetArrowLocation(); return; } else { MessageBox.Show(Translation.GetString("CONTROLLER_TRAIN_ALREADYPLACED")); return; } } RailRoad rr = RailRoad.get(loc); if (rr == null) { MessageBox.Show(Translation.GetString("CONTROLLER_TRAIN_CANNOTPLACE_NOTRACKS")); return; } if (!tr.place(loc)) { MessageBox.Show(Translation.GetString("CONSTRUCTION_CANNOT_PLACE")); } else { playSound(); } } else { // remove RailRoad rr = RailRoad.get(loc); if (rr == null) { MessageBox.Show(Translation.GetString("CONTROLLER_TRAIN_NORAIL")); return; } if (!(rr.Voxel.car is Train.TrainCar)) { MessageBox.Show(Translation.GetString("CONTROLLER_TRAIN_NOCARS")); return; } ((Train.TrainCar)rr.Voxel.car).parent.remove(); playSound(); // successfully removed } }