/// <summary> /// /// </summary> void Start() { gameState = GameState.OpenWorld; openWorldCharacter = Instantiate(OpenWorldCharacterPrefab, new Vector3(0, 0, -35), Quaternion.identity) as GameObject; //TODO: debug stuff for combat so we have a party, shouldnt be here PartyUnit newUnit = ScriptableObject.CreateInstance <PartyUnit> (); newUnit.UnitPrefab = Resources.Load("Characters/Hero") as GameObject; newUnit.MovementDistance = 4; newUnit.Health = 150; newUnit.UnitClass = PlayerControlledBoardUnit.PlayerClass.Support; newUnit.ListOfAbilities.Add(Instantiate(Resources.Load <AbilityDescription> ("Abilities/Support/ElectromagneticField")) as AbilityDescription); newUnit.ListOfAbilities.Add(Instantiate(Resources.Load <AbilityDescription> ("Abilities/Support/ConcussiveBlast")) as AbilityDescription); newUnit.ListOfAbilities.Add(Instantiate(Resources.Load <AbilityDescription> ("Abilities/Support/StaticShell")) as AbilityDescription); newUnit.ListOfAbilities.Add(Instantiate(Resources.Load <AbilityDescription> ("Abilities/Support/PulseForce")) as AbilityDescription); newUnit.currentLevel = 1; newUnit.UnitTalentTree = Instantiate(Resources.Load <TalentTree> ("TalentTrees/WarriorTree")) as TalentTree; CurrentParty.Add(newUnit); newUnit = ScriptableObject.CreateInstance <PartyUnit> (); newUnit.UnitPrefab = Resources.Load("Characters/Hero") as GameObject; newUnit.MovementDistance = 4; newUnit.ListOfAbilities.Add(Instantiate(Resources.Load <AbilityDescription> ("Abilities/Wizard/RadiantEnergy")) as AbilityDescription); newUnit.ListOfAbilities.Add(Instantiate(Resources.Load <AbilityDescription> ("Abilities/Wizard/CircuitBreak")) as AbilityDescription); newUnit.ListOfAbilities.Add(Instantiate(Resources.Load <AbilityDescription> ("Abilities/Wizard/StaticGrip")) as AbilityDescription); newUnit.ListOfAbilities.Add(Instantiate(Resources.Load <AbilityDescription> ("Abilities/Wizard/FluxBlast")) as AbilityDescription); newUnit.Health = 120; newUnit.UnitClass = PlayerControlledBoardUnit.PlayerClass.Wizard; newUnit.currentLevel = 1; newUnit.UnitTalentTree = Instantiate(Resources.Load <TalentTree> ("TalentTrees/WizardTree")) as TalentTree; CurrentParty.Add(newUnit); CurrentPowerUps.Add(Instantiate(Resources.Load <PowerUp> ("PowerUps/MoveSpeed")) as PowerUp); }
void TryToDismissUnit(PartyUnit unit) { // this depends on the fact if unit is dismissable // for example Capital guard is not dimissable // all other units normally are dismissable if (unit.IsDismissable) { // as for confirmation string confirmationMessage; // verify if this is party leader if (unit.IsLeader) { confirmationMessage = "Dismissing party leader will permanently dismiss whole party and all its members. Do you want to dismiss " + unit.GivenName + " " + unit.UnitName + " and whole party?"; } else { confirmationMessage = "Do you want to dismiss " + unit.UnitName + "?"; } // send actions to Confirmation popup, so he knows how to react on no and yes btn presses ConfirmationPopUp.Instance().Choice(confirmationMessage, new UnityAction(OnDismissYesConfirmation), new UnityAction(OnDismissNoConfirmation)); } else { // display error message NotificationPopUp.Instance().DisplayMessage("It is not possible to dismiss " + unit.GivenName + " " + unit.UnitName + "."); } }
void CreateTalentTree(PartyUnit unit) { if (debug) { Debug.Log("Talent Tree: " + unit.UnitTalentTree.name); Debug.Log("Talent Count: " + unit.UnitTalentTree.Tree.Count); } GameObject talentTreeAnchor = new GameObject("TalentTreeAnchor"); int row = 0; int collum = 0; //Initilize Icons for (int i = 0; i < unit.UnitTalentTree.Tree.Count; i++) { collum = i % 3 + 1; row = (int)(i / 3) + 1; GameObject talentIcon = Instantiate(GUIIcon, new Vector3(collum, -row * 1.125f, 0), Quaternion.identity) as GameObject; TalentIcon talentIconCached = talentIcon.GetComponent <TalentIcon> (); talentIconCached.Initilize(CurrentlyDisplayedPartyUnit, unit.UnitTalentTree.Tree [i], collum, row); talentIcon.transform.parent = talentTreeAnchor.transform; talentIconCached.pm = this; } //Set Transform talentTreeAnchor.transform.parent = TalentAnchorPoint; talentTreeAnchor.transform.localPosition = Vector3.zero; talentTreeAnchor.transform.localRotation = Quaternion.identity; talentTreeAnchor.transform.localScale = Vector3.one * 0.52f; //Set Array talentIcons = GetComponentsInChildren <TalentIcon> (); TalentWindow.SetActive(false); }
void SetUnitDefenseInfo(PartyUnit partyUnit) { // Get defense text Text attributeText = transform.Find("Panel/UnitDefense/Value").GetComponent <Text>(); // display effective defense attributeText.text = partyUnit.GetEffectiveDefense().ToString(); // verify if base unit defense does not equal to effective defense if (partyUnit.GetEffectiveDefense() != partyUnit.UnitBaseDefense) { // Display how defense is calculated // open brackets attributeText.text += "("; // set base unit defense without bonuses attributeText.text += baseStatPreviewStyleStart + partyUnit.UnitBaseDefense.ToString() + baseStatPreviewStyleEnd; // get and add defense skill bonus to text AddBonusInfoToText(attributeText, partyUnit.GetSkillDefenseBonus(), skillBonusPreviewStyleStart, skillBonusPreviewStyleEnd); // get and add items bonus AddBonusInfoToText(attributeText, partyUnit.GetItemsDefenseBonus(), itemBonusPreviewStyleStart, itemBonusPreviewStyleEnd); // get and add city bonus to text AddBonusInfoToText(attributeText, partyUnit.GetCityDefenseBonus(), cityBonusPreviewStyleStart, cityBonusPreviewStyleEnd); // get and add status bonus (example: defense stance) to text AddBonusInfoToText(attributeText, (int)(partyUnit.GetDefensiveStanceBonus() * (100 - partyUnit.GetTotalAdditiveDefense())), statusBonusPreviewStyleStart, statusBonusPreviewStyleEnd); // not needed - stats do no give defense bonus // close brackets attributeText.text += ")"; } }
public void SetUnitPowerInfo(PartyUnit partyUnit) { // Get power text Text powerText = transform.Find("Panel/AbilityParameters/Power").GetComponent <Text>(); // Get party unit effective power value int effectivePower = partyUnit.GetUnitEffectivePower(); // Display effective power absolute value powerText.text = Math.Abs(effectivePower).ToString(); // get base power value int basePower = partyUnit.UnitAbilityEffectivePower - GetStatsPowerBonus(partyUnit); // verify if effective power does not equal to base power if (effectivePower != basePower) { // Display additional modifiers between brackets powerText.text += "("; // set default unit power without bonuses (without just upgraded stats power bonus) powerText.text += baseStatPreviewStyleStart + Math.Abs(basePower).ToString() + baseStatPreviewStyleEnd; // get and add stats power bonus if it is present AddBonusInfoToText(powerText, Math.Abs(GetStatsPowerBonus(partyUnit)), statsBonusPreviewStyleStart, statsBonusPreviewStyleEnd); // get and add offence skill bonus to text AddBonusInfoToText(powerText, Math.Abs(partyUnit.GetOffenceSkillPowerBonus()), skillBonusPreviewStyleStart, skillBonusPreviewStyleEnd); // get and add items bonus to the text AddBonusInfoToText(powerText, Math.Abs(partyUnit.GetItemsPowerBonus()), itemBonusPreviewStyleStart, itemBonusPreviewStyleEnd); // close brackets powerText.text += ")"; } }
ValidationResult DoDiscardModifierInContextOf(System.Object srcContext, System.Object dstContext) { // verify if source or destination context do not match requirements of this limiter if (!DoesContextMatch(srcContext, dstContext)) { // context is not in scope of this limiter // don't limit return(ValidationResult.Pass()); } //// verify if destination context is of InventorySlotDropHandler type //if (dstContext is InventorySlotDropHandler) //{ // // ignore this limiter (don't discard) // return false; //} // set context to party unit PartyUnit dstPartyUnit = (PartyUnit)dstContext; // loop through all required statuses foreach (UnitStatus matchStatus in requiredAnyOfUnitStatus) { if (dstPartyUnit.UnitStatus == matchStatus) { // don't limit return(ValidationResult.Pass()); } } // No any of required statuses match - discard modifier return(ValidationResult.Discard(onDiscardMessage)); }
int GetLeadershipConsumedByPartyUnitsExcludingLeader(PartyUnit partyUnit) { // get unit party HeroParty heroParty = partyUnit.GetUnitParty(); // verify if unit is member of party if (heroParty != null) { Debug.LogWarning("!!Convert UnitSize to class!!"); return(heroParty.GetLeadershipConsumedByPartyUnits() - (int)heroParty.GetPartyLeader().UnitSize - 1); } else { Debug.Log("Unit without party"); return(0); } //// structure 5PartyPanel-4Row-3Cell-2UnitSlot-1UnitCanvas-Unit //PartyPanel partyPanel = null; //if (partyUnit.transform.parent) // if (partyUnit.transform.parent.parent) // if (partyUnit.transform.parent.parent.parent) // if (partyUnit.transform.parent.parent.parent.parent) // if (partyUnit.transform.parent.parent.parent.parent.parent) // partyPanel = partyUnit.transform.parent.parent.parent.parent.parent.GetComponent<PartyPanel>(); //if (partyPanel != null) //{ // return partyPanel.GetNumberOfPresentUnits() - 1; //} //else //{ // return 0; //} }
PartyUnit HireGenericUnit(PartyUnit hiredUnitTemplate, HeroParty heroParty, Transform destinationUnitSlotTransform, bool doCreateUI = true) { // create unit in HeroParty PartyUnit newPartyUnit = Instantiate(hiredUnitTemplate, heroParty.transform).GetComponent <PartyUnit>(); // Set new unit cell address newPartyUnit.PartyUnitData.unitPPRow = destinationUnitSlotTransform.GetComponent <UnitSlot>().GetUnitPPRow(); newPartyUnit.PartyUnitData.unitPPCell = destinationUnitSlotTransform.GetComponent <UnitSlot>().GetUnitPPCell(); // Reset new unit current health to max newPartyUnit.ResetCurrentHealth(); // Reset new unit current move points to max newPartyUnit.ResetCurrentMovePointsNumber(); // take gold from player TurnsManager.Instance.GetActivePlayer().TotalGold -= hiredUnitTemplate.UnitCost; if (doCreateUI) { // create unit canvas in unit slot PartyUnitUI partyUnitUI = Instantiate(unitCanvasTemplate, destinationUnitSlotTransform).GetComponent <PartyUnitUI>(); // link unit to unit canvas partyUnitUI.LPartyUnit = newPartyUnit; // Activate PartyUnitUI (canvas) partyUnitUI.gameObject.SetActive(true); } // return result return(newPartyUnit); }
/// Setup party for debugging so you dont have to run it from the open world every time void SetupParty() { PartyUnit newUnit = ScriptableObject.CreateInstance <PartyUnit> (); newUnit.UnitPrefab = Resources.Load("Characters/Hero") as GameObject; newUnit.MovementDistance = 3; newUnit.Health = 60; newUnit.UnitClass = PlayerControlledBoardUnit.PlayerClass.Warrior; newUnit.ListOfAbilities.Add(Instantiate(Resources.Load <AbilityDescription> ("Abilities/TestDamageSlow")) as AbilityDescription); newUnit.ListOfAbilities.Add(Instantiate(Resources.Load <AbilityDescription> ("Abilities/TestHeal")) as AbilityDescription); newUnit.ListOfAbilities.Add(Instantiate(Resources.Load <AbilityDescription> ("Abilities/TestHeal")) as AbilityDescription); newUnit.ListOfAbilities.Add(Instantiate(Resources.Load <AbilityDescription> ("Abilities/TestStun")) as AbilityDescription); newUnit.currentLevel = 1; newUnit.UnitTalentTree = Instantiate(Resources.Load <TalentTree> ("TalentTrees/WarriorTree")) as TalentTree; currentParty.Add(newUnit); newUnit = ScriptableObject.CreateInstance <PartyUnit> (); newUnit.UnitPrefab = Resources.Load("Characters/Hero") as GameObject; newUnit.MovementDistance = 4; newUnit.ListOfAbilities.Add(Instantiate(Resources.Load <AbilityDescription> ("Abilities/TestDamageSlow")) as AbilityDescription); newUnit.ListOfAbilities.Add(Instantiate(Resources.Load <AbilityDescription> ("Abilities/TestHeal")) as AbilityDescription); newUnit.ListOfAbilities.Add(Instantiate(Resources.Load <AbilityDescription> ("Abilities/TestStun")) as AbilityDescription); newUnit.Health = 65; newUnit.UnitClass = PlayerControlledBoardUnit.PlayerClass.Wizard; newUnit.currentLevel = 1; newUnit.UnitTalentTree = Instantiate(Resources.Load <TalentTree> ("TalentTrees/WizardTree")) as TalentTree; currentParty.Add(newUnit); }
public List <UniquePowerModifierData> GetPropagatedBonuses(PartyUnit dstPartyUnit) { Debug.Log("GetPropagatedBonuses " + CityConfig.cityName); // by default city gives only defense bonus to all units inside // init list of UPMs data List <UniquePowerModifierData> upmsData = new List <UniquePowerModifierData>(); // set propagation context CityPropagationContext propagationContext = new CityPropagationContext(this, dstPartyUnit); // loop through all unique powe modifier configs for (int i = 0; i < UniquePowerModifierConfigs.Count; i++) { Debug.Log("city upm " + UniquePowerModifierConfigs[i].DisplayName); // Verify if UPM is applicable to destination party unit if (UniquePowerModifierConfigs[i].AreRequirementsMetInContextOf(propagationContext).doDiscardModifier == false) { // create new UPM data based on UPM config and destination party unit upmsData.Add(new UniquePowerModifierData { uniquePowerModifierID = new UniquePowerModifierID { cityID = cityData.cityID, uniquePowerModifierConfigIndex = i, modifierOrigin = ModifierOrigin.City, destinationGameObjectID = dstPartyUnit.gameObject.GetInstanceID() }, durationLeft = UniquePowerModifierConfigs[i].UpmDurationMax, // normally duration type is permanent, so this value is not relevant currentPower = UniquePowerModifierConfigs[i].GetUpmEffectivePower(this) // Updater will take care about current city level }); Debug.LogWarning("Propagate [" + cityData.cityID + "] City UPM [" + UniquePowerModifierConfigs[i].DisplayName + "] power [" + UniquePowerModifierConfigs[i].GetUpmEffectivePower(this) + "] to [" + dstPartyUnit.UnitName + "] unit"); } } // return the list with UPMs data return(upmsData); }
// default update public override UnitStatModifierConfig GetUpdatedUSMC(UnitStatModifierConfig unitStatModifierConfig, System.Object context) { // get party unit from gameObject //PartyUnit partyUnit = context.GetComponent<PartyUnit>(); // verify if party unit is not null //if (partyUnit != null) if (DoesContextMatch(context)) { // init PartyUnit from context PartyUnit partyUnit = (PartyUnit)context; // copy current USM config (to not make changes on default one) UnitStatModifierConfig newUSMConfig = Instantiate(unitStatModifierConfig); // get party unit stats upgrade count int skillLevel = partyUnit.GetUnitSkillData(associatedUnitSkillID).currentSkillLevel; // update to current USM config power based on calculation type newUSMConfig.modifierPower = Mathf.RoundToInt(newUSMConfig.modifierPower + newUSMConfig.modifierPower * skillLevel * percentToBase / 100f); // return new USM config return(newUSMConfig); } else { //Debug.LogError("Party Unit reference is null"); Debug.LogError("Context doesn't match"); } return(unitStatModifierConfig); }
// default update public override UnitStatModifierConfig GetUpdatedUSMC(UnitStatModifierConfig unitStatModifierConfig, System.Object context) { // get party unit from gameObject //PartyUnit partyUnit = context.GetComponent<PartyUnit>(); // verify if party unit is not null //if (partyUnit != null) // verify if context match if (DoesContextMatch(context)) { // init PartyUnit from context PartyUnit partyUnit = (PartyUnit)context; // copy current USM config (to not make changes on default one) UnitStatModifierConfig newUSMConfig = Instantiate(unitStatModifierConfig); // get party unit stats upgrade count int statsUpgradeCount = partyUnit.StatsUpgradesCount; // update to current USM config power newUSMConfig.modifierPower += powerIncrementOnStatsUpgrade * statsUpgradeCount; // return new USM config return(newUSMConfig); } else { // Debug.LogError("Party Unit reference is null"); Debug.LogError("Context doesn't match"); } return(unitStatModifierConfig); }
protected void CreateUnit(PartyUnit unit) { if (unit != null) { CurrentlyDisplayedPartyUnit = unit; if (debug) { Debug.Log(string.Format(":Loaded Character:" + "Name: {0} " + "Level: {1} ", unit.name, unit.currentLevel)); } unit.currentLevel = 5; GameObject obj = Instantiate(unit.UnitPrefab) as GameObject; if (obj.GetComponent <MyHeroController3rdPerson> ()) { Destroy(obj.GetComponent <MyHeroController3rdPerson> ()); } obj.transform.position = UnitAnchorPoint.position; obj.transform.parent = UnitAnchorPoint; NamePlate.GetComponent <UnitNamePlateGUI> ().Initilize(unit); CreateTalentTree(unit); } else { NamePlate.SetActive(false); Stats.SetActive(false); TalentWindow.SetActive(false); } }
public void ActivateAdvance(PartyUnit partyUnit, Align align = Align.Middle, bool isInterractible = true, ContentMode mode = ContentMode.Full, BackgroundIntermediate.Mode backgroundMode = BackgroundIntermediate.Mode.MiddleScreen) { // verify party unit is not null, if it is null, // then user right clicked on a cell without unit if (partyUnit) { ActivateUnitInfoPanel(partyUnit, backgroundMode); SetAlign(align); interactable = isInterractible; if (mode == ContentMode.Full) { // activate full mode Br transform.Find("BrFull").gameObject.SetActive(true); // deactivate short mode Br transform.Find("BrShort").gameObject.SetActive(false); // activate unit description transform.Find("Panel/UnitDescription").gameObject.SetActive(true); } else if (mode == ContentMode.Short) { // deactivate full mode Br transform.Find("BrFull").gameObject.SetActive(false); // activate short mode Br transform.Find("BrShort").gameObject.SetActive(true); // deactivate unit description transform.Find("Panel/UnitDescription").gameObject.SetActive(false); } else { Debug.LogError("Unknown mode: " + mode.ToString()); } } }
void HirePartyLeader(PartyUnit hiredUnitTemplate, bool doCreateUI = true, City city = null) { // create new party HeroPartyUI newHeroPartyUI = CreateNewPartyInCity(city); // Get unit's slot transform Transform newUnitParentSlot = newHeroPartyUI.GetComponentInChildren <PartyPanel>(true).GetUnitSlotTr(PartyPanel.Row.Middle, GetHiredLeaderDestinationSlotName(hiredUnitTemplate)); // Hire unit, but do not create canvas, because it will be done automatically by HeroParty on enable PartyUnit newPartyLeader = HireGenericUnit(hiredUnitTemplate, newHeroPartyUI.LHeroParty, newUnitParentSlot, false); // Rename hero party, when we know the leader newHeroPartyUI.LHeroParty.gameObject.name = newPartyLeader.GivenName + " " + newPartyLeader.UnitName + " Party"; // Create hero's representation on the map // prerequisites: party leader should be created beforehand SetHeroPartyRepresentationOnTheMap(newHeroPartyUI.LHeroParty, city); if (doCreateUI) { // Activate HeroPartyUI newHeroPartyUI.gameObject.SetActive(true); // trigger onDisable focus panel function so it reset its state transform.root.Find("MiscUI/LeftFocus").GetComponent <FocusPanel>().OnDisable(); // link party leader to the Left Focus panel so it can use it to fill in information transform.root.Find("MiscUI/LeftFocus").GetComponent <FocusPanel>().focusedObject = newHeroPartyUI.GetPartyLeaderUI().gameObject; // trigger onEnable focus panel so it get linked unit data and update its information transform.root.Find("MiscUI/LeftFocus").GetComponent <FocusPanel>().OnEnable(); // Disable Hire leader panel transform.parent.Find("HireHeroPanel").gameObject.SetActive(false); } }
public void DisplayHeroEquipmentUsableInventory() { // get party leader PartyUnit partyLeader = GetComponentInParent <HeroPartyUI>().LHeroParty.GetPartyLeader(); // verify if party leader exists (it may not exist in city garnizon) if (partyLeader != null) { // get all usable items from party leader equipment foreach (Transform childTransform in GetComponentInParent <HeroPartyUI>().LHeroParty.GetPartyLeader().transform) { // get item InventoryItem inventoryItem = childTransform.GetComponent <InventoryItem>(); // verify if this is an item if (inventoryItem != null) { // verify if item is in hero eqipment slot and that it is usable if (inventoryItem.CurrentHeroEquipmentSlot != HeroEquipmentSlots.None && inventoryItem.IsUsable) { SetItemRepresentationInInventoryUI(childTransform.GetComponent <InventoryItem>(), true); } } } } }
public void SetActive(bool doActivate) { if (doActivate) { // get active player faction Faction activePlayerFaction = TurnsManager.Instance.GetActivePlayer().Faction; // loop through all heroparties foreach (HeroParty heroParty in ObjectsManager.Instance.GetComponentsInChildren <HeroParty>(true)) { // verify if hero party belongs to the player's faction and if it is not garnizon if ((heroParty.Faction == activePlayerFaction) && (heroParty.PartyMode == PartyMode.Party)) { // get leader PartyUnit partyLeaderUnit = heroParty.GetPartyLeader(); // create and activate leader info Instantiate(playerHeroInfoTemplate, playerHeroesListTransform).GetComponent <PlayerHeroInfo>().SetActive(partyLeaderUnit); } } } else { // remove all heroes infos foreach (PlayerHeroInfo playerHeroInfo in GetComponentsInChildren <PlayerHeroInfo>()) { Destroy(playerHeroInfo.gameObject); } } }
ValidationResult DoDiscardModifierInContextOf(System.Object srcContext, System.Object dstContext) { // verify if source or destination context do not match requirements of this limiter if (!DoesContextMatch(srcContext, dstContext)) { // context is not in scope of this limiter // don't limit return(ValidationResult.Pass()); } //// verify if destination context is of InventorySlotDropHandler type //if (dstContext is InventorySlotDropHandler) //{ // // ignore this limiter (don't discard) // return false; //} // get destination context as PartyUnit if (dstContext is PartyUnit) { PartyUnit dstPartyUnit = (PartyUnit)dstContext; // verify if destination unit health is already max if (dstPartyUnit.UnitHealthCurr >= dstPartyUnit.GetUnitEffectiveMaxHealth()) { // limit return(ValidationResult.Discard(onDiscardMessage)); } } // don't limit return(ValidationResult.Pass()); }
internal void FillFourthPage(IEnumerable <FourthPage> completelist) { foreach (var item in completelist) { AddPartyBtn.Clicks(); waitForPageUntilElementIsVisible(By.Id("input_7_14"), 8); PartyEmpNo.EnterText(item.EmployeeNumber); PartyFName.EnterText(item.FirstName); PartMInitial.EnterText(item.MiddleName); PartyLName.EnterText(item.LastName); PartyTitle.EnterText(item.Title); PartyUnit.EnterText(item.UnitOfAssignmnet); PartyWorkPhone.EnterText(item.WorkPhone); PartyExt.EnterText(item.Extension); PartyMobileNo.EnterText(item.MobileNumber); PartyWorkHr.EnterText(item.WorkHours); PartyRDO.EnterText(item.RDO); PartyDept.EnterText(item.Department); PartySupervisorFN.EnterText(item.SFName); PartySupervisorMI.EnterText(item.SMName); PartySupervisorLN.EnterText(item.SLN); PartySupervisorPhNo.EnterText(item.SPhoneNumber); PartyPopupSubmitBtn.Clicks(); } FourthNextBtn.Clicks(); }
public void HireUnit(Transform callerCell, UnitType hiredUnitType, bool doCreateUI = true, City city = null) { // get template for selected unit type PartyUnit hiredUnitTemplate = TemplatesManager.Instance.GetPartyUnitTemplateByType(hiredUnitType).GetComponent <PartyUnit>(); // 1 do basic verications, which are applicable to every hired unit if (VerifyIfPlayerHasEnoughGoldToBuyUnit(hiredUnitTemplate)) { // 2 act based on the unit type: leader or normal unit if (hiredUnitTemplate.IsLeader) { HirePartyLeader(hiredUnitTemplate, doCreateUI, city); } else { // act based on the unit type if (UnitSize.Single == hiredUnitTemplate.UnitSize) { HireSingleUnit(callerCell, hiredUnitTemplate, doCreateUI); } else { HireDoubleUnit(callerCell, hiredUnitTemplate, doCreateUI); } } } }
public void OnMaxHealthChanged(PartyUnit partyUnit) { // verify if party unit is this if (partyUnit == LPartyUnit) { UpdateUnitMaxHealthInfo(); } }
void SetPartyLeaderMovePointsInfo(MapHero mapHero) { // get party leader PartyUnit partyLeader = mapHero.LHeroParty.GetPartyLeader(); // Set UI text focusedObjectInfoText.text = partyLeader.MovePointsCurrent + "/" + partyLeader.GetEffectiveMaxMovePoints() + " Move Points"; }
public void OnAbilityApply(PartyUnit appliedToPartyUnit, UnitAbility unitAbility) { // verify if party unit to which modifier has been applied is the same as current if (appliedToPartyUnit == LPartyUnit) { unitAbility.textAnimation.Run(UnitInfoPanelText); } }
//============================================================================ // Initilization //============================================================================ public void Initilize(PartyUnit unit) { NameText.text = unit.Name; LevelText.text = unit.currentLevel.ToString(); name = unit.Name; level = unit.currentLevel; }
//public void OnItemHasBeenDroppedIntoTheUnitSlotEvent(System.Object unitSlotDropHandlerObj) //{ // // verify if type is correct // if (!(unitSlotDropHandlerObj is UnitSlotDropHandler)) // { // Debug.LogError("unitSlotDropHandler is not of UnitSlotDropHandler type"); // return; // } // // init unit slot drop handler // UnitSlotDropHandler unitSlotDropHandler = (UnitSlotDropHandler)unitSlotDropHandlerObj; // // init item config // List<UniquePowerModifierConfig> uniquePowerModifierConfigsSortedByExecutionOrder = InventoryItemDragHandler.itemBeingDragged.LInventoryItem.InventoryItemConfig.UniquePowerModifierConfigsSortedByExecutionOrder; // // verify if this UPM can be applied to destination unit // if (InventoryItemDragHandler.itemBeingDragged.LInventoryItem.InventoryItemConfig.PrimaryUniquePowerModifierConfig.AreRequirementsMetInContextOf(unitSlotDropHandler, LPartyUnit)) // { // // get source context // System.Object srcContext = GetItemBeingDraggedSourceContext(); // // apply unit unique power modifiers (buffs, debuffs, etc) // for (int i = 0; i < uniquePowerModifierConfigsSortedByExecutionOrder.Count; i++) // { // // verify if UPM can be applied to destination unit // if (uniquePowerModifierConfigsSortedByExecutionOrder[i].AreRequirementsMetInContextOf(srcContext, LPartyUnit)) // { // // set unique power modifier ID // UniquePowerModifierID uniquePowerModifierID = new UniquePowerModifierID() // { // inventoryItemID = InventoryItemDragHandler.itemBeingDragged.LInventoryItem.InventoryItemConfig.inventoryItemID, // uniquePowerModifierConfigIndex = i, // modifierOrigin = ModifierOrigin.Item, // destinationGameObjectID = this.gameObject.GetInstanceID() // }; // // apply upm // uniquePowerModifierConfigsSortedByExecutionOrder[i].Apply(InventoryItemDragHandler.itemBeingDragged.LInventoryItem, LPartyUnit, uniquePowerModifierID); // // run text animation // uniquePowerModifierConfigsSortedByExecutionOrder[i].UniquePowerModifierUIConfig.OnTriggerUPMTextAnimation.Run(UnitInfoPanelText); // } // } // } // //// verify if it the slot where item has been dropped is the same where this party unit UI is located // //if (GetComponentInParent<UnitSlotDropHandler>().GetInstanceID() == unitSlotDropHandler.GetInstanceID()) // //{ // // Debug.Log("Same slot"); // // Debug.Log("Act on Item Drop"); // // InventoryItemDragHandler inventoryItemDragHandler = InventoryItemDragHandler.itemBeingDragged; // // // get item // // InventoryItem inventoryItem = inventoryItemDragHandler.LInventoryItem; // // // verify if item has active modifiers or usages // // if (inventoryItem.HasActiveModifiers()) // // { // // Debug.Log("Apply item's UniquePowerModifier(s) and UnitStatModifier(s) to the party unit and its UI"); // // // consume item and verify if it was successfull // // if (lPartyUnit.UseItem(inventoryItem)) // // { // // // successfully consumed item // // // update UI based on changed party unit data // // UpdateUnitCellInfo(); // // // item has run out of usages // // if (inventoryItem.LeftUsagesCount == 0) // // { // // // there are no usages left // // Debug.Log("Move item to the unit"); // // // move item to the unit, there are still might be non-instant upms and usms // // inventoryItem.transform.SetParent(LPartyUnit.transform); // // // Get PartyInventoryUI (before InventoryItemDragHandler is destroyed) // // PartyInventoryUI partyInventoryUI = inventoryItemDragHandler.ItemBeindDraggedSlot.GetComponentInParent<PartyInventoryUI>(); // // // verify if it is not null // // if (partyInventoryUI != null) // // { // // // Note: inventoryItemDragHandler removal will suppress On End Item Drag event // // // .. workaround: // // // call on end drag manually before removing item // // inventoryItemDragHandler.OnEndDrag(null); // // // remove item drag handler // // RecycleBin.Recycle(inventoryItemDragHandler.gameObject); // // // reorganize inventory UI // // partyInventoryUI.ReorganizeInventoryUI(); // // } // // else // // { // // Debug.LogError("Logic error. Probably source slot is not party of PartyInventoryUI, but can be part of Equipment Menu"); // // } // // //// Get source item slot transform // // //ItemSlotDropHandler srcItemSlot = inventoryItemDragHandler.ItemBeindDraggedSlot; // // //// verify if source slot is in party inventory mode // // //if (srcItemSlot.SlotMode == ItemSlotDropHandler.Mode.PartyInventory) // // //{ // // // // Get PartyInventoryUI (before slot is destroyed) // // // PartyInventoryUI partyInventoryUI = srcItemSlot.GetComponentInParent<PartyInventoryUI>(); // // // // remove all empty slots in inventory to fill in possible gaps after item consumption // // // partyInventoryUI.RemoveAllEmptySlots(); // // // // fill in empty slots in inventory; // // // partyInventoryUI.FillInEmptySlots(); // // //} // // } // // else // // { // // // there are still usages left // // Debug.Log("Clone item to the unit"); // // // clone item and place it into the unit // // // so non-instant modifiers can be applied // // // and assign inventoryItem varible with new inventory item // // // inventoryItem = Instantiate(inventoryItem.gameObject, this.transform).GetComponent<InventoryItem>(); // // inventoryItem = Instantiate(inventoryItem.gameObject, LPartyUnit.transform).GetComponent<InventoryItem>(); // // // old inventory item, which was clonned, will return back to the inventory // // } // // // remove expired modifiers from triggered item // // // note: don't do this on original modifier config, because it removes UPM from config // // // inventoryItem.RemoveExpiredModifiers(); // // // self-destory item on expire // // inventoryItem.SelfDestroyIfExpired(); // // } // // else // // { // // // item cannot be consumed // // // item will return to its original position // // } // // } // // else // // { // // // item is not consumable // // // nothing to do here // // // item will return to its original position // // // this type of items should be placed into hero equipment // // } // //} // //else // //{ // // Debug.Log("Other slot"); // //} // CursorController.Instance.SetNormalCursor(); //} #region Events Actions // called in UI in EventsListener public void OnPartyUnitStatusChange(PartyUnit changedPartyUnit) { // verify if changed party unit is the same as current if (changedPartyUnit == LPartyUnit) { SetUnitStatus(); } }
/// <summary> /// Setup in debug mode so we dont require initialization from the GameManager /// </summary> void DebugSetup() { BoardManager.instance.InitializeMapForCombat(0); GameObject mapEditor = GameObject.Find("MapEditor"); if (mapEditor != null) { Destroy(mapEditor); } List <PartyUnit> CurrentParty = new List <PartyUnit>(); PartyUnit newUnit = ScriptableObject.CreateInstance <PartyUnit> (); newUnit.UnitPrefab = Resources.Load("Characters/Hero") as GameObject; newUnit.MovementDistance = 4; newUnit.Health = 150; newUnit.UnitClass = PlayerControlledBoardUnit.PlayerClass.Support; newUnit.ListOfAbilities.Add(Instantiate(Resources.Load <AbilityDescription> ("Abilities/Support/ElectromagneticField")) as AbilityDescription); newUnit.ListOfAbilities.Add(Instantiate(Resources.Load <AbilityDescription> ("Abilities/Support/ConcussiveBlast")) as AbilityDescription); newUnit.ListOfAbilities.Add(Instantiate(Resources.Load <AbilityDescription> ("Abilities/Support/StaticShell")) as AbilityDescription); newUnit.ListOfAbilities.Add(Instantiate(Resources.Load <AbilityDescription> ("Abilities/Support/PulseForce")) as AbilityDescription); newUnit.currentLevel = 1; newUnit.UnitTalentTree = Instantiate(Resources.Load <TalentTree> ("TalentTrees/WarriorTree")) as TalentTree; CurrentParty.Add(newUnit); newUnit = ScriptableObject.CreateInstance <PartyUnit> (); newUnit.UnitPrefab = Resources.Load("Characters/Hero") as GameObject; newUnit.MovementDistance = 4; newUnit.ListOfAbilities.Add(Instantiate(Resources.Load <AbilityDescription> ("Abilities/Wizard/RadiantEnergy")) as AbilityDescription); newUnit.ListOfAbilities.Add(Instantiate(Resources.Load <AbilityDescription> ("Abilities/Wizard/CircuitBreak")) as AbilityDescription); newUnit.ListOfAbilities.Add(Instantiate(Resources.Load <AbilityDescription> ("Abilities/Wizard/StaticGrip")) as AbilityDescription); newUnit.ListOfAbilities.Add(Instantiate(Resources.Load <AbilityDescription> ("Abilities/Wizard/FluxBlast")) as AbilityDescription); newUnit.Health = 120; newUnit.UnitClass = PlayerControlledBoardUnit.PlayerClass.Wizard; newUnit.currentLevel = 1; newUnit.UnitTalentTree = Instantiate(Resources.Load <TalentTree> ("TalentTrees/WizardTree")) as TalentTree; CurrentParty.Add(newUnit); List <EnemyUnitInfo> enemies = new List <EnemyUnitInfo> (); EnemyUnitInfo newEnemy = ScriptableObject.CreateInstance <EnemyUnitInfo> (); newEnemy.UnitPrefab = Resources.Load("EnemyUnitPrefabTest") as GameObject; newEnemy.MovementDistance = 3; newEnemy.Health = 400; newEnemy.AIType = CombatAIManager.AIType.Melee; newEnemy.ListOfAbilities.Add(Resources.Load <AbilityDescription> ("Abilities/EnemyAbilities/Bite")); enemies.Add(newEnemy); newEnemy = ScriptableObject.CreateInstance <EnemyUnitInfo> (); newEnemy.UnitPrefab = Resources.Load("EnemyUnitPrefabTest") as GameObject; newEnemy.MovementDistance = 3; newEnemy.Health = 400; newEnemy.AIType = CombatAIManager.AIType.Melee; newEnemy.ListOfAbilities.Add(Resources.Load <AbilityDescription> ("Abilities/EnemyAbilities/Bite")); enemies.Add(newEnemy); SetupCombat(0, CurrentParty, enemies); }
/// <summary> /// Initialize the unit based on a PartyUnit /// </summary> public void Initialize(PartyUnit u) { MoveDistance = u.MovementDistance; AbilityActivator.ListOfAbilities = u.ListOfAbilities; MaxHealth = u.Health; CurrentHealth = u.Health; alive = true; UnitClass = u.UnitClass; }
bool VerifySingleUnitHire(PartyUnit selectedUnit) { bool result = true; // this is actually not required, because // if number of units in city reaches maximum, // then hire unit button is disabled // but let it be, just in case return(result); }
//============================================================================ // Initilization //============================================================================ public void Initialize(PartyUnit unit) { CreateUnit(unit); startPosition = transform.position; foreach (Hover h in GetComponentsInChildren <Hover>()) { h.platformManager = this; } SetWindowsActive(false); }
//============================================================================ // Initilization //============================================================================ public void Initilize(PartyUnit unit, Talent tal, int col, int ro) { talent = tal; GetTalentData(); row = ro; collum = col; meetsLevelRequirement = (unit.currentLevel >= row * 2); SetColor(); }