public void AssignTrait(Trait newTrait) { assignedTrait=newTrait; nameText.text=newTrait.name; GetComponent<Button>().onClick.RemoveAllListeners(); if (assignedTrait.GetType().BaseType==typeof(Trait)) GetComponent<Button>().image.color=Color.white; else { Skill assignedSkill=assignedTrait as Skill; if (assignedSkill.learned) GetComponent<Button>().image.color=Color.white; else { if (InventoryScreenHandler.mainISHandler.selectedMember.skillpoints<1) GetComponent<Button>().image.color=Color.gray; else { GetComponent<Button>().image.color=Color.green; GetComponent<Button>().onClick.AddListener( ()=> { //if (InventoryScreenHandler.mainISHandler.selectedMember.skillpoints>=1) { //Order is important InventoryScreenHandler.mainISHandler.selectedMember.ActivateSkill(assignedSkill); InventoryScreenHandler.mainISHandler.selectedMember.skillpoints--; InventoryScreenHandler.mainISHandler.RefreshInventoryItems(); } }); } } } }
private void PurchaseTrait(Trait trait) { if (UnlockedTraits.Contains(trait.GetType())) { return; } var cost = trait.Cost; if (EvolutionPoints < cost) { return; } Debug.Log("Purchased " + trait.Name); EvolutionPoints -= cost; UnlockedTraits.Add(trait.GetType()); CreateTraitSelectionGui(); }
public void MoveTrait(GameObject newObj) { if (selectedTrait == null) { return; } print("MOVE TRAIT " + selectedTrait.GetName()); newObj.AddComponent(selectedTrait.GetType()); selectedTrait.Remove(); //TODO: properly repopulate appropriate lists DisableTraitsMode(); EnableTraitsMode(); }