示例#1
0
    // Update is called once per frame
    void Update()
    {
        Thought thought = thoughtMenu.currentThought;

        if (thought == null)
        {
            // freeze when thought is chosen, and still jumping
            if (!player.grounded)
            {
                gameObject.GetComponent <SpriteRenderer>().enabled = true;
                transform.position = previousPosition;
            }
            else
            {
                gameObject.GetComponent <SpriteRenderer>().enabled = false;
            }
            return;
        }


        gameObject.GetComponent <SpriteRenderer>().enabled = true;
        float zeroY  = runManager.runState.height;
        float minY   = zeroY + ActivityPlatform.PowerToYDiff(thought.minJumpPower);
        float maxY   = zeroY + ActivityPlatform.PowerToYDiff(thought.maxJumpPower + 1);
        float range  = maxY - minY;
        float period = .5f; // number of seconds per cycle
        // move position up and down until thought has been chosen, then freeze
        float offset = range == 0 ? 0 : (Time.time * range / period) % range;

        transform.position = new Vector2(transform.parent.position.x - 0.3f, minY + offset - ActivityPlatform.platformThickness);
        previousPosition   = transform.position;
    }
示例#2
0
    // convert from arrow position to jump power
    public int GetJumpPower()
    {
        float zeroY = runManager.runState.height;
        float ydiff = (transform.position.y - zeroY + ActivityPlatform.platformThickness);

        return(ActivityPlatform.YDiffToPower(ydiff));
    }
示例#3
0
    // Initialization
    void Start()
    {
        // get reference to gameManager
        gameManager = Object.FindObjectOfType <GameManager>();
        // get reference to runManager
        runManager = Object.FindObjectOfType <RunManager>();

        // set activity platform label (todo: make nicer!)
        GameObject platform = this.transform.parent.transform.parent.gameObject;

        ap = platform.GetComponent <ActivityPlatform>();
        scheduleCollectableOffset = new Vector2(1.3f, .8f);
        if (ap.activity != null)
        {
            string prefix = ap.jumpNumber.ToString() + ") ";
            gameObject.GetComponent <TextMeshProUGUI>().text = prefix + ap.activity.name.ToString();
            // spawn collectible for scheduled activities
            if (gameManager.profile.GetSchedule(runManager.runState.timeSteps + 1) == ap.activity)
            {
                gameObject.GetComponent <TextMeshProUGUI>().text = gameObject.GetComponent <TextMeshProUGUI>().text;
                scheduleCollectable = Instantiate(ScheduleCollectablePrefab, ap.transform);
                scheduleCollectable.transform.localPosition = scheduleCollectableOffset;
            }
        }
    }
示例#4
0
    // correctly position platform based on current states
    public void Initialize(Activity _activity, int heightDiff, int jumpNumber)
    {
        activity        = _activity;
        explored        = false;
        jumpPadExplored = false;
        RunState runState = runManager.runState;

        this.jumpNumber = jumpNumber;
        // set the platform at the proper position
        // height specified by activity
        y = runState.height + heightDiff;
        // x to the right of current platform, if there is one
        x      = GapSize(heightDiff);
        length = platformLength;
        ActivityPlatform current = runState.CurrentActivityPlatform();

        if (current != null)
        {
            int endX = current.x + current.length;
            x = endX + GapSize(y - current.y) + jumpPadLength;
        }
        gameObject.transform.position = new Vector2(x, y);

        // scale the transform of the physical platform child to the proper length
        // (this will work as long as prefab is a unit cube with default scale)
        Transform ground = gameObject.transform.Find("Ground");

        ground.localScale = new Vector2(length, platformThickness);
        // scale the fixed length jump pad at the end of the platform
        Transform jumpPad = gameObject.transform.Find("JumpPad");

        jumpPad.localPosition = new Vector2(length, 0);
        jumpPad.localScale    = new Vector2(jumpPadLength, platformThickness);
    }
    // instantiate a new activity platform
    private void SpawnPlatform(Activity activity, int jumpNumber)
    {
        int        yDiff    = ActivityPlatform.PowerToYDiff(jumpNumber);
        GameObject platform = Instantiate(platformPrefab);

        platform.GetComponent <ActivityPlatform>().Initialize(activity, yDiff, jumpNumber);
        // add it to list of prospective platforms in runState
        runState.spawnedPlatforms.Add(platform.GetComponent <ActivityPlatform>());
    }
    // for when the player enters the jump Pad
    public void EnterJumpPad(ActivityPlatform activityPlatform)
    {
        // if failed tutorial, try again
        if (runState.timeSteps == 0 && runState.rhythmCombo == 0)
        {
            gameManager.showRhythmTutorial = true;
            gameManager.StartRun();
        }
        // if done, end run (and skip the rest of the procedure)
        if (runState.done)
        {
            gameManager.EndRun(runState);
            return;
        }
        // trigger end activity animation
        player.GetComponent <Animator>().SetTrigger("finishActivity");

        // Zoom out for jump
        camera.ZoomOut();

        if (activityPlatform != null)
        {
            // stop rhythm game
            if (runState.CurrentActivityPlatform())
            {
                rhythmManager.StopRhythm();
            }
        }

        // regenerate energy - ABORTED DUE TO ENERGY = COMBO
        runState.IncreaseEnergy(gameManager.profile.energyRegen);

        // cap energy
        // runState.energy = System.Math.Min(runState.energy, gameManager.profile.energyCap);

        // DEPRECATED  - now thru thought costs/ visibility + randomized heights
        // emotions take effect on difficulty of jumping to activities
        // (by adjusting height of current platform)
        // activityPlatform.Raise(runState.GetRaiseAmount());

        // spawn new set of platforms
        List <Activity> activities = SelectActivities();

        Debug.Assert(activities.Count() < 5);
        for (int i = 0; i < activities.Count(); i++)
        {
            SpawnPlatform(activities[i], i + 1);
        }
        SpawnPlatform(SelectDefaultActivity(), 0);
        SpawnPlatform(SelectBreakdownActivity(), -1);
        // clear out all other animation triggers
        player.GetComponent <Animator>().ResetTrigger(StartJump);
        player.GetComponent <Animator>().ResetTrigger(ActivityFail);
        player.GetComponent <Animator>().ResetTrigger(StartActivity);
        player.GetComponent <Animator>().SetBool(ChantBeforeBed, GameManager.Instance.profile.meditateBeforeBed);
        player.GetComponent <Animator>().SetBool(ExerciseKick, GameManager.Instance.profile.exerciseMartialArts);
    }
