public void MoveKnight(Player player, Knight knightToMove, bool forced) { movedKnight = true; Knight temp = knightToMove; positionedUnit = temp; owned = true; knight = temp.level; if (!forced) { temp.deactivateKnight(); } else { knightActive = knightToMove.isKnightActive(); } switch (positionedUnit.Owner.myColor) { case 0: color = Color.red; break; case 1: color = Color.blue; break; case 2: color = Color.green; break; case 3: color = new Color(255, 128, 0); break; } }
public void BuildDesertKnight(Player player) { movedKnight = true; positionedUnit = new Knight(player, player.desertKnightLevel); player.ownedUnits.Add(positionedUnit); owned = true; knight = player.desertKnightLevel; if (player.desertKnightActive) { var temp = positionedUnit as Knight; temp.activateKnight(); } knightActive = player.desertKnightActive; switch (positionedUnit.Owner.myColor) { case 0: color = Color.red; break; case 1: color = Color.blue; break; case 2: color = Color.green; break; case 3: color = new Color(255, 128, 0); break; } }
IEnumerator buildIntersectionUnit2(IntersectionUnit intersectionUnit, System.Type unitType) { waitingForPlayer = true; List <Intersection> validIntersectionsToBuild = getValidIntersectionsForPlayer(players[currentPlayerTurn]); ResourceTuple costOfUnit = resourceManager.getCostOfUnit(unitType); if (costOfUnit == null) { print("Cost of unit is null, returning."); waitingForPlayer = false; yield break; } if (!setupPhase) { if (!players [currentPlayerTurn].hasAvailableResources(costOfUnit)) // (Road.ResourceValue);//ResourceCost.getResourceValueOf(Road.ResourceValue); { print("Insufficient Resources to build a road!"); waitingForPlayer = false; yield break; } } if (validIntersectionsToBuild.Count == 0) { print("No possible location to build a settlement!"); Destroy(intersectionUnit); waitingForPlayer = false; yield break; } highlightIntersectionsWithColor(validIntersectionsToBuild, true, players [currentPlayerTurn].playerColor); intersectionUnit.id = unitID++; intersectionUnit.gameObject.SetActive(false); yield return(StartCoroutine(players [currentPlayerTurn].makeIntersectionSelection(validIntersectionsToBuild))); //, intersectionUnit)); intersectionUnit.GetComponentInChildren <Renderer> ().material.color = players[currentPlayerTurn].playerColor; intersectionUnit.gameObject.SetActive(true); if (!setupPhase) { players [currentPlayerTurn].spendResources(costOfUnit); uiButtons [1].GetComponentInChildren <Text> ().text = "Build Settlement"; } highlightAllIntersections(false); waitingForPlayer = false; }
private void LoadKnight(Knight k) { positionedUnit = k; owned = true; knight = k.level; switch (positionedUnit.Owner.myColor) { case 0: color = Color.red; break; case 1: color = Color.blue; break; case 2: color = Color.green; break; case 3: color = new Color(255, 128, 0); break; } }
private void LoadVillage(Village village, IntersectionData data) { positionedUnit = village; type = data.type; owned = true; switch (positionedUnit.Owner.myColor) { case 0: color = Color.red; break; case 1: color = Color.blue; break; case 2: color = Color.green; break; case 3: color = new Color(255, 128, 0); break; } metropolis = data.metropolis; }
public void BuildKnight(Player player) { positionedUnit = new Knight(player, KnightLevel.Basic); player.ownedUnits.Add(positionedUnit); owned = true; knight = KnightLevel.Basic; switch (positionedUnit.Owner.myColor) { case 0: color = Color.red; break; case 1: color = Color.blue; break; case 2: color = Color.green; break; case 3: color = new Color(255, 128, 0); break; } }
public void Load(IntersectionData data, IntersectionUnit u) { this.harbor = data.harbourKind; this.isFishingInter = data.isFishing; this.owned = data.owned; if (u != null) { if (u is Village) { var village = (Village)u; LoadVillage(village, data); } else if (u is Knight) { var knight = (Knight)u; LoadKnight(knight); } } }
public void RemoveKnight(Player player, bool destroy) { knightRemoved = true; owned = false; Knight temp = (Knight)positionedUnit; // temp.deactivateKnight(); knight = KnightLevel.None; knightActive = false; positionedUnit = null; if (destroy) { player.AddKnight(temp.level); player.ownedUnits.Remove(positionedUnit); } color = new Color(255, 255, 255); }
public void BuildSettlement(Player player) { positionedUnit = new Village(player); player.ownedUnits.Add(positionedUnit); type = 1; owned = true; switch (positionedUnit.Owner.myColor) { case 0: color = Color.red; break; case 1: color = Color.blue; break; case 2: color = Color.green; break; case 3: color = new Color(255, 128, 0); break; } //add the harbour to the list of owned harbour for when he trades it knows if (harbor != HarbourKind.None) { player.ownedHarbour.Add(harbor); } }
public List <Edge> getValidEdgesForPlayer(Player player, bool roadBuilt) { //print ("roadBuilt == " + roadBuilt.ToString ()); List <Edge> validEdges = new List <Edge> (); List <Unit> ownedUnits = player.getOwnedUnits(); if (EventTransferManager.instance.setupPhase) { for (int i = 0; i < ownedUnits.Count; i++) { if (typeof(IntersectionUnit).IsAssignableFrom(ownedUnits [i].GetType())) { bool validSet = true; IntersectionUnit intersectionUnit = (IntersectionUnit)(ownedUnits [i]); Intersection relatedIntersection = intersectionUnit.locationIntersection; List <Edge> connectedEdges = relatedIntersection.getLinkedEdges(); for (int j = 0; j < connectedEdges.Count; j++) { if (connectedEdges [j].occupier != null) { validSet = false; } } if (validSet) { for (int j = 0; j < connectedEdges.Count; j++) { if (connectedEdges [j].occupier == null) { validEdges.Add(connectedEdges [j]); } } } } } } else { for (int i = 0; i < ownedUnits.Count; i++) { if (typeof(EdgeUnit).IsAssignableFrom(ownedUnits [i].GetType())) { EdgeUnit tradeUnit = (EdgeUnit)(ownedUnits [i]); Edge relatedEdge = tradeUnit.locationEdge; List <Intersection> connectedIntersections = relatedEdge.getLinkedIntersections(); for (int j = 0; j < connectedIntersections.Count; j++) { if (connectedIntersections [j].occupier == null || connectedIntersections [j].occupier.owner == player) { List <Edge> connectedEdges = connectedIntersections [j].getLinkedEdges(); for (int k = 0; k < connectedEdges.Count; k++) { if (connectedEdges [k].occupier == null && (roadBuilt == connectedEdges [k].isLandEdge() || connectedEdges [k].isShoreEdge())) { if (relatedEdge.occupier.isRoad() == roadBuilt || (connectedIntersections [j].occupier != null && connectedIntersections [j].occupier.owner == player)) { validEdges.Add(connectedEdges [k]); } } } } } } } } if (!roadBuilt) { List <Edge> pirateEdges = getRobberPirateEdges(1); foreach (var edge in pirateEdges) { if (validEdges.Contains(edge)) { validEdges.Remove(edge); } } } return(validEdges); }
IEnumerator buildIntersectionUnit(IntersectionUnit intersectionUnit, System.Type unitType) { waitingForPlayer = true; List <Intersection> validIntersectionsToBuild = getValidIntersectionsForPlayer(players[currentPlayerTurn]); ResourceTuple costOfUnit = resourceManager.getCostOfUnit(unitType); if (!setupPhase && costOfUnit == null) { print("costofunit is null, returning."); Destroy(intersectionUnit.gameObject); waitingForPlayer = false; uiButtons [1].GetComponentInChildren <Text> ().text = "Build Settlement"; currentActiveButton = -1; removeUnitFromGame(intersectionUnit); yield break; } if (!setupPhase) { if (!players [currentPlayerTurn].hasAvailableResources(costOfUnit)) // (Road.ResourceValue);//ResourceCost.getResourceValueOf(Road.ResourceValue); { print("Insufficient Resources to build this intersection unit!"); Destroy(intersectionUnit.gameObject); waitingForPlayer = false; uiButtons [1].GetComponentInChildren <Text> ().text = "Build Settlement"; currentActiveButton = -1; removeUnitFromGame(intersectionUnit); yield break; } } if (validIntersectionsToBuild.Count == 0) { print("No possible location to build this intersection unit!"); Destroy(intersectionUnit.gameObject); waitingForPlayer = false; uiButtons [1].GetComponentInChildren <Text> ().text = "Build Settlement"; currentActiveButton = -1; removeUnitFromGame(intersectionUnit); yield break; } highlightIntersectionsWithColor(validIntersectionsToBuild, true, players [currentPlayerTurn].playerColor); yield return(StartCoroutine(players [currentPlayerTurn].makeIntersectionSelection(validIntersectionsToBuild))); //, intersectionUnit)); print(players [currentPlayerTurn].playerName + " builds a " + unitType.ToString() + " on intersection #" + players [currentPlayerTurn].lastIntersectionSelection.id); players [currentPlayerTurn].lastIntersectionSelection.occupier = intersectionUnit; intersectionUnit.locationIntersection = players [currentPlayerTurn].lastIntersectionSelection; players [currentPlayerTurn].addOwnedUnit(intersectionUnit, unitType); intersectionUnit.owner = players [currentPlayerTurn]; intersectionUnit.transform.position = players [currentPlayerTurn].lastIntersectionSelection.transform.position; intersectionUnit.transform.parent = players [currentPlayerTurn].lastIntersectionSelection.transform; intersectionUnit.transform.localScale = intersectionUnit.transform.localScale * GameObject.FindGameObjectWithTag("Board").GetComponent <GameBoard> ().hexRadius; intersectionUnit.GetComponentInChildren <Renderer> ().material.color = players[currentPlayerTurn].playerColor; intersectionUnit.gameObject.SetActive(true); //unitsInPlay.Add (intersectionUnit.id, intersectionUnit); if (!setupPhase) { players [currentPlayerTurn].spendResources(costOfUnit); uiButtons [1].GetComponentInChildren <Text> ().text = "Build Settlement"; } highlightAllIntersections(false); currentActiveButton = -1; waitingForPlayer = false; }
// Use this for initialization void Awake() { positionedUnit = null; cityWallSprite = (Sprite)Resources.Load <Sprite>("CityWall"); intersection = (Sprite)Resources.Load <Sprite>("intersection"); }
public IntersectionUnitData(IntersectionUnit source) : base(source) { }