public void UCE_IncreaseHarvestNodeCounterFor(UCE_HarvestingProfessionTemplate profession) { for (int i = 0; i < UCE_quests.Count; ++i) { if ((!UCE_quests[i].completed || !UCE_quests[i].completedAgain) && UCE_quests[i].harvestTarget.Length > 0 && UCE_quests[i].harvestTarget.Any(x => x.target == profession) ) { UCE_Quest quest = UCE_quests[i]; bool bChanged = false; for (int j = 0; j < quest.harvestTarget.Length; ++j) { if (quest.harvestTarget[j].target == profession && quest.harvestedTarget[j] < quest.harvestTarget[j].amount) { int idx = j; quest.harvestedTarget[idx]++; bChanged = true; break; } } UCE_quests[i] = quest; if (bChanged) { UCE_checkQuestCompletion(i); } } } }
// ----------------------------------------------------------------------------------- // UCE_HarvestingValidation (Client/Server) // ----------------------------------------------------------------------------------- public bool UCE_HarvestingValidation() { bool bValid = UCE_ResourceNodeValidation() && mana >= UCE_selectedResourceNode.manaCost; if (bValid) { // ----- check tools UCE_HarvestingProfessionTemplate requiredProfession = getHarvestingProfessionTemplate(); int check = 0; foreach (UCE_HarvestingTool tool in requiredProfession.tools) { if ((!tool.equippedItem && InventoryCount(new Item(tool.requiredItem)) >= 1) || (tool.equippedItem && UCE_checkHasEquipment(tool.requiredItem))) check++; } if (requiredProfession.requiresAllTools) { if (check < requiredProfession.tools.Length) bValid = false; } else { if (check <= 0 && requiredProfession.tools.Length > 0) bValid = false; } } // ---- Cancel /* if (!bValid) UCE_cancelHarvesting(); */ return bValid; }
// ----------------------------------------------------------------------------------- // HasHarvestingProfessionLevel // ----------------------------------------------------------------------------------- public bool HasHarvestingProfessionLevel(UCE_HarvestingProfessionTemplate aProf, int level) { if (HasHarvestingProfession(aProf)) { var tmpProf = getHarvestingProfession(aProf); if (tmpProf.level >= level) return true; } return false; }
// ================================== PROFESSIONS ==================================== // ----------------------------------------------------------------------------------- // getHarvestingProfession // ----------------------------------------------------------------------------------- public UCE_HarvestingProfession getHarvestingProfession(UCE_HarvestingProfessionTemplate tmpl) { if (HasHarvestingProfession(tmpl)) { int id = UCE_Professions.FindIndex(x => x.templateName == tmpl.name); return UCE_Professions[id]; } return new UCE_HarvestingProfession(); }
// ----------------------------------------------------------------------------------- // UCE_cancelHarvesting // ----------------------------------------------------------------------------------- public void UCE_cancelHarvesting() { if (UCE_selectedResourceNode != null) { UCE_stopTimer(); UCE_removeTask(); UCE_CastbarHide(); UCE_HarvestingProfessionTemplate requiredProfession = getHarvestingProfessionTemplate(); if (requiredProfession != null) StopAnimation(requiredProfession.animatorState, requiredProfession.stopPlayerSound); UCE_selectedResourceNode = null; } }
public void Target_UCE_startResourceNodeAccess(NetworkConnection target) { if (UCE_ResourceNodeValidation() && UCE_HarvestingValidation()) { UCE_addTask(); UCE_setTimer(UCE_HarvestingDuration(harvestBooster)); UCE_CastbarShow(UCE_selectedResourceNode.accessLabel, UCE_HarvestingDuration(harvestBooster)); agent.ResetPath(); LookAtY(UCE_selectedResourceNode.transform.position); UCE_HarvestingProfessionTemplate requiredProfession = getHarvestingProfessionTemplate(); StartAnimation(requiredProfession.animatorState, requiredProfession.startPlayerSound); } }
private void LateUpdate_UCE_Harvesting() { if (UCE_ResourceNodeValidation() && UCE_checkTimer()) { UCE_stopTimer(); UCE_removeTask(); UCE_CastbarHide(); UCE_HarvestingProfessionTemplate requiredProfession = getHarvestingProfessionTemplate(); StopAnimation(requiredProfession.animatorState, requiredProfession.stopPlayerSound); Destroy(indicator); Cmd_UCE_FinishHarvest(); } else if (!UCE_ResourceNodeValidation() && UCE_timerRunning) { UCE_cancelHarvesting(); } }
// ----------------------------------------------------------------------------------- // UCE_HarvestingProfession // ----------------------------------------------------------------------------------- public UCE_HarvestingProfession UCE_getHarvestingProfession(UCE_HarvestingProfessionTemplate tmpl) { return UCE_Professions.First(x => x.templateName == tmpl.name); }
// ----------------------------------------------------------------------------------- // HasHarvestingProfession // ----------------------------------------------------------------------------------- public bool HasHarvestingProfession(UCE_HarvestingProfessionTemplate profession) { return UCE_Professions.Any(x => x.templateName == profession.name); }
// ----------------------------------------------------------------------------------- // ToolTip // ----------------------------------------------------------------------------------- public string ToolTip(UCE_HarvestingProfessionTemplate tpl) { return(tpl.ToolTip()); }