ScreenPad.HandleAiming C# (CSharp) Метод

HandleAiming() приватный Метод

private HandleAiming ( Vector2 _screenPos ) : void
_screenPos Vector2
Результат void
        void HandleAiming ( Vector2 _screenPos ) {
            if ( this.useRemoteTouch ) {
#if UNITY_IPHONE
                // the screen touch priority is higher than aimingZone
                if ( this.availableTouches.Count != 0 ) {
                    GameObject girl = Game.PlayerGirl().gameObject;
                    Vector3 girlScreenPos = Camera.main.WorldToScreenPoint(girl.transform.position);
                    Vector2 girlScreenPos_v2 = new Vector2(girlScreenPos.x, girlScreenPos.y); 

                    Touch t = GetLastTouch();
                    Vector2 delta = t.position - girlScreenPos_v2;
                    this.aimingDir = delta.normalized;
                    this.shootCounter = this.shootingDuration;
                }
                else if ( this.aimingID != -1 ) {
                    Vector2 delta = _screenPos - this.aimingZone.center;
                    Vector2 desiredDir = delta.normalized; 
                    // DISABLE: this.aimingDir = -delta.normalized; // this is old method, inverse needle
                    // adjust the aiming direction by 
                    desiredDir = (Game.PlayerGirl() as PlayerGirl).GetAutoLockDir(desiredDir);
                    this.aimingDir = desiredDir; 
                    this.shootCounter = this.shootingDuration;
                }
#endif
            } else {
                GameObject girl = Game.PlayerGirl().gameObject;
                Vector3 girlScreenPos = Camera.main.WorldToScreenPoint(girl.transform.position);
                Vector2 girlScreenPos_v2 = new Vector2(girlScreenPos.x, girlScreenPos.y); 
                Vector2 delta = new Vector2(Input.mousePosition.x,Input.mousePosition.y) - girlScreenPos_v2;
                Vector2 desiredDir = delta.normalized; 
                desiredDir = (Game.PlayerGirl() as PlayerGirl).GetAutoLockDir(desiredDir);
                this.aimingDir = desiredDir;
            } // end if ( !this.useRemoteTouch )

            // use cross to get the direction of the rotation.
            Vector2 up = Vector2.up;
            float sin_theta = this.aimingDir.x * up.y - this.aimingDir.y * up.x; 
            float degrees = Vector2.Angle( this.aimingDir, Vector2.up );
            this.aimingAnchor.localEulerAngles = new Vector3( 0.0f, 0.0f, -1.0f * degrees * Mathf.Sign(sin_theta) );
        }