public void AddUtilityCardToDatabase(UtilityCard c) { c.gameObject.name = c.CardName; allUtilityCards.Add(c.CardName, c); c.transform.SetParent(transform); }
private async Task <string> FindActionByScore(UtilityCard utilityCard) { float score = 0; string actionName = ""; if (utilityCard.requestCard != null) { int length = utilityCard.requestCard.Length; for (int i = 0; i < length; i++) { if (utilityCard.requestCard[i].Execute != null) { float utilityScore = utilityCard.requestCard[i].Execute(); if (utilityScore > score) { score = utilityScore; actionName = utilityCard.requestCard[i].action; } } } } return(actionName); }
public async Task Request(UtilityCard utilityCard, RequestCallback requestCallback) { string actionName = await FindActionByScore(utilityCard); if (requestCallback != null) { requestCallback(actionName); } }
public void CopyActionsFrom(UtilityCard c) { this.CardName = c.CardName; this.CardCost = c.CardCost; this.CardDescription = c.CardDescription; this.Target = c.Target; this.Area = c.Area; this.Range = c.Range; this.Effect = c.Effect; this.CardDraw = c.CardDraw; }
private async void Start() { try { var response = await ApiWrapper.GamePrices(); var propertyPricesArray = (JArray)response["properties"]; propertiesList = new List <PropertyCard>(propertyPricesArray.Count); stationsList = new List <StationCard>(propertyPricesArray.Count); utilitiesList = new List <UtilityCard>(propertyPricesArray.Count); foreach (var property in propertyPricesArray) { var propertyName = property["name"].ToString(); var color = property["color"]?.ToString(); var location = (int)property["location"]; var rents = ((JArray)property["rents"]).Select(rent => (int)rent).ToArray(); var mortgage = (int)property["mortgage"]; var type = (int)property["type"]; switch (type) { case 0: { var houseCosts = (JArray)response["houses"]; var houseCost = (int)houseCosts[location / 10]; var card = new PropertyCard(propertyName, color, location, rents, houseCost, mortgage); propertiesList.Add(card); break; } case 1: { var card = new StationCard(propertyName, location, rents, mortgage); stationsList.Add(card); break; } default: { var card = new UtilityCard(propertyName, location, rents, mortgage); utilitiesList.Add(card); break; } } } } catch (Exception e) { Debug.Log(e); // TODO: Show error to player } }
public void AddUtilityCardToDeck(UtilityCard c) { //Debug.Log("AddCardToDeck: " + c.title); GameObject go = Instantiate(c.gameObject); go.GetComponent <UtilityCard>().CopyActionsFrom(c); GameObject hand = GameObject.Find("Deck"); go.transform.SetParent(hand.transform); go.SetActive(false); }
public void AddUtilityCardToDeck(string title) { if (allUtilityCards.ContainsKey(title) == false) { Debug.LogError("No player card with title: " + title); return; } UtilityCard c = allUtilityCards[title]; AddUtilityCardToDeck(c); }
private void Start() { APIWrapper.Instance.GamePrices((response, error) => { if (error == null) { var propertyPricesArray = (JArray) response["properties"]; propertiesList = new List<PropertyCard>(propertyPricesArray.Count); stationsList = new List<StationCard>(propertyPricesArray.Count); utilitiesList = new List<UtilityCard>(propertyPricesArray.Count); foreach (var property in propertyPricesArray) { var name = property["name"].ToString(); var color = property["color"]?.ToString(); var location = (int) property["location"]; var rents = ((JArray) property["rents"]).Select(rent => (int) rent).ToArray(); var mortgage = (int) property["mortgage"]; var type = (int) property["type"]; switch (type) { case 0: { var houseCosts = (JArray) response["houses"]; var houseCost = (int) houseCosts[location / 10]; var card = new PropertyCard(name, color, location, rents, houseCost, mortgage); propertiesList.Add(card); break; } case 1: { var card = new StationCard(name, location, rents, mortgage); stationsList.Add(card); break; } default: { var card = new UtilityCard(name, location, rents, mortgage); utilitiesList.Add(card); break; } } } } else { throw new Exception(error); } }); }
public IEnumerator DisplayCard(int location) { if (GameManager.Instance.Game.CurrentPlayerId == AuthenticationManager.Instance.user.Id) { _buy.SetActive(true); _abandon.SetActive(true); } if (location == 5 || location == 15 || location == 25 || location == 35) { List <StationCard> stationCards = _cardLoader.stationsList; StationCard stationCard = stationCards[0]; foreach (StationCard card in stationCards) { if (card.location == location) { stationCard = card; } } _cards.SetActive(true); GameObject stCard = _cardsList[1]; stCard.SetActive(true); stCard.transform.Find("Name").gameObject.GetComponent <TextMeshProUGUI>().text = stationCard.name; for (int i = 0; i < stationCard.rents.Length; i++) { stCard.transform.Find("Rent" + i).gameObject.GetComponent <TextMeshProUGUI>().text = stationCard.rents[i].ToString(); } stCard.transform.Find("MortgageText").gameObject.GetComponent <TextMeshProUGUI>().text = stationCard.mortgage.ToString(); } else if (location == 12) { List <UtilityCard> utilityCards = _cardLoader.utilitiesList; UtilityCard utilityCard = utilityCards[0]; _cards.SetActive(true); GameObject uCard1 = _cardsList[2]; uCard1.SetActive(true); uCard1.transform.Find("MortgageText").gameObject.GetComponent <TextMeshProUGUI>().text = utilityCard.mortgage.ToString(); } else if (location == 28) { List <UtilityCard> utilityCards = _cardLoader.utilitiesList; UtilityCard utilityCard = utilityCards[0]; _cards.SetActive(true); GameObject uCard2 = _cardsList[3]; uCard2.SetActive(true); uCard2.transform.Find("MortgageText").gameObject.GetComponent <TextMeshProUGUI>().text = utilityCard.mortgage.ToString(); } else { List <PropertyCard> propertyCards = _cardLoader.propertiesList; PropertyCard propertyCard = propertyCards[0]; foreach (PropertyCard card in propertyCards) { if (card.location == location) { propertyCard = card; } } _cards.SetActive(true); foreach (GameObject card in _cardsList) { if (card.name != "PropertyCard") { card.SetActive(false); } else { card.SetActive(true); Color color; ColorUtility.TryParseHtmlString("#" + propertyCard.color, out color); card.transform.Find("Colour").gameObject.GetComponent <Image>().color = color; card.transform.Find("Name").gameObject.GetComponent <TextMeshProUGUI>().text = propertyCard.name; for (int i = 0; i < propertyCard.rents.Length; i++) { card.transform.Find("Rent" + i).gameObject.GetComponent <TextMeshProUGUI>().text = propertyCard.rents[i].ToString(); } card.transform.Find("BookCostText").gameObject.GetComponent <TextMeshProUGUI>().text = propertyCard.houseCost.ToString(); card.transform.Find("DegreeCostText").gameObject.GetComponent <TextMeshProUGUI>().text = propertyCard.houseCost.ToString(); card.transform.Find("MortgageText").gameObject.GetComponent <TextMeshProUGUI>().text = propertyCard.mortgage.ToString(); } } } yield return(new WaitForSeconds(5f)); Abandon(); }
private string FindActionByWeight(UtilityCard utilityCard, int topK) { return(""); }
public void OnDrop(PointerEventData eventData) { d = eventData.pointerDrag.GetComponent <Draggable> (); // GameObject GameController = GameObject.Find ("GameController"); // GameController gameController = GameController.GetComponent<GameController> (); // GameObject ButtonScripts = GameObject.Find ("ButtonsCanvas"); // ButtonScripts buttonScripts = ButtonScripts.GetComponent<ButtonScripts> (); buttonScripts.TurnEverythingFalse(); GameController.control.TurnFalsePlayerButtons(); // Debug.Log("OnDrop cone"); // if (d != null ) { // Debug.Log(d.attack); // attack = d.attack; // movementCost = d.movementCost; // effect = d.effect; d.parentToReturnTo = this.transform; // } mobility = false; // else{ // Debug.Log("OnDrop cone"); // Debug.Log(d.cardType); switch (d.cardType) { case CardTypes.Damage: // GameObject Unit = GameObject.Find(map.selecterPlayer); // Unit unit = Unit.GetComponent<Unit> (); DamageCard damageCard = d.GetComponentInParent <DamageCard>(); // DamageCard damageCard = eventData.pointerDrag.GetComponent<DamageCard>(); Debug.Log(damageCard.DamageType); mobility = damageCard.Mobility; range = damageCard.Range; target = damageCard.Target; areaRange = damageCard.Area; damageType = damageCard.DamageType; GameController.control.cardCost = damageCard.CardCost; DamageType(); effect = damageCard.Effect; RunTargets(); break; case CardTypes.Heal: HealCard healCard = d.GetComponentInParent <HealCard>(); GameObject Player = GameObject.Find(map.selecterPlayer); PlayableCharacter player = Player.GetComponent <PlayableCharacter> (); // DamageCard damageCard = eventData.pointerDrag.GetComponent<DamageCard>(); // mobility = damageCard.Mobility; // buttonScripts.healSelected = true; // playingPlayer = map.selecterPlayer; range = healCard.Range; target = healCard.Target; areaRange = healCard.Area; effect = healCard.Effect; healDot = player.PlayerClass.HealValue / 2; heal = (player.PlayerClass.HealValue * healCard.CardHeal) / 3; GameController.control.cardCost = healCard.CardCost; RunTargets(); break; case CardTypes.Utility: UtilityCard utilityCard = d.GetComponentInParent <UtilityCard>(); // DamageCard damageCard = eventData.pointerDrag.GetComponent<DamageCard>(); // mobility = damageCard.Mobility; range = utilityCard.Range; target = utilityCard.Target; areaRange = utilityCard.Area; effect = utilityCard.Effect; GameController.control.cardCost = utilityCard.CardCost; RunTargets(); break; default: break; } // } //TODO värjää väärin if (d != null) { GameObject HighlightTiles = GameObject.Find("_Scripts"); HighlightTiles highlightTiles = HighlightTiles.GetComponent <HighlightTiles> (); highlightTiles.HighlightTilesInRange(); } }