private IEnumerator ConsumeAnim(float animDuration) { PlayExplosionAnim(); float lantenFollowTime = animDuration / 2f; float animTimer = 0f; Vector3 startPos = new Vector3(); bool bStartPosSet = false; while (animTimer < animDuration) { if (!bPaused) { animTimer += Time.deltaTime; if (animTimer > animDuration - lantenFollowTime) { if (!bStartPosSet) { _mothState = MothStates.ConsumeFollow; startPos = MothSprite.position; bStartPosSet = true; } float timeRatio = (animTimer - (animDuration - lantenFollowTime)) / lantenFollowTime; float xOffset = startPos.x - (startPos.x - _lantern.position.x) * timeRatio; float yOffset = startPos.y - (startPos.y - _lantern.position.y) * timeRatio; MothSprite.position = new Vector3(xOffset, yOffset, startPos.z); } } yield return(null); } _mothInteractor.ActivateAbility(Colour); SendToInactivePool(); _bConsumption = false; }
public void Activate(SpawnType spawnTf, MothColour colour, MothPathHandler.MothPathTypes pathType = MothPathHandler.MothPathTypes.Spiral) { // TODO determine where in the vertical space the moth can spawn ie Raycast (endless mode only) //const float Range = 2f; //float MothYPos = Range * Random.value - Range / 2; base.Activate(transform, spawnTf); _mothState = MothStates.Normal; _mothAnimator.enabled = true; _mothCollider.enabled = true; MothSprite.transform.position = transform.position; _pathHandler.SetPathType(pathType); Colour = colour; PlayNormalAnimation(); }