mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-13 11:57:37 +02:00
Frog Hop (#900)
* frogge * a frogge * le froge * a frogge bip * added spins that don't work i mean forgge * spin it boys le frogge * sounds are working i mean le frogge * changing the prefab bc people are stupid and dumb * frogge is almost at your door * thank you very frogge * almost done frogge * done coding frogge * anim stuff frogge * literally almost ready to PR frogge too real * too frogging real * done frogge :3
This commit is contained in:
133
Assets/Scripts/Games/FrogHop/ntrFrog.cs
Normal file
133
Assets/Scripts/Games/FrogHop/ntrFrog.cs
Normal file
@ -0,0 +1,133 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using HeavenStudio.Util;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_FrogHop
|
||||
{
|
||||
public class ntrFrog : MonoBehaviour
|
||||
{
|
||||
//definitions
|
||||
#region Definitions
|
||||
|
||||
[SerializeField] public Animator FrogAnim;
|
||||
[SerializeField] public List<SpriteRenderer> SpriteParts = new();
|
||||
[SerializeField] public Transform MissFace;
|
||||
[SerializeField] public SpriteRenderer Head;
|
||||
|
||||
[NonSerialized] public int animSide = -1;
|
||||
[NonSerialized] public float scaleConstant = 1;
|
||||
[NonSerialized] public string loopAnim = null;
|
||||
[NonSerialized] public bool isBumped = false;
|
||||
|
||||
#endregion
|
||||
|
||||
//global methods
|
||||
#region Global Methods
|
||||
|
||||
public void Start()
|
||||
{
|
||||
scaleConstant = FrogAnim.transform.localScale.x;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
//frog methods
|
||||
#region Frog Methods
|
||||
|
||||
public void Bop()
|
||||
{
|
||||
FrogAnim.DoScaledAnimationAsync("Bop", 0.5f, animLayer: 0);
|
||||
isBumped = false;
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (loopAnim != null) FrogAnim.DoScaledAnimationAsync("Talk" + loopAnim, 0.5f, 0.5f, 1);
|
||||
}
|
||||
|
||||
public void Talk(string type, double animEnd)
|
||||
{
|
||||
SpriteRenderer isMissing = null;
|
||||
if (MissFace != null)
|
||||
{
|
||||
isMissing = MissFace.GetComponent<SpriteRenderer>();
|
||||
if (isMissing.enabled) return;
|
||||
}
|
||||
|
||||
loopAnim = type;
|
||||
BeatAction.New(this, new List<BeatAction.Action>()
|
||||
{ new BeatAction.Action(animEnd, delegate { FrogAnim.DoScaledAnimationAsync("Talk" + type, 0.5f, 0.5f, 1); loopAnim = null; }) });
|
||||
}
|
||||
|
||||
public void Hop(int side = 0, bool isLong = false)
|
||||
{
|
||||
SwapSide(side);
|
||||
|
||||
FrogAnim.transform.localScale = new Vector3(animSide * scaleConstant, scaleConstant, 1);
|
||||
FrogAnim.DoScaledAnimationAsync(isLong ? "LongHop" : "Hop", 0.5f, animLayer: 0);
|
||||
|
||||
isBumped = false;
|
||||
}
|
||||
|
||||
public void Charge(int side = 0)
|
||||
{
|
||||
SwapSide(side);
|
||||
|
||||
FrogAnim.transform.localScale = new Vector3(animSide * scaleConstant, scaleConstant, 1);
|
||||
FrogAnim.DoScaledAnimationAsync("Charge", 0.5f, animLayer: 0);
|
||||
|
||||
isBumped = false;
|
||||
}
|
||||
|
||||
public void Spin()
|
||||
{
|
||||
FrogAnim.DoScaledAnimationAsync("Spin", 0.5f, animLayer: 0);
|
||||
|
||||
isBumped = false;
|
||||
}
|
||||
|
||||
public void Glare()
|
||||
{
|
||||
FrogAnim.DoScaledAnimationAsync("Glare", 0.5f, 0.5f, 1);
|
||||
}
|
||||
|
||||
public void Sweat()
|
||||
{
|
||||
FrogAnim.DoScaledAnimationAsync("Sweat", 0.5f, 0.5f, animLayer: 2);
|
||||
}
|
||||
|
||||
public void Bump()
|
||||
{
|
||||
if (!isBumped)
|
||||
{
|
||||
isBumped = true;
|
||||
FrogAnim.transform.localScale = new Vector3(scaleConstant, scaleConstant, 1);
|
||||
|
||||
FrogAnim.DoScaledAnimationAsync("Ouch", 0.5f, 0.5f, 1);
|
||||
FrogAnim.DoScaledAnimationAsync("Bump", 0.5f, animLayer: 0);
|
||||
|
||||
SoundByte.PlayOneShotGame("frogHop/SE_NTR_FROG_EN_MISS");
|
||||
SoundByte.PlayOneShotGame("frogHop/SE_NTR_FROG_EN_MISS_BOING");
|
||||
}
|
||||
}
|
||||
|
||||
public void SwapSide(int side)
|
||||
{
|
||||
if (side != 0) animSide = side;
|
||||
else animSide *= -1;
|
||||
if (MissFace != null) MissFace.localScale = new Vector3(animSide, 1, 1);
|
||||
Head.flipX = animSide > 0;
|
||||
}
|
||||
|
||||
public void Darken(bool reverse = false)
|
||||
{
|
||||
if (!reverse) foreach (var a in SpriteParts) { a.color = new Color(0.5f, 0.5f, 0.5f, 1); }
|
||||
else foreach (var a in SpriteParts) { a.color = new Color(1, 1, 1, 1); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user