Ejemplo n.º 1
0
 void Start()
 {
     _instance               = this;
     camera                  = GetComponent <Camera>();
     aspect                  = (float)Screen.width / (float)Screen.height;
     ortho                   = Matrix4x4.Ortho(-orthographicSize * aspect, orthographicSize * aspect, -orthographicSize, orthographicSize, near, far);
     perspective             = Matrix4x4.Perspective(fov, aspect, near, far);
     camera.projectionMatrix = ortho;
     orthoOn                 = true;
     blender                 = (MatrixBlender)GetComponent(typeof(MatrixBlender));
 }
Ejemplo n.º 2
0
    private IEnumerator Move(Transform target, float time, float hold, bool changePerspective = true)
    {
        float   starttime       = Time.time;
        Vector3 currentVelocity = Vector3.zero;

        if (changePerspective)
        {
            PerspectiveShifter.ShiftToPerspective(time / 2);
        }
        var pm = GameObject.Find("PlayerMesh");

        pm.SetActive(false);
        while (Time.time < starttime + time)
        {
            transform.position = Vector3.SmoothDamp(transform.position, target.position, ref currentVelocity, time - (Time.time - starttime));
            transform.rotation = Quaternion.Slerp(transform.rotation, target.rotation, 0.5f);
            yield return(null);
        }
        while (Time.time < starttime + time + hold)
        {
            transform.position = target.position;
            transform.rotation = target.rotation;
            yield return(null);
        }
        if (changePerspective)
        {
            PerspectiveShifter.ShiftToOrtho(time / 2);
        }
        while (Time.time < starttime + time + time + hold)
        {
            transform.position = Vector3.SmoothDamp(transform.position, transform.parent.position, ref currentVelocity, time - (Time.time - starttime));
            transform.rotation = Quaternion.Slerp(transform.rotation, transform.parent.rotation, 0.5f);
            yield return(null);
        }
        pm.SetActive(true);
        transform.localPosition = Vector3.zero;
        transform.localRotation = Quaternion.identity;
    }
Ejemplo n.º 3
0
    private IEnumerator TransitionToPerspective()
    {
        yield return(new WaitForSeconds(5));

        PerspectiveShifter.ShiftToPerspective(10);
    }
