// ---------------------- override protected void OnUpdateAnimator(bool skipAnim) { #if UNITY_EDITOR if (!UnityEditor.EditorApplication.isPlaying) { //this.CheckHierarchy(); //return; } #endif TouchJoystick joystick = (TouchJoystick)this.sourceControl; if ((joystick == null) || (this.image == null)) { return; } JoystickState joyState = joystick.GetState(); //false); //this.useVirtualJoystickState); SpriteConfig sprite = null; if ((this.spriteMode == SpriteMode.FourWay) || (this.spriteMode == SpriteMode.EightWay)) { Dir curDir = Dir.N; if (this.spriteMode == SpriteMode.FourWay) { curDir = joyState.GetDir4(); } else if (this.spriteMode == SpriteMode.EightWay) { curDir = joyState.GetDir8(); } switch (curDir) { case Dir.U: sprite = this.spriteUp; break; case Dir.UR: sprite = this.spriteUpRight; break; case Dir.R: sprite = this.spriteRight; break; case Dir.DR: sprite = this.spriteDownRight; break; case Dir.D: sprite = this.spriteDown; break; case Dir.DL: sprite = this.spriteDownLeft; break; case Dir.L: sprite = this.spriteLeft; break; case Dir.UL: sprite = this.spriteUpLeft; break; } } if (joystick.Pressed() && ((sprite == null) || !sprite.enabled)) { sprite = this.spriteNeutralPressed; } if (((sprite == null) || !sprite.enabled)) { sprite = this.spriteNeutral; } if (!CFUtils.editorStopped && !this.IsIllegallyAttachedToSource()) { Vector2 joyVec = joyState.GetVectorEx((joystick.shape == TouchControl.Shape.Rectangle) || (joystick.shape == TouchControl.Shape.Square)); if (this.animateTransl) { this.extraOffset = CFUtils.SmoothTowardsVec2(this.extraOffset, Vector2.Scale(joyVec, this.moveScale), this.translationSmoothingTime, CFUtils.realDeltaTimeClamped, 0.0001f); } else { this.extraOffset = Vector2.zero; } if (this.rotationMode != RotationMode.Disabled) { float targetAngle = 0; if (joystick.Pressed()) { Vector2 v = joyState.GetVector(); if (this.rotationMode == RotationMode.Compass) { if (v.sqrMagnitude > 0.0001f) { this.lastSafeCompassAngle = joyState.GetAngle(); //CFUtils.VecToAngle(v.normalized); } targetAngle = -this.lastSafeCompassAngle; //targetRotation = Quaternion.Euler(0, 0, -this.lastSafeCompassAngle); } else { targetAngle = ((this.rotationMode == RotationMode.SimpleHorizontal) ? v.x : v.y) * -this.simpleRotationRange; } } else { this.lastSafeCompassAngle = 0; targetAngle = 0; } this.extraRotation = CFUtils.SmoothTowardsAngle(this.extraRotation, targetAngle, this.rotationSmoothingTime, CFUtils.realDeltaTimeClamped, 0.0001f); } } this.BeginSpriteAnim(sprite, skipAnim); this.UpdateSpriteAnimation(skipAnim); }