示例#7
0
    // helper function for classifying an activity
    public bool IsDefault(RunState runState)
    {
        // default activities can be normal activities as well - it depends on the runState
        ActivityPlatform current = runState.CurrentActivityPlatform();
        int h     = current ? current.y : 0;
        int ydiff = PlatformHeight(runState) - h;

        // any activity that is below threshold ydiff qualifies
        return(ydiff <= defaultPlatformHeightDiff && !isBreakdown);
    }
示例#8
0
    public Activity CurrentActivity()
    {
        ActivityPlatform ap = CurrentActivityPlatform();

        if (ap == null || ap.activity == null)
        {
            return(null);
        }
        return(ap.activity);
    }
示例#9
0
 // destroy all platforms in the prospective set except chosen, clear list
 public void ClearSpawned(ActivityPlatform chosen)
 {
     foreach (ActivityPlatform p in spawnedPlatforms)
     {
         if (p != chosen)
         {
             UnityEngine.Object.Destroy(p.gameObject);
         }
     }
     spawnedPlatforms.Clear();
 }
示例#10
0
    public void IncreaseCombo()
    {
        rhythmCombo++;
        rhythmBreakCount = 0;
        ActivityPlatform ap = CurrentActivityPlatform();

        if (rhythmCombo > ap.bestCombo)
        {
            ap.bestCombo = rhythmCombo;
        }
        // increase overall score
        score += Mathf.Max(1, rhythmCombo * scoreMultiplier);
    }
 // spawn random plumes of fire on the platform
 void SpawnFire(ActivityPlatform platform, int maxPlumes)
 {
     if (numFirePlumes < maxPlumes)
     {
         numFirePlumes++;
         // random x position along the platform
         Vector3    pos   = new Vector3(Random.Range(0, platform.length), 0, 0);
         GameObject plume = Instantiate(firePrefab, pos, Quaternion.identity, platform.transform);
         plume.transform.localPosition = pos;
         // random size
         float sizeFactor = Random.Range(0.5f, 1f);
         plume.transform.localScale = new Vector3(sizeFactor, sizeFactor, sizeFactor);
         plume.name = "FirePlume";
         StartCoroutine(FadeOutAndDestroyFire(plume.GetComponent <SpriteRenderer>(), Random.Range(1, 3f)));
     }
 }
示例#12
0
    // for when the player arrives on next activity, called via trigger in ActivityPlatform
    public void AdvanceTimeStep(ActivityPlatform newActivityPlatform)
    {
        if (newActivityPlatform != null)
        {
            // activate UI tutorial on first platform of run
            if (gameManager.showUITutorial)
            {
                tutorialManager.ActivateUITutorial();
            }

            // increment timeSteps
            runState.timeSteps += 1;

            // update activity history
            runState.activityHistory.Add(newActivityPlatform);
            runState.height = newActivityPlatform.y;

            // make first activity "sleep in"
            if (newActivityPlatform.activity == null)
            {
                Debug.Assert(runState.activityHistory.Count == 1);
                newActivityPlatform.activity = Object.FindObjectOfType <SleepIn>();
                runState.timeSteps           = 0;
            }
            else
            {
                // clear out other spawnedPlatforms
                runState.ClearSpawned(newActivityPlatform);
                // trigger activity special effect
                newActivityPlatform.activity.Effect(runState);
            }
            // start new platform spawning rhythm notes
            rhythmManager.StartRhythm(newActivityPlatform.activity);
            // start activity animation
            player.GetComponent <Animator>().SetInteger("activityHash", Animator.StringToHash(newActivityPlatform.activity.name));
            player.GetComponent <Animator>().SetTrigger("startActivity");
            // hack special case increase energy from martial arts
            if (GameManager.Instance.profile.exerciseMartialArts && newActivityPlatform.activity.name == "Exercise")
            {
                runState.energy += 5;
            }
        }

        // return zoom to normal
        camera.ZoomNormal();
    }
示例#13
0
    // (weighted) availability of activity, given state of run
    public int Availability(RunState runState)
    {
        // check that it's unlocked
        if (!isUnlocked)
        {
            return(0);
        }
        // disallow normal activity that would be at or below breakdown height, to avoid weird situations
        ActivityPlatform current = runState.CurrentActivityPlatform();
        int h     = current ? current.y : 0;
        int ydiff = PlatformHeight(runState) - h;

        if (ydiff <= breakdownPlatformHeightDiff && !isBreakdown)
        {
            return(0);
        }

        // don't allow any activities lower than the breakdown
        return(CustomAvailability(runState));
    }
示例#14
0
    void Awake()
    {
        GameObject platform = this.transform.parent.gameObject;

        ap = platform.GetComponent <ActivityPlatform>();
    }