Ejemplo n.º 4
0
    private void EnterPhase(GamePhase phase, bool onlyLog = false)
    {
        this.phase = phase;
        switch (phase)
        {
        case GamePhase.LearnActions:
            PlayerPrefs.SetInt("level", 0);
            MessageController.AddMessage("Your farm is not doing well", true, onlyLog: onlyLog);
            MessageController.AddMessage("Water the plants and feed them to your chickens", onlyLog: onlyLog);
            MessageController.AddMessage("Eating will keep your energy up", onlyLog: onlyLog);
            goalText.text = @"* Feed yourself
* feed your <color='green'>grass</color> and <color='green'>carrots</color> <color='#33f'>water</color>
* feed your <color='#f33'>chickens</color> <color='green'>plants</color>";
            //messagePanel.anchorMin = new Vector2(1, 0.5f);
            //messagePanel.anchorMax = new Vector2(1, 0.5f);
            //messagePanel.pivot = new Vector2(1, 0.5f);
            snapshots[0].TransitionTo(1);
            PerspectiveShifter.ShiftToOrtho(0);
            break;

        case GamePhase.FeedWater:
            PlayerPrefs.SetInt("level", 1);
            mrBiscuits1.SetActive(true);
            MessageController.AddMessage("Look at it", true, onlyLog: onlyLog);
            MessageController.AddMessage("It's so thirsty", onlyLog: onlyLog);
            MessageController.AddMessage("Maybe you can help", onlyLog: onlyLog);
            MessageController.AddMessage("find it some water", onlyLog: onlyLog);
            goalText.text = @"* Feed yourself
* feed your <color='green'>grass</color> and <color='green'>carrots</color> <color='#33f'>water</color>
* feed your <color='#f33'>chickens</color> <color='green'>plants</color>
* feed mr. biscuits some <color='#33f'>water</color>";
            snapshots[1].TransitionTo(1);
            if (!onlyLog)
            {
                CinematicShot.MoveToTarget(cineTargets[0], 0.5f, 3);
            }

            break;

        case GamePhase.FeedVeggies:
            PlayerPrefs.SetInt("level", 2);
            cachedMrBiscuits2 = Instantiate(mrBiscuits2, mrBiscuits1.transform.position, Quaternion.identity);
            Utility.PhysicalDestroy(mrBiscuits1);
            MessageController.AddMessage("It's getting bigger and stronger", true, onlyLog: onlyLog);
            MessageController.AddMessage("It wants some veggies too", onlyLog: onlyLog);
            goalText.text = @"* Feed yourself
* feed your <color='green'>grass</color> and <color='green'>carrots</color> <color='#33f'>water</color>
* feed your <color='#f33'>chickens</color> <color='green'>plants</color>
* feed mr. biscuits <color='green'>plants</color>";
            snapshots[2].TransitionTo(1);
            if (!onlyLog)
            {
                CinematicShot.MoveToTarget(cineTargets[1], 0.5f, 3);
            }

            break;

        case GamePhase.HelloBats:
            PlayerPrefs.SetInt("level", 3);
            MessageController.AddMessage("You must protect Mr. Biscuits!", true, onlyLog: onlyLog);
            MessageController.AddMessage("They are hungry, bring meat to their lair", onlyLog: onlyLog);
            batSpawner.SetActive(true);
            goalText.text = @"* Feed yourself
* feed your <color='green'>grass</color> and <color='green'>carrots</color> <color='#33f'>water</color>
* feed your <color='#f33'>chickens</color> <color='green'>plants</color>
* feed mr. biscuits <color='green'>plants</color>
* feed the <color='purple'>bat lair</color> <color='#f33'>eggs</color> or <color='#f33'>chickens</color>";
            snapshots[3].TransitionTo(1);
            if (!onlyLog)
            {
                CinematicShot.MoveToTarget(cineTargets[2], 0.5f, 3);
            }

            break;

        case GamePhase.FeedMeats:
            PlayerPrefs.SetInt("level", 4);
            cachedMrBiscuits3 = Instantiate(mrBiscuits3, cachedMrBiscuits2.transform.position, Quaternion.identity);
            Utility.PhysicalDestroy(cachedMrBiscuits2);
            MessageController.AddMessage("Mr. Biscuits needs protein", true, onlyLog: onlyLog);
            MessageController.AddMessage("Eggs will do", onlyLog: onlyLog);
            MessageController.AddMessage("Or chickens...", onlyLog: onlyLog);
            goalText.text = @"* Feed yourself
* feed your <color='green'>grass</color> and <color='green'>carrots</color> <color='#33f'>water</color>
* feed your <color='#f33'>chickens</color> <color='green'>plants</color>
* feed the <color='purple'>bat lair</color> <color='#f33'>eggs</color> or <color='#f33'>chickens</color>
* feed mr. biscuits <color='green'>plants</color> and <color='#f33'>protein</color>";
            snapshots[4].TransitionTo(1);
            StartCoroutine(TransitionToMb3bSnapshot());
            if (!onlyLog)
            {
                CinematicShot.MoveToTarget(cineTargets[3], 0.5f, 3);
                StartCoroutine(TransitionToPerspective());
            }
            break;

        case GamePhase.Run:
            goalIndicator.StartFlashing();
            PlayerPrefs.SetInt("level", 5);
            cachedMrBiscuits4 = Instantiate(mrBiscuits4, cachedMrBiscuits3.transform.position, Quaternion.AngleAxis(180, Vector3.up));
            Utility.PhysicalDestroy(cachedMrBiscuits3);
            MessageController.AddMessage("run run run run run run run run", true);
            MessageController.AddMessage("run run run run run run run run");
            MessageController.AddMessage("run run run run run run run run");
            goalText.text          = @"* Feed yourself
* <color='red'>run</color>";
            messagePanel.anchorMin = new Vector2(1, 0f);
            messagePanel.anchorMax = new Vector2(1, 0f);
            messagePanel.pivot     = new Vector2(1, 0f);
            snapshots[6].TransitionTo(1);
            if (!onlyLog)
            {
                CinematicShot.MoveToTarget(cineTargets[4], 0.5f, 3, false);
            }
            PerspectiveShifter.ShiftToPerspective(1f);
            break;

        case GamePhase.Win:
            goalIndicator.StopFlashing();
            PlayerPrefs.SetInt("level", 0);
            MessageController.AddMessage("You escaped!", true);
            MessageController.AddMessage("but Mr. Biscuits has been unleashed upon this world");
            MessageController.AddMessage("-.. --- --- -- ... --- ...");
            MessageController.AddMessage("This was an entry in the Ludum Dare 41 compo");
            MessageController.AddMessage("By Zak Reynolds");
            MessageController.AddMessage("Thanks for playing!");
            snapshots[0].TransitionTo(5);
            break;
        }
    }