// Update is called once per frame void Update() { if (activated) { if ((Time.time - refTimeforShieldPartActivations > timeBetweenShieldPartActivations) && shieldPartSet.Count > 0) { int randNum = Random.Range(0, shieldPartSet.Count); ShieldPart randPart = shieldPartSet[randNum]; ActivateShieldPart(randPart); PlayRandomShieldActivationSound(); shieldPartSetCopy.Add(randPart); shieldPartSet.Remove(randPart); refTimeforShieldPartActivations = Time.time; if (shieldPartSet.Count == 1) { PlayShieldActivationCompletionSound(); } } if (animatingShieldIconBgd) { if (Time.time - shieldPopupAnimationRefTime > shieldPopupActivationFrameTime) { if (shieldPopupAnimationFrameIndex < shieldActivationIconFrames.Count - 1) { shieldPopupAnimationFrameIndex++; shieldActivationPopup.texture = shieldActivationIconFrames[shieldPopupAnimationFrameIndex]; } else { animatingShieldIconBgd = false; animatingLittleShieldGuyAvatar = true; shieldPopupAnimationFrameIndex = 0; } shieldPopupAnimationRefTime = Time.time; } } else if (animatingLittleShieldGuyAvatar) { if (Time.time - shieldPopupAnimationRefTime > shieldPopupActivationFrameTime) { if (shieldPopupAnimationFrameIndex < littleShieldGuyActivationFrames.Count - 1) { shieldPopupAnimationFrameIndex++; littleShieldGuyAvatar.texture = littleShieldGuyActivationFrames[shieldPopupAnimationFrameIndex]; } else { animatingLittleShieldGuyAvatar = false; shieldPopupAnimationFrameIndex = littleShieldGuyActivationFrames.Count - 1; } shieldPopupAnimationRefTime = Time.time; } } } else { if ((Time.time - refTimeforShieldPartActivations > timeBetweenShieldPartActivations) && shieldPartSetCopy.Count > 0) { int randNum = Random.Range(0, shieldPartSetCopy.Count); ShieldPart randPart = shieldPartSetCopy[randNum]; DeactivateShieldPart(randPart); PlayRandomShieldActivationSound(); shieldPartSet.Add(randPart); shieldPartSetCopy.Remove(randPart); refTimeforShieldPartActivations = Time.time; } if (animatingLittleShieldGuyAvatar) { if (Time.time - shieldPopupAnimationRefTime > shieldPopupDeactivationFrameTime) { if (shieldPopupAnimationFrameIndex > 0) { shieldPopupAnimationFrameIndex--; littleShieldGuyAvatar.texture = littleShieldGuyActivationFrames[shieldPopupAnimationFrameIndex]; } else { animatingShieldIconBgd = true; animatingLittleShieldGuyAvatar = false; shieldPopupAnimationFrameIndex = shieldActivationIconFrames.Count - 1; } shieldPopupAnimationRefTime = Time.time; } } else if (animatingShieldIconBgd) { if (Time.time - shieldPopupAnimationRefTime > shieldPopupDeactivationFrameTime) { if (shieldPopupAnimationFrameIndex > 0) { shieldPopupAnimationFrameIndex--; shieldActivationPopup.texture = shieldActivationIconFrames[shieldPopupAnimationFrameIndex]; } else { animatingShieldIconBgd = false; shieldPopupAnimationFrameIndex = 0; } shieldPopupAnimationRefTime = Time.time; } } } }