public static void ResumeTactic(Tactic tactic) { TacticAttributes attributes = Database.FindTacticAttributes(tactic.tacticName); tactic.oreCost = attributes.oreCost; tactic.goldCost = attributes.goldCost; }
public void AddTactic(Tactic tactic) { int count = gameInfo.unusedTactics[Login.playerID].Count; if (count == Lineup.tacticLimit) { StartCoroutine(ShowFullTacticBag()); } else { gameInfo.AddTactic(tactic); tacticObjs[count].parent.gameObject.SetActive(true); int index = 0; if (count != 0) { index = gameInfo.unusedTactics[Login.playerID].IndexOf(tactic); for (int i = count; i > index; i--) { TacticInfo tacticInfo = tacticObjs[i - 1].GetComponent <TacticInfo>(); tacticObjs[i].GetComponent <TacticInfo>().SetAttributes(tacticInfo.tacticAttributes, Login.playerID, tacticInfo.tactic.original); } } TacticAttributes tacticAttributes = Database.FindTacticAttributes(tactic.tacticName); tacticObjs[index].GetComponent <TacticInfo>().SetAttributes(tacticAttributes, Login.playerID, false); tacticTriggers.Insert(index, tacticAttributes.trigger); SetTacticInteractable(); } }
private void TacticAdder(TacticAttributes attributes) { totalOreCost += attributes.oreCost; totalGoldCost += attributes.goldCost; int index = 0; if (current_tactics == 0 || attributes < tacticAttributes[0]) { index = 0; } else if (attributes > tacticAttributes[current_tactics - 1]) { index = current_tactics; } else { for (int i = 0; i < current_tactics - 1; i++) { if (attributes > tacticAttributes[i] && attributes < tacticAttributes[i + 1]) { index = i + 1; break; } } } lineup.tactics.Insert(index, new Tactic(attributes)); tacticAttributes.Insert(index, attributes); tacticObjs[current_tactics++].SetActive(true); for (int i = index; i < current_tactics; i++) { tacticObjs[i].GetComponent <TacticInfo>().SetAttributes(tacticAttributes[i]); } SetTexts(); }
public Collection(TacticAttributes attributes, int Count = 1) { name = attributes.Name; type = "Tactic"; count = Count; health = attributes.goldCost; }
public void SetAttributes(TacticAttributes attributes, int ownerID = -1) { if (attributes == null) { return; } piece = null; tactic = attributes; trap = null; nameText.text = attributes.Name; cardName = attributes.Name; description = attributes.description; descriptionText.text = attributes.description; cost = attributes.oreCost; costText.text = attributes.oreCost.ToString(); costImage.SetActive(true); healthImage.SetActive(false); coinImage.SetActive(true); health = attributes.goldCost; coinText.text = attributes.goldCost.ToString(); image.sprite = attributes.image; type = "Tactic"; typeText.text = type; SetOwner(ownerID); }
public Collection(string tacticName, int Count = 1) { name = tacticName; type = "Tactic"; count = Count; TacticAttributes attributes = Database.FindTacticAttributes(tacticName); health = attributes.goldCost; }
public Tactic(Collection collection, int owner = 0, bool Original = true) { tacticName = collection.name; TacticAttributes attributes = Database.FindTacticAttributes(tacticName); oreCost = attributes.oreCost; goldCost = attributes.goldCost; ownerID = owner; original = Original; }
private void FindAttributes() { //WriteDirectories(); ReadDirectories(); foreach (string type in loadType) { foreach (string folder in directories[type]) { if (type == "Standard Piece") { PieceAttributes attributes = LoadPieceAttributes(folder); standardAttributes.Add(attributes.Name, attributes); } else if (type == "Piece") { PieceAttributes attributes = LoadPieceAttributes(folder); pieces.Add(attributes.Name, attributes); pieceList.Add(attributes.Name); pieceListDict[attributes.type].Add(attributes.Name); } else if (type == "Tactic") { TacticAttributes attributes = LoadTacticAttributes(folder); tactics.Add(attributes.Name, attributes); tacticList.Add(attributes.Name); } else if (type == "Board") { BoardAttributes attributes = LoadBoardAttributes(folder); boards.Add(attributes.Name, attributes); boardList.Add(attributes.Name); } else if (type == "Trap") { TrapAttributes attributes = LoadTrapAttributes(folder); traps.Add(attributes.Name, attributes); trapList.Add(attributes.Name); } else if (type == "Contract") { ContractAttributes attributes = LoadContractAttributes(folder); contracts.Add(attributes.Name, attributes); contractList.Add(attributes.Name); } else if (type == "Mission") { MissionAttributes attributes = LoadMissionAttributes(folder); missions.Add(attributes.Name, attributes); missionList.Add(attributes.Name); } } } }
public void RemoveTactic(TacticAttributes attributes) { // called by user if (current_tactics == 0) { return; } TacticRemover(attributes); collectionManager.AddCollection(new Collection(attributes)); if (collectionManager.currentPage.Key == "Tactic") { collectionManager.ShowCurrentPage(); } }
public void Clear() { piece = null; tactic = null; nameText.text = "Name"; descriptionText.text = "Description"; costText.text = "0"; healthText.text = "0"; healthText.color = Color.white; coinText.text = "0"; image.sprite = null; cardName = type = description = ""; ownerID = -1; }
public Tactic(TacticAttributes tacticAttributes, int owner = 0, bool Original = true) { tacticName = tacticAttributes.Name; oreCost = tacticAttributes.oreCost; goldCost = tacticAttributes.goldCost; if (owner == 0) { ownerID = Login.playerID; } else { ownerID = owner; } original = true; }
public void SetCards() { Login.user.ChangeContracts(targetContract.name, -contractCount, false); List <string> types = Database.FindContractAttributes(targetContract.name).cardTypes; for (int i = 0; i < contractCount * 5; i++) { string type = types[Random.Range(0, types.Count)]; Collection collection; if (type == "Tactic") { string tactic = Database.tacticList[Random.Range(0, Database.tacticList.Count)]; TacticAttributes attributes = Database.FindTacticAttributes(tactic); collection = new Collection(attributes); cardView.transform.Find("Card" + i.ToString()).GetComponent <CardInfo>().SetAttributes(collection); } else { int luck = Random.Range(0, 100); List <string> pieces = Database.pieceListDict[type]; string piece = pieces[Random.Range(0, pieces.Count)]; PieceAttributes attributes = Database.FindPieceAttributes(piece); collection = new Collection(attributes); if (luck > 85) { collection.health += (int)Mathf.Ceil(collection.health * 0.1f); } if (luck > 90) { collection.health += (int)Mathf.Ceil(collection.health * 0.1f); } if (luck > 95) { collection.health += (int)Mathf.Ceil(collection.health * 0.1f); } CardInfo cardInfo = cardView.transform.Find("Card" + i.ToString()).GetComponent <CardInfo>(); cardInfo.SetAttributes(attributes); cardInfo.SetHealth(collection.health); } Login.user.AddCollection(collection, false); } Login.user.Upload(); contractCount = 0; }
public Collection(string Name, string Type, int Count = 1, int Health = 0) { name = Name; type = Type; count = Count; health = Health; if (Type == "Tactic") { TacticAttributes attributes = Database.FindTacticAttributes(Name); health = attributes.goldCost; } else if (!Name.StartsWith("Standard ")) { PieceAttributes attributes = Database.FindPieceAttributes(Name); if (Health == 0) { health = attributes.health; } } }
public void SetAttributes(TacticAttributes attributes, int ownerID = 0, bool original = true) { tacticAttributes = attributes; if (ownerID == 0) { ownerID = Login.playerID; } tactic = new Tactic(attributes.Name, attributes.oreCost, attributes.goldCost, ownerID, original); if (tacticAttributes.trigger != null) { trigger = Instantiate(tacticAttributes.trigger); } if (tacticAttributes.trigger != null) { trigger.tactic = tactic; } nameText.text = attributes.Name; SetOreCost(attributes.oreCost); SetGoldCost(attributes.goldCost); image.sprite = attributes.image; }
public void SetAttributes(TrapAttributes attributes, int ownerID = -1) { if (attributes == null) { return; } piece = null; tactic = null; trap = attributes; nameText.text = attributes.Name; cardName = attributes.Name; description = attributes.description; descriptionText.text = attributes.description; costImage.SetActive(false); healthImage.SetActive(false); coinImage.SetActive(false); image.sprite = attributes.image; type = "Trap"; typeText.text = type; SetOwner(ownerID); }
private void TacticRemover(TacticAttributes attributes) { Tactic remove = new Tactic(attributes); int index = FindTactic(remove.tacticName); totalOreCost -= attributes.oreCost; totalGoldCost -= attributes.goldCost; if (current_tactics > 1) { for (int i = index; i < current_tactics - 1; i++) { tacticObjs[i].GetComponent <TacticInfo>().SetAttributes(tacticAttributes[i + 1]); } } else { tacticObjs[0].GetComponent <TacticInfo>().Clear(); } lineup.tactics.RemoveAt(index); tacticAttributes.RemoveAt(index); tacticObjs[--current_tactics].SetActive(false); SetTexts(); }
public bool Equals(TacticAttributes attributes) { return(new Tactic(this) == new Tactic(attributes)); }