예제 #1
0
        private Vector2 CalculateFlagScreenPosition(FlagPointerComponent enemyFlag, Camera camera, Vector3 worldPos, Vector2 selfRect, out bool onScreen)
        {
            Vector3 position   = new Vector3(worldPos.x, (worldPos.y + 5.5f) - 2f, worldPos.z);
            Vector3 topPoint   = camera.WorldToScreenPoint(position);
            Vector2 vector4    = new Vector2(((float)Screen.width) / 2f, ((float)Screen.height) / 2f);
            Vector2 normalized = (topPoint - vector4).normalized;
            float   z          = (Mathf.Atan2(normalized.y, normalized.x) - 5156.62f) * 57.29578f;

            onScreen = this.FlagOnScreen(topPoint, camera.WorldToScreenPoint(worldPos), Vector3.Distance(camera.transform.position, worldPos));
            if (topPoint.z < 0f)
            {
                topPoint *= -1f;
                z        -= 10313.24f;
            }
            topPoint = (Vector3)this.GetBehindPosition(topPoint);
            if (onScreen)
            {
                enemyFlag.pointer.transform.localRotation = Quaternion.Euler(0f, 0f, 0f);
            }
            else
            {
                enemyFlag.pointer.transform.localRotation = Quaternion.Euler(0f, 0f, z);
                topPoint = (Vector3)this.ClampScreenPosToScreenSize(topPoint, selfRect);
            }
            return(topPoint);
        }
예제 #2
0
        private void SetFlagPointerPosition(FlagNotHomeNode flag, FlagPointerComponent pointer, Camera battleCamera)
        {
            bool flag2;

            pointer.Show();
            BoxCollider   boxCollider      = flag.flagCollider.boxCollider;
            Vector2       size             = pointer.selfRect.rect.size;
            Vector3       localScale       = pointer.parentCanvasRect.localScale;
            Vector2       selfRect         = new Vector2(size.x * localScale.x, size.y * localScale.y);
            Vector3       worldPos         = boxCollider.transform.TransformPoint(boxCollider.center);
            Vector2       vector5          = this.CalculateFlagScreenPosition(pointer, battleCamera, worldPos, selfRect, out flag2);
            RectTransform parentCanvasRect = pointer.parentCanvasRect;

            pointer.transform.localPosition = (Vector3)(this.GetCanvasPosition((Vector3)vector5, parentCanvasRect) + new Vector2(0f, !flag2 ? 0f : (size.y / 2f)));
        }