Example #1
0
    private IEnumerator Start()
    {
        for (int i = 0; i < this.m_comicStrips.Count; i++)
        {
            ComicStrip comicStrip = this.m_comicStrips[i];
            float      x          = comicStrip.m_strip.GetComponent <UnmanagedSprite>().Size.x;
            this.m_startPos     = -10f * (float)Screen.width / (float)Screen.height + 0.5f * x + 4f * (float)Screen.width / (float)Screen.height;
            this.m_startPos_3_2 = -15f + 0.5f * x + 6f;
            comicStrip.m_strip.transform.position = new Vector3(this.m_startPos, 0f, (float)i);
            float num = 0f;
            this.m_comicStrips[i].m_strip.GetComponent <Renderer>().material.SetColor("_Color", new Color(1f, 1f, 1f, num));
            this.FadeChildren(num, this.m_comicStrips[i], false);
        }
        this.m_continueButton.SetActive(GameProgress.GetInt(Singleton <GameManager> .Instance.CurrentSceneName + "_played", 0, GameProgress.Location.Local, null) == 1);
        if (ScreenPlacement.IsAspectRatioNarrowerThan(4f, 3f))
        {
            this.m_continueButton.transform.Translate(-2.5f, 0f, 0f);
        }
        base.StartCoroutine(this.UpdateStrips());
        yield return(null);

        if (this.m_soundTrack && this.m_currentStrip == 0)
        {
            Singleton <AudioManager> .Instance.Spawn2dOneShotEffect(this.m_soundTrack);
        }
        for (int j = 0; j < this.m_currentStrip; j++)
        {
            this.m_time += this.GetComicPageTime(j);
        }
        yield break;
    }
Example #2
0
 public Snapshot(string name, float dist, Vector3 screenPlace, Vector3 cameraForward, Vector3 targetForward, Texture2D screenshot, AnimalBehavior state)
 {
     targetName      = name;
     distanceAway    = dist;
     screenPlacement = determineScreenPlace(screenPlace);
     orientation     = determineOrientation(cameraForward, targetForward);
     theScreenshot   = screenshot;
     animalState     = state;
 }
Example #3
0
 private void Start()
 {
     this.m_camera = base.GetComponent <Camera>();
     this.m_camera.orthographic = true;
     this.m_cameraLimits        = WPFMonoBehaviour.levelManager.CurrentCameraLimits;
     this.m_cameraMaxZoom       = Mathf.Min(Mathf.Min(this.m_cameraLimits.size.x, this.m_cameraLimits.size.y) / 2f, 20f);
     this.m_cameraMinZoom       = 7f;
     if (Singleton <BuildCustomizationLoader> .Instance.IsHDVersion)
     {
         if (ScreenPlacement.IsAspectRatioNarrowerThan(3f, 2f))
         {
             this.m_cameraMinZoom = 8.4f;
         }
         else
         {
             this.m_cameraMinZoom = 7.7f;
         }
     }
     this.m_camera.orthographicSize = this.m_cameraMinZoom;
     this.m_cameraPreview           = base.GetComponent <CameraPreview>();
     this.m_snapshotFX = base.GetComponent <SnapshotEffect>();
     if (this.m_cameraPreview == null && WPFMonoBehaviour.levelManager.GoalPosition != null)
     {
         this.m_cameraPreview = base.gameObject.AddComponent <CameraPreview>();
         CameraPreview.CameraControlPoint cameraControlPoint = new CameraPreview.CameraControlPoint();
         cameraControlPoint.position = WPFMonoBehaviour.levelManager.GoalPosition.transform.position + WPFMonoBehaviour.levelManager.PreviewOffset;
         cameraControlPoint.zoom     = WPFMonoBehaviour.levelManager.PreviewOffset.z / 2f;
         this.m_cameraPreview.ControlPoints.Add(cameraControlPoint);
         this.m_cameraPreview.ControlPoints.Add(cameraControlPoint);
         CameraPreview.CameraControlPoint cameraControlPoint2 = new CameraPreview.CameraControlPoint();
         cameraControlPoint2.position = new Vector2(this.m_cameraLimits.topLeft.x + this.m_cameraLimits.size.x / 2f, this.m_cameraLimits.topLeft.y - this.m_cameraLimits.size.y / 2f);
         cameraControlPoint2.zoom     = this.m_cameraMaxZoom;
         this.m_cameraPreview.ControlPoints.Add(cameraControlPoint2);
         CameraPreview.CameraControlPoint cameraControlPoint3 = new CameraPreview.CameraControlPoint();
         cameraControlPoint3.position = WPFMonoBehaviour.levelManager.StartingPosition + WPFMonoBehaviour.levelManager.ConstructionOffset;
         cameraControlPoint3.zoom     = WPFMonoBehaviour.levelManager.ConstructionOffset.z;
         this.m_cameraPreview.ControlPoints.Add(cameraControlPoint3);
         this.m_cameraPreview.ControlPoints.Add(cameraControlPoint3);
         this.m_cameraPreview.m_animationTime = WPFMonoBehaviour.levelManager.m_previewMoveTime;
         if (this.m_cameraPreview.m_animationTime < 1f)
         {
             this.m_cameraPreview.m_animationTime = 1f;
         }
     }
     if (this.m_cameraPreview != null)
     {
         WPFMonoBehaviour.levelManager.m_previewMoveTime = this.m_cameraPreview.m_animationTime;
     }
     this.m_cameraBuildZoom = this.m_cameraPreview.ControlPoints[this.m_cameraPreview.ControlPoints.Count - 1].zoom;
     base.gameObject.SetActive(true);
 }
