HeavenStudioPlus/Assets/Scripts/Games/MrUpbeat/UpbeatMan.cs

105 lines
2.6 KiB
C#
Raw Normal View History

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using Starpelly;
using RhythmHeavenMania.Util;
namespace RhythmHeavenMania.Games.MrUpbeat
{
public class UpbeatMan : PlayerActionObject
{
[Header("References")]
public MrUpbeat game;
public Animator animator;
public Animator blipAnimator;
public GameObject[] shadows;
2022-03-05 03:10:10 +00:00
public float targetBeat = 0.25f;
public int stepTimes = 0;
2022-03-05 03:10:10 +00:00
private bool stepped = false;
public GameEvent blip = new GameEvent();
private void Update()
{
2022-03-05 03:10:10 +00:00
float normalizedBeat = Conductor.instance.GetPositionFromMargin(targetBeat, 0.5f);
StateCheck(normalizedBeat);
2022-03-05 03:10:10 +00:00
if(game.canGo && normalizedBeat > Minigame.LateTime())
{
2022-03-06 17:34:54 +00:00
if ((game.beatCount % 2 == 0 && stepTimes % 2 == 0) || (game.beatCount % 2 == 1 && stepTimes % 2 == 1))
{
Fall();
}
2022-03-05 03:10:10 +00:00
targetBeat += 100f;
return;
}
if (PlayerInput.Pressed())
{
if (state.perfect)
{
Step();
2022-03-05 03:10:10 +00:00
}
else if(state.notPerfect())
{
Fall();
}
2022-03-05 03:10:10 +00:00
else
{
Step();
}
}
}
2022-03-05 03:10:10 +00:00
public override void OnAce()
{
2022-03-05 03:10:10 +00:00
if (!game.canGo) return;
Step();
}
2022-03-05 03:10:10 +00:00
public void Idle()
{
2022-03-05 03:10:10 +00:00
stepTimes = 0;
transform.localScale = new Vector3(1, 1);
animator.Play("Idle", 0, 0);
}
public void Step()
{
stepTimes++;
2022-03-05 03:10:10 +00:00
animator.Play("Step", 0, 0);
Jukebox.PlayOneShotGame("mrUpbeat/step");
if (stepTimes % 2 == 1)
2022-03-05 03:10:10 +00:00
{
shadows[0].SetActive(false);
shadows[1].SetActive(true);
transform.localScale = new Vector3(-1, 1);
2022-03-05 03:10:10 +00:00
} else
{
shadows[0].SetActive(true);
shadows[1].SetActive(false);
transform.localScale = new Vector3(1, 1);
2022-03-05 03:10:10 +00:00
}
}
public void Fall()
{
2022-03-05 03:10:10 +00:00
animator.Play("Fall", 0, 0);
Jukebox.PlayOneShot("miss");
}
public void Blip()
{
Jukebox.PlayOneShotGame("mrUpbeat/blip");
blipAnimator.Play("Blip", 0, 0);
}
}
}