public void InteractionTick() { if (interactionTickTime != 0f) // because sometimes the functioon is called twice per frame { return; } interactionTime = interactionCooldown; interactionTickTime = interactionTickCooldown; if (hoveredInteractor) { if (lastInteraction == InteractionType.Type.collectWood) { interactionJuicer.treeInteractor = hoveredInteractor; CommonRessourceCollectionResolve(); } else if (InteractionType.isCollectingMinerals(lastInteraction)) { CommonRessourceCollectionResolve(); } else if (lastInteraction == InteractionType.Type.collectWheat) { CommonRessourceCollectionResolve(); } else if (lastInteraction == InteractionType.Type.construction) { List <AudioClip> sounds = ResourceDictionary.instance.resources["Iron"].collectingSound; AudioClip soundFx = sounds[Random.Range(0, sounds.Count)]; audiosource.clip = soundFx; if (soundFx) { audiosource.Play(); } // increment progress bar ConstructionController construction = hoveredInteractor.GetComponent <ConstructionController>(); if (construction && construction.Increment()) { interactionTime = 0f; hoveredInteractor = null; animator.SetBool("interaction", false); } } /*else if (lastInteraction == InteractionType.Type.destroyBuilding) * { * List<AudioClip> sounds = ResourceDictionary.instance.resources["Iron"].collectingSound; * AudioClip soundFx = sounds[Random.Range(0, sounds.Count)]; * audiosource.clip = soundFx; * if (soundFx) * audiosource.Play(); * * // increment progress bar * DestructionTemplate destruction = hoveredInteractor.GetComponent<DestructionTemplate>(); * if (destruction.Increment()) * { * interactionTime = 0f; * hoveredInteractor = null; * animator.SetBool("interaction", false); * } * }*/ else { // error interacting = false; hoveredInteractor = null; interactionTime = 0f; animator.SetBool("interaction", false); Debug.LogWarning("no interaction tick for this type implemented : " + lastInteraction.ToString()); } } else { // error interacting = false; hoveredInteractor = null; interactionTime = 0f; animator.SetBool("interaction", false); } }