Example #4
0
    private float GetComicPageTime(int index)
    {
        float x   = this.m_comicStrips[index].m_strip.GetComponent <UnmanagedSprite>().Size.x;
        float num = -0.15f * x;

        if (ScreenPlacement.IsAspectRatioNarrowerThan(4f, 3f))
        {
            num -= 2.5f;
        }
        float num2 = (this.m_startPos - num) / (this.m_startPos_3_2 - num);
        float num3 = num2 * this.m_comicStrips[index].m_speed;
        float num4 = Mathf.Abs(this.m_startPos - num) / num3;
        float num5 = 2f * (1f / this.m_comicStrips[index].m_fadingSpeed);

        return(num4 + num5);
    }
Example #5
0
    private IEnumerator UpdateStrips()
    {
        float alpha = 0f;

        while (this.m_currentStrip < this.m_comicStrips.Count)
        {
            float comicWidth  = this.m_comicStrips[this.m_currentStrip].m_strip.GetComponent <UnmanagedSprite>().Size.x;
            float endPos      = -0.15f * comicWidth;
            float speedFactor = (this.m_startPos - endPos) / (this.m_startPos_3_2 - endPos);
            if (ScreenPlacement.IsAspectRatioNarrowerThan(4f, 3f))
            {
                endPos -= 2.5f;
            }
            if (this.m_comicStrips[this.m_currentStrip].m_strip.transform.position.x <= endPos)
            {
                this.m_comicStrips[this.m_currentStrip].m_strip.transform.position = new Vector3(endPos, 0f);
                if (this.m_currentStrip < this.m_comicStrips.Count - 1)
                {
                    while (alpha > 0f)
                    {
                        alpha -= Time.deltaTime * this.m_comicStrips[this.m_currentStrip].m_fadingSpeed;
                        this.m_comicStrips[this.m_currentStrip].m_strip.GetComponent <Renderer>().material.SetColor("_Color", new Color(1f, 1f, 1f, alpha));
                        this.FadeChildren(alpha, this.m_comicStrips[this.m_currentStrip], false);
                        yield return(new WaitForEndOfFrame());
                    }
                    UnityEngine.Object.Destroy(this.m_comicStrips[this.m_currentStrip].m_strip);
                }
                this.m_comicStrips[this.m_currentStrip] = null;
                this.m_currentStrip++;
            }
            else
            {
                while (alpha < 1f)
                {
                    alpha += Time.deltaTime * this.m_comicStrips[this.m_currentStrip].m_fadingSpeed;
                    this.m_comicStrips[this.m_currentStrip].m_strip.GetComponent <Renderer>().material.SetColor("_Color", new Color(1f, 1f, 1f, alpha));
                    this.FadeChildren(alpha, this.m_comicStrips[this.m_currentStrip], true);
                    yield return(new WaitForEndOfFrame());
                }
                this.m_comicStrips[this.m_currentStrip].m_strip.transform.position -= Vector3.right * speedFactor * this.m_comicStrips[this.m_currentStrip].m_speed * Time.deltaTime;
                yield return(new WaitForEndOfFrame());
            }
        }
        this.m_continueButton.SetActive(true);
        yield break;
    }
