mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-12 12:07:41 +02:00
replace old karate man prefab with new one
This commit is contained in:
@ -1,58 +1,41 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using HeavenStudio.Util;
|
||||
|
||||
//THIS CLASS IS TO BE RENAMED
|
||||
|
||||
namespace HeavenStudio.Games.Loaders
|
||||
{
|
||||
using static Minigames;
|
||||
public static class RvlKarateLoader
|
||||
public static class RvlNewKarateLoader
|
||||
{
|
||||
public static Minigame AddGame(EventCaller eventCaller) {
|
||||
return new Minigame("karateman", "Karate Man", "70A8D8", false, false, new List<GameAction>()
|
||||
return new Minigame("karateman", "Karate Man [INDEV REWORK]", "70A8D8", false, false, new List<GameAction>()
|
||||
{
|
||||
new GameAction("bop", delegate { KarateMan.instance.Bop(eventCaller.currentEntity.beat, eventCaller.currentEntity.length); }, 0.5f, true),
|
||||
new GameAction("hit", delegate
|
||||
{
|
||||
KarateMan.instance.Shoot(eventCaller.currentEntity.beat, eventCaller.currentEntity.type);
|
||||
}, 2, false, new List<Param>()
|
||||
{
|
||||
new Param("type", KarateMan.HitType.Pot, "Object", "The object to fire")
|
||||
}),
|
||||
new GameAction("bulb", delegate {
|
||||
var e = eventCaller.currentEntity;
|
||||
var c = KarateMan.instance.LightBulbColors[e.type];
|
||||
if(e.type == (int)KarateMan.LightBulbType.Custom) c = e.colorA;
|
||||
KarateMan.instance.Shoot(e.beat, 1, tint: c);
|
||||
}, 2, false, new List<Param>()
|
||||
{
|
||||
new Param("type", KarateMan.LightBulbType.Normal, "Type", "The preset bulb type. Yellow is used for kicks while Blue is used for combos"),
|
||||
new Param("colorA", new Color(), "Custom Color", "The color to use when the bulb type is set to Custom")
|
||||
}),
|
||||
new GameAction("kick", delegate { KarateMan.instance.Shoot(eventCaller.currentEntity.beat, 4); }, 4.5f),
|
||||
new GameAction("combo", delegate { KarateMan.instance.Combo(eventCaller.currentEntity.beat); }, 4f),
|
||||
new GameAction("hitX", delegate
|
||||
{
|
||||
var e = eventCaller.currentEntity;
|
||||
switch ((KarateMan.HitThree)e.type)
|
||||
new GameAction("bop", delegate { }, 0.5f, true),
|
||||
new GameAction("hit", delegate { var e = eventCaller.currentEntity; KarateMan.instance.CreateItem(e.beat, e.type); }, 2, false,
|
||||
new List<Param>()
|
||||
{
|
||||
case KarateMan.HitThree.HitTwo: KarateMan.instance.Hit2(e.beat); break;
|
||||
case KarateMan.HitThree.HitThreeAlt: KarateMan.instance.Hit3(e.beat, true); break;
|
||||
case KarateMan.HitThree.HitFour: KarateMan.instance.Hit4(e.beat); break;
|
||||
default: KarateMan.instance.Hit3(e.beat); break;
|
||||
}
|
||||
}, 1f, false, new List<Param>()
|
||||
{
|
||||
new Param("type", KarateMan.HitThree.HitThree, "Type", "What should be called out")
|
||||
}),
|
||||
new GameAction("prepare", delegate { KarateMan.instance.Prepare(eventCaller.currentEntity.beat, eventCaller.currentEntity.length); }, 1f, true),
|
||||
new Param("type", KarateMan.HitType.Pot, "Object", "The object to fire")
|
||||
}),
|
||||
new GameAction("bulb", delegate { var e = eventCaller.currentEntity; KarateMan.instance.CreateBulbSpecial(e.beat, e.type, e.colorA); }, 2, false,
|
||||
new List<Param>()
|
||||
{
|
||||
new Param("type", KarateMan.LightBulbType.Normal, "Type", "The preset bulb type. Yellow is used for kicks while Blue is used for combos"),
|
||||
new Param("colorA", new Color(), "Custom Color", "The color to use when the bulb type is set to Custom")
|
||||
}),
|
||||
new GameAction("kick", delegate { }, 4f),
|
||||
new GameAction("combo", delegate { KarateMan.instance.Combo(eventCaller.currentEntity.beat); }, 4f),
|
||||
new GameAction("hitX", delegate { var e = eventCaller.currentEntity; KarateMan.instance.DoWord(e.beat, e.type); }, 1f, false,
|
||||
new List<Param>()
|
||||
{
|
||||
new Param("type", KarateMan.HitThree.HitThree, "Type", "The warning text to show")
|
||||
}),
|
||||
new GameAction("prepare", delegate { }, 1f, true),
|
||||
new GameAction("set background effects", delegate {
|
||||
var e = eventCaller.currentEntity;
|
||||
var c = KarateMan.instance.BackgroundColors[e.type];
|
||||
if(e.type == (int)KarateMan.BackgroundType.Custom) c = e.colorA;
|
||||
KarateMan.instance.SetBackgroundColor(e.type, e.type2, c, e.colorB);
|
||||
KarateMan.instance.SetBackgroundFX((KarateMan.BackgroundFXType)eventCaller.currentEntity.type3);
|
||||
}, 0.5f, false, new List<Param>()
|
||||
{
|
||||
new Param("type", KarateMan.BackgroundType.Yellow, "Background Type", "The preset background type"),
|
||||
@ -62,27 +45,38 @@ namespace HeavenStudio.Games.Loaders
|
||||
new Param("type3", KarateMan.BackgroundFXType.None, "FX Type", "The background effect to be displayed")
|
||||
|
||||
}),
|
||||
|
||||
|
||||
// These are still here for backwards-compatibility but are hidden in the editor
|
||||
new GameAction("pot", delegate { KarateMan.instance.Shoot(eventCaller.currentEntity.beat, 0); }, 2, hidden: true),
|
||||
new GameAction("rock", delegate { KarateMan.instance.Shoot(eventCaller.currentEntity.beat, 2); }, 2, hidden: true),
|
||||
new GameAction("ball", delegate { KarateMan.instance.Shoot(eventCaller.currentEntity.beat, 3); }, 2, hidden: true),
|
||||
new GameAction("tacobell", delegate { KarateMan.instance.Shoot(eventCaller.currentEntity.beat, 999); }, 2, hidden: true),
|
||||
new GameAction("hit4", delegate { KarateMan.instance.Hit4(eventCaller.currentEntity.beat); }, hidden: true),
|
||||
new GameAction("bgfxon", delegate { KarateMan.instance.SetBackgroundFX(KarateMan.BackgroundFXType.Sunburst); }, hidden: true),
|
||||
new GameAction("bgfxoff", delegate { KarateMan.instance.SetBackgroundFX(KarateMan.BackgroundFXType.None); }, hidden: true),
|
||||
new GameAction("pot", delegate { KarateMan.instance.CreateItem(eventCaller.currentEntity.beat, (int) KarateMan.HitType.Pot); }, 2, hidden: true),
|
||||
new GameAction("rock", delegate { KarateMan.instance.CreateItem(eventCaller.currentEntity.beat, (int) KarateMan.HitType.Rock); }, 2, hidden: true),
|
||||
new GameAction("ball", delegate { KarateMan.instance.CreateItem(eventCaller.currentEntity.beat, (int) KarateMan.HitType.Ball); }, 2, hidden: true),
|
||||
new GameAction("tacobell", delegate { KarateMan.instance.CreateItem(eventCaller.currentEntity.beat, (int) KarateMan.HitType.TacoBell); }, 2, hidden: true),
|
||||
new GameAction("hit4", delegate { KarateMan.instance.DoWord(eventCaller.currentEntity.beat, (int) KarateMan.HitThree.HitFour); }, hidden: true),
|
||||
new GameAction("bgfxon", delegate { }, hidden: true),
|
||||
new GameAction("bgfxoff", delegate { }, hidden: true),
|
||||
new GameAction("hit3", delegate { var e = eventCaller.currentEntity; KarateMan.instance.DoWord(e.beat, e.type); }, 1f, false,
|
||||
new List<Param>()
|
||||
{
|
||||
new Param("type", KarateMan.HitThree.HitThree, "Type", "The warning text to show")
|
||||
},
|
||||
hidden: true),
|
||||
new GameAction("set background color", delegate { }, 0.5f, false,
|
||||
new List<Param>()
|
||||
{
|
||||
new Param("type", KarateMan.BackgroundType.Yellow, "Background Type", "The preset background type"),
|
||||
new Param("type2", KarateMan.ShadowType.Tinted, "Shadow Type", "The shadow type. If Tinted doesn't work with your background color try Custom"),
|
||||
new Param("colorA", new Color(), "Custom Background Color", "The background color to use when background type is set to Custom"),
|
||||
new Param("colorB", new Color(), "Custom Shadow Color", "The shadow color to use when shadow type is set to Custom"),
|
||||
|
||||
}),
|
||||
new GameAction("set background fx", delegate {
|
||||
KarateMan.instance.SetBackgroundFX((KarateMan.BackgroundFXType)eventCaller.currentEntity.type);
|
||||
}, 0.5f, false, new List<Param>()
|
||||
{
|
||||
new Param("type", KarateMan.BackgroundFXType.None, "FX Type", "The background effect to be displayed")
|
||||
|
||||
},
|
||||
hidden: true
|
||||
)
|
||||
|
||||
hidden: true)
|
||||
|
||||
});;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -90,18 +84,18 @@ namespace HeavenStudio.Games.Loaders
|
||||
namespace HeavenStudio.Games
|
||||
{
|
||||
using Scripts_KarateMan;
|
||||
|
||||
public class KarateMan : Minigame
|
||||
{
|
||||
public static KarateMan instance;
|
||||
|
||||
public enum HitType
|
||||
{
|
||||
Pot = 0,
|
||||
Lightbulb = 1,
|
||||
Rock = 2,
|
||||
Ball = 3,
|
||||
CookingPot = 6,
|
||||
Alien = 7,
|
||||
|
||||
TacoBell = 999
|
||||
}
|
||||
|
||||
@ -110,7 +104,11 @@ namespace HeavenStudio.Games
|
||||
HitTwo,
|
||||
HitThree,
|
||||
HitThreeAlt,
|
||||
HitFour
|
||||
HitFour,
|
||||
Grr,
|
||||
Warning,
|
||||
Combo,
|
||||
HitOne,
|
||||
}
|
||||
|
||||
public enum LightBulbType
|
||||
@ -136,7 +134,8 @@ namespace HeavenStudio.Games
|
||||
{
|
||||
None,
|
||||
Sunburst,
|
||||
Rings
|
||||
Rings,
|
||||
Fade
|
||||
}
|
||||
|
||||
public enum ShadowType
|
||||
@ -148,81 +147,181 @@ namespace HeavenStudio.Games
|
||||
public Color[] LightBulbColors;
|
||||
public Color[] BackgroundColors;
|
||||
public Color[] ShadowColors;
|
||||
public static Color ShadowBlendColor = new Color(195f / 255f, 48f / 255f, 2f / 255f);
|
||||
|
||||
//camera positions (normal, special)
|
||||
public Transform[] CameraPosition;
|
||||
Vector3 cameraPosition;
|
||||
|
||||
//pot trajectory stuff
|
||||
public Transform ItemHolder;
|
||||
public GameObject Item;
|
||||
public KarateManJoe Joe;
|
||||
|
||||
//warning text
|
||||
public Animator Word;
|
||||
float wordClearTime = Single.MinValue;
|
||||
const float hitVoiceOffset = 0.042f;
|
||||
|
||||
public GameObject Pot, Bomb;
|
||||
public KarateJoe KarateJoe;
|
||||
|
||||
public List<Minigame.Eligible> EligibleCombos = new List<Minigame.Eligible>();
|
||||
|
||||
public static KarateMan instance { get; set; }
|
||||
|
||||
public Sprite[] ObjectSprites;
|
||||
public Sprite[] BarrelSprites;
|
||||
public Sprite[] CookingPotSprites;
|
||||
public Sprite[] OtherSprites;
|
||||
|
||||
public List<BGSpriteC> BGSprites;
|
||||
public SpriteRenderer BGSprite;
|
||||
public SpriteRenderer BGFXSprite;
|
||||
|
||||
public BackgroundType BGType = BackgroundType.Yellow;
|
||||
public BackgroundFXType BGFXType = BackgroundFXType.None;
|
||||
public Color BGColor;
|
||||
|
||||
public ShadowType Shadow = ShadowType.Tinted;
|
||||
public Color ShadowColor = Color.black;
|
||||
|
||||
private float newBeat;
|
||||
|
||||
public GameEvent bop = new GameEvent();
|
||||
public GameEvent prepare = new GameEvent();
|
||||
|
||||
private float bgBeat;
|
||||
|
||||
public ParticleSystem potHitEffect;
|
||||
|
||||
public GameObject comboRef;
|
||||
|
||||
public GameObject HIT3Ref;
|
||||
|
||||
public Sprite[] Numbers;
|
||||
|
||||
|
||||
[System.Serializable]
|
||||
public class BGSpriteC
|
||||
{
|
||||
public List<Sprite> Sprites;
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
BGType = 0;
|
||||
BGColor = BackgroundColors[0];
|
||||
Shadow = 0;
|
||||
KarateManPot.ResetLastCombo();
|
||||
cameraPosition = CameraPosition[0].position;
|
||||
}
|
||||
|
||||
public override void OnGameSwitch(float beat)
|
||||
private void Start()
|
||||
{
|
||||
base.OnGameSwitch(beat);
|
||||
SetBackgroundColor((int)BGType, (int)Shadow, BGColor, ShadowColor);
|
||||
GameCamera.additionalPosition = cameraPosition - GameCamera.defaultPosition;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
GameCamera.additionalPosition = cameraPosition - GameCamera.defaultPosition;
|
||||
if (Conductor.instance.songPositionInBeats >= wordClearTime)
|
||||
{
|
||||
Word.Play("NoPose");
|
||||
}
|
||||
}
|
||||
|
||||
public void DoWord(float beat, int type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case (int) HitThree.HitTwo:
|
||||
Word.Play("Word02");
|
||||
wordClearTime = beat + 4f;
|
||||
MultiSound.Play(new MultiSound.Sound[]
|
||||
{
|
||||
new MultiSound.Sound("karateman/hit", beat + 0.5f, offset: hitVoiceOffset),
|
||||
new MultiSound.Sound("karateman/two", beat + 1f),
|
||||
}, forcePlay: true);
|
||||
break;
|
||||
case (int) HitThree.HitThree:
|
||||
Word.Play("Word03");
|
||||
wordClearTime = beat + 4f;
|
||||
MultiSound.Play(new MultiSound.Sound[]
|
||||
{
|
||||
new MultiSound.Sound("karateman/hit", beat + 0.5f, offset: hitVoiceOffset),
|
||||
new MultiSound.Sound("karateman/three", beat + 1f),
|
||||
}, forcePlay: true);
|
||||
break;
|
||||
case (int) HitThree.HitThreeAlt:
|
||||
Word.Play("Word03");
|
||||
wordClearTime = beat + 4f;
|
||||
MultiSound.Play(new MultiSound.Sound[]
|
||||
{
|
||||
new MultiSound.Sound("karateman/hitAlt", beat + 0.5f, offset: hitVoiceOffset),
|
||||
new MultiSound.Sound("karateman/threeAlt", beat + 1f),
|
||||
}, forcePlay: true);
|
||||
break;
|
||||
case (int) HitThree.HitFour:
|
||||
Word.Play("Word04");
|
||||
wordClearTime = beat + 4f;
|
||||
MultiSound.Play(new MultiSound.Sound[]
|
||||
{
|
||||
new MultiSound.Sound("karateman/hit", beat + 0.5f, offset: hitVoiceOffset),
|
||||
new MultiSound.Sound("karateman/four", beat + 1f),
|
||||
}, forcePlay: true);
|
||||
break;
|
||||
case (int) HitThree.Grr:
|
||||
Word.Play("Word01");
|
||||
wordClearTime = beat + 1f;
|
||||
break;
|
||||
case (int) HitThree.Warning:
|
||||
Word.Play("Word05");
|
||||
wordClearTime = beat + 1f;
|
||||
break;
|
||||
case (int) HitThree.Combo:
|
||||
Word.Play("Word00");
|
||||
wordClearTime = beat + 3f;
|
||||
break;
|
||||
case (int) HitThree.HitOne: //really?
|
||||
Word.Play("Word06");
|
||||
wordClearTime = beat + 4f;
|
||||
MultiSound.Play(new MultiSound.Sound[]
|
||||
{
|
||||
new MultiSound.Sound("karateman/hit", beat + 0.5f, offset: hitVoiceOffset),
|
||||
new MultiSound.Sound("karateman/one", beat + 1f),
|
||||
}, forcePlay: true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void CreateItem(float beat, int type)
|
||||
{
|
||||
|
||||
string outSound;
|
||||
if (Starpelly.Mathp.GetDecimalFromFloat(beat + 0.5f) == 0f)
|
||||
outSound = "karateman/offbeatObjectOut";
|
||||
else
|
||||
outSound = "karateman/objectOut";
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case (int) HitType.Pot:
|
||||
CreateItemInstance(beat, "Item00");
|
||||
break;
|
||||
case (int) HitType.Lightbulb:
|
||||
if (Starpelly.Mathp.GetDecimalFromFloat(beat + 0.5f) == 0f)
|
||||
outSound = "karateman/offbeatLightbulbOut";
|
||||
else
|
||||
outSound = "karateman/lightbulbOut";
|
||||
var mobj = CreateItemInstance(beat, "Item01", KarateManPot.ItemType.Bulb);
|
||||
mobj.GetComponent<KarateManPot>().SetBulbColor(LightBulbColors[0]);
|
||||
break;
|
||||
case (int) HitType.Rock:
|
||||
CreateItemInstance(beat, "Item02", KarateManPot.ItemType.Rock);
|
||||
break;
|
||||
case (int) HitType.Ball:
|
||||
CreateItemInstance(beat, "Item03", KarateManPot.ItemType.Ball);
|
||||
break;
|
||||
case (int) HitType.CookingPot:
|
||||
CreateItemInstance(beat, "Item06", KarateManPot.ItemType.Cooking);
|
||||
break;
|
||||
case (int) HitType.Alien:
|
||||
CreateItemInstance(beat, "Item07", KarateManPot.ItemType.Alien);
|
||||
break;
|
||||
case (int) HitType.TacoBell:
|
||||
CreateItemInstance(beat, "Item99", KarateManPot.ItemType.TacoBell);
|
||||
break;
|
||||
default:
|
||||
CreateItemInstance(beat, "Item00");
|
||||
break;
|
||||
}
|
||||
Jukebox.PlayOneShotGame(outSound, forcePlay: true);
|
||||
}
|
||||
|
||||
public void CreateBulbSpecial(float beat, int type, Color c)
|
||||
{
|
||||
string outSound;
|
||||
if (Starpelly.Mathp.GetDecimalFromFloat(beat + 0.5f) == 0f)
|
||||
outSound = "karateman/offbeatLightbulbOut";
|
||||
else
|
||||
outSound = "karateman/lightbulbOut";
|
||||
var mobj = CreateItemInstance(beat, "Item01", KarateManPot.ItemType.Bulb);
|
||||
|
||||
if (type == (int) LightBulbType.Custom)
|
||||
mobj.GetComponent<KarateManPot>().SetBulbColor(c);
|
||||
else
|
||||
mobj.GetComponent<KarateManPot>().SetBulbColor(LightBulbColors[type]);
|
||||
Jukebox.PlayOneShotGame(outSound, forcePlay: true);
|
||||
}
|
||||
|
||||
public void Combo(float beat)
|
||||
{
|
||||
comboRef.GetComponent<Animator>().enabled = true;
|
||||
comboRef.GetComponent<Animator>().Play("comboRef");
|
||||
Jukebox.PlayOneShotGame("karateman/barrelOutCombos");
|
||||
Jukebox.PlayOneShotGame("karateman/barrelOutCombos", forcePlay: true);
|
||||
|
||||
Shoot(beat, 0, true, "PotCombo1", 0, new Vector2(-0.94f, -2.904f));
|
||||
Shoot(beat + 0.25f, 0, true, "PotCombo2", 1, new Vector2(-0.94f, -2.904f));
|
||||
Shoot(beat + 0.5f, 0, true, "PotCombo3", 2, new Vector2(-0.776f, -3.162f));
|
||||
Shoot(beat + 0.75f, 0, true, "PotCombo4", 3, new Vector2(1.453f, -3.162f));
|
||||
Shoot(beat + 1f, 0, true, "PotCombo5", 4, new Vector2(0.124f, -3.123f));
|
||||
Shoot(beat + 1.5f, 4, true, "PotCombo6", 5, new Vector2(-1.333f, -2.995f));
|
||||
int comboId = KarateManPot.GetNewCombo();
|
||||
|
||||
BeatAction.New(gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat, delegate { CreateItemInstance(beat, "Item00", KarateManPot.ItemType.ComboPot1, comboId); }),
|
||||
new BeatAction.Action(beat + 0.25f, delegate { CreateItemInstance(beat + 0.25f, "Item00", KarateManPot.ItemType.ComboPot2, comboId); }),
|
||||
new BeatAction.Action(beat + 0.5f, delegate { CreateItemInstance(beat + 0.5f, "Item00", KarateManPot.ItemType.ComboPot3, comboId); }),
|
||||
new BeatAction.Action(beat + 0.75f, delegate { CreateItemInstance(beat + 0.75f, "Item00", KarateManPot.ItemType.ComboPot4, comboId); }),
|
||||
new BeatAction.Action(beat + 1f, delegate { CreateItemInstance(beat + 1f, "Item00", KarateManPot.ItemType.ComboPot5, comboId); }),
|
||||
new BeatAction.Action(beat + 1.5f, delegate { CreateItemInstance(beat + 1.5f, "Item05", KarateManPot.ItemType.ComboBarrel, comboId); }),
|
||||
});
|
||||
|
||||
MultiSound.Play(new MultiSound.Sound[]
|
||||
{
|
||||
@ -232,267 +331,21 @@ namespace HeavenStudio.Games
|
||||
new MultiSound.Sound("karateman/punchy4", beat + 1.75f),
|
||||
new MultiSound.Sound("karateman/ko", beat + 2f),
|
||||
new MultiSound.Sound("karateman/pow", beat + 2.5f)
|
||||
});
|
||||
}, forcePlay: true);
|
||||
}
|
||||
|
||||
public void Shoot(float beat, int type, bool combo = false, string throwAnim = "", int comboIndex = 0, Vector2 endShadowPos = new Vector2(), UnityEngine.Color tint = default)
|
||||
GameObject CreateItemInstance(float beat, string awakeAnim, KarateManPot.ItemType type = KarateManPot.ItemType.Pot, int comboId = -1)
|
||||
{
|
||||
GameObject pot = Instantiate(Pot);
|
||||
pot.transform.parent = Pot.transform.parent;
|
||||
GameObject mobj = GameObject.Instantiate(Item, ItemHolder);
|
||||
KarateManPot mobjDat = mobj.GetComponent<KarateManPot>();
|
||||
mobjDat.type = type;
|
||||
mobjDat.startBeat = beat;
|
||||
mobjDat.awakeAnim = awakeAnim;
|
||||
mobjDat.comboId = comboId;
|
||||
|
||||
if (KarateJoe.instance.anim.IsAnimationNotPlaying())
|
||||
KarateJoe.instance.SetHead(0);
|
||||
|
||||
Pot p = pot.GetComponent<Pot>();
|
||||
|
||||
pot.SetActive(true);
|
||||
p.startBeat = beat;
|
||||
p.createBeat = beat;
|
||||
p.isThrown = true;
|
||||
p.type = type;
|
||||
|
||||
if(type <= ObjectSprites.Length)
|
||||
p.Sprite.GetComponent<SpriteRenderer>().sprite = ObjectSprites[type];
|
||||
|
||||
if (combo)
|
||||
{
|
||||
p.comboIndex = comboIndex;
|
||||
p.throwAnim = throwAnim;
|
||||
p.combo = true;
|
||||
KarateJoe.currentComboPots.Add(p);
|
||||
p.endShadowThrowPos = endShadowPos;
|
||||
}
|
||||
else
|
||||
{
|
||||
p.throwAnim = "PotThrow";
|
||||
|
||||
string outSnd = "";
|
||||
switch (type)
|
||||
{
|
||||
case 0:
|
||||
if (Starpelly.Mathp.GetDecimalFromFloat(beat) == 0f)
|
||||
outSnd = "karateman/objectOut";
|
||||
else
|
||||
outSnd = "karateman/offbeatObjectOut";
|
||||
p.hitSnd = "karateman/potHit";
|
||||
break;
|
||||
case 1:
|
||||
outSnd = "karateman/lightbulbOut";
|
||||
p.hitSnd = "karateman/lightbulbHit";
|
||||
if (tint != default && tint != Color.black) {
|
||||
p.BulbLightSprite.SetActive(true);
|
||||
p.BulbLightSprite.GetComponent<SpriteRenderer>().color = tint;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (Starpelly.Mathp.GetDecimalFromFloat(beat) == 0f)
|
||||
outSnd = "karateman/objectOut";
|
||||
else
|
||||
outSnd = "karateman/offbeatObjectOut";
|
||||
p.hitSnd = "karateman/rockHit";
|
||||
break;
|
||||
case 3:
|
||||
if (Starpelly.Mathp.GetDecimalFromFloat(beat) == 0f)
|
||||
outSnd = "karateman/objectOut";
|
||||
else
|
||||
outSnd = "karateman/offbeatObjectOut";
|
||||
p.hitSnd = "karateman/soccerHit";
|
||||
break;
|
||||
case 4:
|
||||
p.kick = true;
|
||||
outSnd = "karateman/barrelOutKicks";
|
||||
p.hitSnd = "karateman/barrelBreak";
|
||||
|
||||
MultiSound.Play(new MultiSound.Sound[]
|
||||
{
|
||||
new MultiSound.Sound("karateman/punchKick1", beat + 1f),
|
||||
new MultiSound.Sound("karateman/punchKick2", beat + 1.5f),
|
||||
new MultiSound.Sound("karateman/punchKick3", beat + 1.75f),
|
||||
new MultiSound.Sound("karateman/punchKick4", beat + 2.25f)
|
||||
});
|
||||
break;
|
||||
case 6:
|
||||
if (Starpelly.Mathp.GetDecimalFromFloat(beat) == 0f)
|
||||
outSnd = "karateman/objectOut";
|
||||
else
|
||||
outSnd = "karateman/offbeatObjectOut";
|
||||
p.hitSnd = "karateman/cookingPot";
|
||||
break;
|
||||
case 7:
|
||||
if (Starpelly.Mathp.GetDecimalFromFloat(beat) == 0f)
|
||||
outSnd = "karateman/objectOut";
|
||||
else
|
||||
outSnd = "karateman/offbeatObjectOut";
|
||||
p.hitSnd = "karateman/alienHit";
|
||||
break;
|
||||
case 999:
|
||||
p.Sprite.GetComponent<SpriteRenderer>().sprite = OtherSprites[0];
|
||||
if (Starpelly.Mathp.GetDecimalFromFloat(beat) == 0f)
|
||||
outSnd = "karateman/objectOut";
|
||||
else
|
||||
outSnd = "karateman/offbeatObjectOut";
|
||||
p.hitSnd = "karateman/tacobell";
|
||||
break;
|
||||
}
|
||||
|
||||
p.endShadowThrowPos = new Vector2(-1.036f, -2.822f);
|
||||
|
||||
Jukebox.PlayOneShotGame(outSnd);
|
||||
}
|
||||
p.Init();
|
||||
}
|
||||
|
||||
List<Beatmap.Entity> cuedVoices = new List<Beatmap.Entity>(); // "Hit" voices cued in advance are stored here so they aren't called multiple times in Update().
|
||||
private void Update()
|
||||
{
|
||||
if (Conductor.instance.ReportBeat(ref newBeat))
|
||||
{
|
||||
if (BGFXSprite.enabled)
|
||||
{
|
||||
var type = (int)BGFXType - 1;
|
||||
if (bgBeat % 2 == 0)
|
||||
{
|
||||
BGFXSprite.sprite = BGSprites[type].Sprites[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
BGFXSprite.sprite = BGSprites[type].Sprites[1];
|
||||
}
|
||||
bgBeat++;
|
||||
}
|
||||
}
|
||||
|
||||
if (Conductor.instance.ReportBeat(ref bop.lastReportedBeat, bop.startBeat % 1))
|
||||
{
|
||||
if (Conductor.instance.songPositionInBeats >= bop.startBeat && Conductor.instance.songPositionInBeats < bop.startBeat + bop.length)
|
||||
{
|
||||
if (KarateJoe.anim.IsAnimationNotPlaying())
|
||||
KarateJoe.anim.Play("Bop", 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (prepare.length > 0)
|
||||
{
|
||||
if (Conductor.instance.songPositionInBeats >= prepare.startBeat && Conductor.instance.songPositionInBeats < prepare.startBeat + prepare.length)
|
||||
{
|
||||
if (KarateJoe.anim.IsAnimationNotPlaying())
|
||||
KarateJoe.AnimPlay("Prepare");
|
||||
}
|
||||
else
|
||||
{
|
||||
KarateJoe.AnimPlay("Idle");
|
||||
prepare.length = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!Conductor.instance.isPlaying)
|
||||
return;
|
||||
|
||||
// Call "hit" voice slightly early to account for sound offset.
|
||||
var hitVoiceEvents = GameManager.instance.Beatmap.entities.FindAll(c => c.datamodel == "karateman/hit3" || c.datamodel == "karateman/hit4");
|
||||
for (int i = 0; i < hitVoiceEvents.Count; i++)
|
||||
{
|
||||
var hitEvent = hitVoiceEvents[i];
|
||||
var timeToEvent = hitEvent.beat - Conductor.instance.songPositionInBeats;
|
||||
if (timeToEvent <= 1f && timeToEvent > 0f && !cuedVoices.Contains(hitEvent))
|
||||
{
|
||||
cuedVoices.Add(hitEvent);
|
||||
var sound = "karateman/hit";
|
||||
if (hitEvent.type == (int)KarateMan.HitThree.HitThreeAlt) sound += "Alt";
|
||||
MultiSound.Play(new MultiSound.Sound[] { new MultiSound.Sound(sound, hitEvent.beat - hitVoiceOffset * Conductor.instance.songBpm / 60f) });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetBackgroundFX(BackgroundFXType type)
|
||||
{
|
||||
BGFXType = type;
|
||||
|
||||
if (BGFXType == BackgroundFXType.None)
|
||||
{
|
||||
BGFXSprite.enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
BGFXSprite.enabled = true;
|
||||
BGFXSprite.sprite = BGSprites[(int)type - 1].Sprites[0];
|
||||
}
|
||||
}
|
||||
|
||||
public void SetBackgroundColor(int type, int shadowType, Color backgroundColor, Color shadowColor)
|
||||
{
|
||||
BGType = (BackgroundType)type;
|
||||
BGColor = backgroundColor;
|
||||
BGSprite.color = backgroundColor;
|
||||
Shadow = (ShadowType)shadowType;
|
||||
ShadowColor = shadowColor;
|
||||
}
|
||||
|
||||
public void Bop(float beat, float length)
|
||||
{
|
||||
bop.length = length;
|
||||
bop.startBeat = beat;
|
||||
}
|
||||
|
||||
public void Hit2(float beat)
|
||||
{
|
||||
MultiSound.Play(new MultiSound.Sound[] { new MultiSound.Sound("karateman/two", beat + 0.5f) });
|
||||
}
|
||||
|
||||
public void Hit3(float beat, bool alt = false)
|
||||
{
|
||||
var sound = "karateman/three";
|
||||
if (alt) sound += "Alt";
|
||||
MultiSound.Play(new MultiSound.Sound[] { new MultiSound.Sound(sound, beat + 0.5f) });
|
||||
GameObject hit3 = Instantiate(HIT3Ref, this.transform);
|
||||
hit3.transform.GetChild(0).GetChild(1).GetComponent<SpriteRenderer>().sprite = Numbers[2];
|
||||
BeatAction.New(hit3, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat + 0.5f, delegate { hit3.transform.GetChild(0).gameObject.SetActive(true); }),
|
||||
new BeatAction.Action(beat + 4.5f, delegate { Destroy(hit3); })
|
||||
});
|
||||
}
|
||||
|
||||
public void Hit4(float beat)
|
||||
{
|
||||
MultiSound.Play(new MultiSound.Sound[] { new MultiSound.Sound("karateman/four", beat + 0.5f) });
|
||||
GameObject hit4 = Instantiate(HIT3Ref, this.transform);
|
||||
hit4.transform.GetChild(0).GetChild(1).GetComponent<SpriteRenderer>().sprite = Numbers[3];
|
||||
BeatAction.New(hit4, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat + 0.5f, delegate { hit4.transform.GetChild(0).gameObject.SetActive(true); }),
|
||||
new BeatAction.Action(beat + 4.5f, delegate { Destroy(hit4); })
|
||||
});
|
||||
}
|
||||
|
||||
public void Prepare(float beat, float length)
|
||||
{
|
||||
prepare.startBeat = beat;
|
||||
prepare.length = length;
|
||||
}
|
||||
|
||||
public void CreateBomb(Transform parent, Vector2 scale, ref GameObject shadow)
|
||||
{
|
||||
GameObject bomb = Instantiate(Bomb, parent);
|
||||
bomb.SetActive(true);
|
||||
bomb.transform.localScale = scale;
|
||||
shadow.transform.parent = bomb.transform;
|
||||
shadow.transform.SetAsLastSibling();
|
||||
bomb.GetComponent<Bomb>().shadow = shadow;
|
||||
}
|
||||
|
||||
public Color GetShadowColor()
|
||||
{
|
||||
if(Shadow == ShadowType.Custom)
|
||||
{
|
||||
return ShadowColor;
|
||||
}
|
||||
else if(BGType < BackgroundType.Custom)
|
||||
{
|
||||
return ShadowColors[(int)BGType];
|
||||
}
|
||||
mobj.SetActive(true);
|
||||
|
||||
return Color.LerpUnclamped(BGColor, ShadowBlendColor, 0.45f);
|
||||
return mobj;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user