예제 #1
0
        private void Awake()
        {
            var rendererObject = new GameObject("Line");

            rendererObject.layer = LayerMask.NameToLayer("Tools");
            rendererObject.transform.SetParent(transform, worldPositionStays: false);
            rendererObject.AddComponent <NoAutomaticFade>();
            rendererObject.AddComponent <LineFader>().owner = this;

            lineRenderer = rendererObject.GetComponent <MeshRenderer>();
            if (!lineRenderer)
            {
                lineRenderer = rendererObject.AddComponent <MeshRenderer>();
            }

            lineRenderer.sharedMaterial = material;

            filter = rendererObject.GetComponent <MeshFilter>();
            if (!filter)
            {
                filter = rendererObject.AddComponent <MeshFilter>();
            }

            scaleWithDistance = GetComponent <ScaleWithDistance>();

            mesh = new Mesh();
            mesh.MarkDynamic();
            filter.sharedMesh = mesh;
        }
예제 #2
0
        public void UnhideCard()
        {
            if (CardAnimator && !CardAnimator.GetBool("CardVisible"))
            {
                isCardSelected = true;
                CardAnimator.SetBool("CardVisible", true);
                descriptionAnimator.SetBool("selected", true);

                // update the position of the image and face the camera
                CardAnimator.transform.parent.position = IndicatorLine.points[0].position;
                if (Camera.main != null)
                {
                    Vector3 forwardDirection = transform.position - Camera.main.transform.position;
                    CardAnimator.transform.parent.rotation = Quaternion.LookRotation(forwardDirection.normalized, Camera.main.transform.up);
                }

                AudioSource cardAudioSource = CardAnimator.GetComponent <AudioSource>();
                if (AirtapSound != null && cardAudioSource != null)
                {
                    VOManager.Instance.Stop(clearQueue: true);
                    VOManager.Instance.PlayClip(AirtapSound);
                    cardAudioSource.PlayOneShot(SelectSound);
                }

                // slide out the description
                StopAllCoroutines();
                Description.transform.localPosition = descriptionStoppedLocalPosition;
                targetDescriptionScale = Mathf.Max(Description.transform.lossyScale.x, Description.transform.lossyScale.y, Description.transform.lossyScale.z);
                ScaleWithDistance distanceScaler = CardAnimator.transform.parent.GetComponentInChildren <ScaleWithDistance>();
                Description.transform.parent.SetParent(distanceScaler.transform, true);
                targetOffsetObject = new GameObject("DescriptionOffset");
                targetOffsetObject.transform.SetParent(CardAnimator.transform.parent);

                StartCoroutine(SlideCardOut());

                // fade out the points of interest when the card is selected
                if (TransitionManager.Instance != null)
                {
                    foreach (PointOfInterest pointOfInterest in pointsOfInterest)
                    {
                        if (pointOfInterest != null)
                        {
                            // if faders has their coroutines killed, then need to be initialized to a disabled state
                            Fader[] faders = pointOfInterest.GetComponentsInChildren <Fader>(true);
                            foreach (Fader fader in faders)
                            {
                                fader.DisableFade();
                            }

                            if (pointOfInterest == this)
                            {
                                BillboardLine.LineFader fader = GetComponentInChildren <BillboardLine.LineFader>(true);
                                if (fader != null)
                                {
                                    StartCoroutine(TransitionManager.Instance.FadeContent(
                                                       fader.gameObject,
                                                       TransitionManager.FadeType.FadeOut,
                                                       CardPOIManager.Instance.POIFadeOutTime,
                                                       CardPOIManager.Instance.POIOpacityCurve));
                                }
                            }
                            else
                            {
                                StartCoroutine(TransitionManager.Instance.FadeContent(
                                                   pointOfInterest.gameObject,
                                                   TransitionManager.FadeType.FadeOut,
                                                   CardPOIManager.Instance.POIFadeOutTime,
                                                   CardPOIManager.Instance.POIOpacityCurve));
                            }
                        }
                    }
                }
            }
        }