protected override void CompleteAction() { if (player.currentTool == gatherTool) { drops.spawnFromMaterial(transform.position); player.RemoveResourceFromWatch(this); if (m_breakSound) { m_breakSound.Play(); GameObject.Destroy(m_currentModel); GameObject.Destroy(m_gatherUIWrapper); GameObject.Destroy(m_repairUIWrapper); GameObject.Destroy(m_runningUIWrapper); deleteFlag = true; GameObject.Destroy(this.gameObject, m_breakSound.clip.length); } else { GameObject.Destroy(this.gameObject); } } else if (player.currentTool == repairTool) { var costProfile = ResourceManager.GetCostProfile(m_type); bool foundLimiter = false; foreach (var costItem in costProfile.m_buildingCost) { if (costItem.m_viabilityBool == false) { foundLimiter = true; } } if (!foundLimiter) { foreach (var costItem in costProfile.m_buildingCost) { Debug.Log("Cost Item: ID-" + costItem.m_type + " Delta-" + costItem.m_delta); ResourceManager.ChangeResource(costItem.m_type, costItem.m_delta); } Repair(); } else { currentHit = maxHit; UpdateUI(); } } }
// Update is called once per frame new void Update() { base.Update(); if (m_uiActive) { if (m_ruined && player.currentTool == repairTool) { UIConstructor uic = m_currentUIWrapper.GetComponent <UIConstructor>(); uic.Flush(); var cp = ResourceManager.GetCostProfile(m_type); foreach (var res in cp.m_buildingCost) { Color col = res.m_viabilityBool ? Color.black : Color.red; uic.AddSlot(res.m_type, res.m_delta.ToString(), col); } } else if (!m_ruined) { UIConstructor uic = m_currentUIWrapper.GetComponent <UIConstructor>(); uic.Flush(); var cy = ResourceManager.GetCurrentYields(m_type); Color col = cy.m_maxed ? Color.black : Color.red; for (int i = 0; i < ResourceManager.ResourceTypeCount; i++) { ResourceTypes resType = (ResourceTypes)i; if (cy.m_maxDeltas.ContainsKey(resType)) { if (cy.m_maxDeltas[resType] != 0.0f) { print("add slot " + resType); uic.AddSlot(resType, cy.m_currentDeltas[resType].ToString(), col); } } } } } }