Example #6
0
    private void SetPlacement()
    {
        if (CameraOverride == null)
        {
            cam = Camera.main;
        }
        else
        {
            cam = CameraOverride;
        }

        if (cam == null)
        {
            return;
        }

        if (!cam.orthographic)
        {
            throw new System.NotImplementedException("UI Placement system is not set up to handle a perspective camera");
        }

        bounds = new Bounds();
        if (originalScale == Vector3.zero)
        {
            originalScale = transform.localScale;
        }
        else
        {
            transform.localScale = originalScale;
        }
        //get the size of the component
        if (OverrideBounds)
        {
            Vector2 adjustedSizeOverride = SizeOverride;
            adjustedSizeOverride.Scale(transform.localScale);
            bounds = new Bounds(transform.TransformPoint(CenterOverride), adjustedSizeOverride);
        }
        else
        {
            foreach (Renderer rend in GetComponentsInChildren <Renderer>())
            {
                if (bounds.size == Vector3.zero)
                {
                    bounds = rend.bounds;
                }
                else
                {
                    bounds.Encapsulate(rend.bounds);
                }
            }
        }
        //if the bounds are still undefined, put in some dummy values
        if (bounds.size == Vector3.zero)
        {
            bounds = new Bounds(transform.position, Vector2.one);
        }

        ScreenPlacement sp    = FindTargetPlacement();
        Transform       trans = transform;

        //adjust the CameraSize based on any aspect subtraction that we're using

        float subtractionAspect;

        if (sp.ScreenSubtraction.y > 0)
        {
            subtractionAspect = sp.ScreenSubtraction.x / sp.ScreenSubtraction.y;
        }
        else
        {
            subtractionAspect = 0;
        }

        float adjustedAspect, adjustedSize;

        if (cam.aspect > subtractionAspect)
        {
            //the screen is wider than the subtraction region, remove width
            adjustedAspect = cam.aspect - subtractionAspect;
            adjustedSize   = cam.orthographicSize;
        }
        else
        {
            adjustedAspect = subtractionAspect - cam.aspect;
            adjustedSize   = (cam.orthographicSize * 2 * cam.aspect) / adjustedAspect;
        }
        Vector2 CameraSize = new Vector2(adjustedSize * 2 * adjustedAspect, cam.orthographicSize * 2);

        Vector2 scale = Vector2.one;

        //scale the object based on screen size
        if (sp.ScreenSize.x != 0 || sp.ScreenSize.y != 0)
        {
            if (sp.ScreenSize.x != 0)
            {
                if (sp.ScreenSize.y != 0)
                {
                    //scale x and y based on total screen size
                    scale.x = (CameraSize.x * sp.ScreenSize.x) / bounds.size.x;
                    scale.y = (CameraSize.y * sp.ScreenSize.y) / bounds.size.y;
                }
                else
                {
                    //uniform scale to make the width a portion of the screen
                    scale *= (CameraSize.x * sp.ScreenSize.x) / bounds.size.x;
                }
            }
            else
            {
                //uniform scale to make the height a portion of the screen
                scale *= (CameraSize.y * sp.ScreenSize.y) / bounds.size.y;
            }
        }

        //get the local position of the anchor
        Vector2 localAnchor = trans.InverseTransformPoint(GetWorldAnchorPoint(bounds, sp.Anchor));

        //take the new scale into account
        localAnchor.Scale(scale);
        //transform back into world space
        Vector2 worldAnchor = trans.TransformPoint(localAnchor);

        //move the object so that the anchor lines up with the screen position
        Vector2 targetPosition = cam.ViewportToWorldPoint(sp.ScreenPosition);

        if ((Vector2)trans.position != targetPosition - worldAnchor)
        {
            trans.position += (Vector3)(targetPosition - worldAnchor);
        }
        //apply the scale to the object
        if (scale != Vector2.one)
        {
            Vector3 localScale = trans.localScale;
            localScale.Scale(scale);
            trans.localScale = (Vector3)localScale + Vector3.forward;
        }
    }