Example #1
0
    public void FocusOnPlanet(float duration, RectTransform setFocusElement = null)
    {
        RectTransform focusedElement = setFocusElement ?? GetFocussedElement();

        if (focusedElement.gameObject.tag == "sun")
        {
            focusedElement = (RectTransform)content.transform.GetChild(1).transform;
        }

        planetNameText.text = focusedElement.gameObject.name;
        velocity            = Vector2.zero;

        float startPosition = content.anchoredPosition.x;
        float endPosition   = -focusedElement.localPosition.x;

        LeanTween.value(content.gameObject, startPosition, endPosition, duration)
        .setEase(LeanTweenType.easeInOutSine)
        .setOnUpdate((value) => content.anchoredPosition = new Vector2(value, content.anchoredPosition.y))
        .setOnComplete(() => velocity = Vector2.zero);
        LeanTween.alphaCanvas(planetNameCanvasGroup, 1, duration);

        ViewPlanet.Instance.currentViewingLocation = focusedElement.GetComponent <PlanetElement>().Planet;
        planetInfo.Display(ViewPlanet.Instance.currentViewingLocation);
    }