two main cats done

This commit is contained in:
Rapandrasmus 2024-02-08 21:14:57 +01:00
parent 844df979a1
commit de287f10a1
6 changed files with 310 additions and 12 deletions

View file

@ -487,6 +487,37 @@ SpriteRenderer:
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!1 &2010293588750359072
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 9079661336676261219}
m_Layer: 0
m_Name: CatLeftPoint
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &9079661336676261219
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2010293588750359072}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -11.65, y: -1.31, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 2298792418077467027}
m_RootOrder: 8
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &2018572788905518313
GameObject:
m_ObjectHideFlags: 0
@ -776,6 +807,8 @@ Transform:
- {fileID: 6081244242579349435}
- {fileID: 1786682412932371778}
- {fileID: 615325631333663386}
- {fileID: 3502128156805934089}
- {fileID: 9079661336676261219}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -799,6 +832,7 @@ MonoBehaviour:
_hugeObjectPrefab: {fileID: -3577666667379746924, guid: d971a00c5581d884b9658910cac762ad, type: 3}
_cutObjectHolder: {fileID: 1521262164748977952}
_catRight: {fileID: 2259150297677717709}
_catRightMove: {fileID: 6490317461649069614}
_catRightObjectsSmall:
- {fileID: 8919816004362866721}
- {fileID: 8283341335121478951}
@ -811,6 +845,7 @@ MonoBehaviour:
- {fileID: 8599624938353215766}
- {fileID: 4673486003957519203}
_catLeft: {fileID: 3984350684958007215}
_catLeftMove: {fileID: 8215517585804257612}
_catLeftObjectsSmall:
- {fileID: 6041809295034117955}
- {fileID: 6549654297430473285}
@ -824,6 +859,7 @@ MonoBehaviour:
- {fileID: 7551078816062909441}
_catAnimationOffsetStart: -0.5
_catAnimationOffsetEnd: 0.5
_catMoveLength: 0.5
--- !u!1 &3527631078867808426
GameObject:
m_ObjectHideFlags: 0
@ -1997,6 +2033,37 @@ SpriteRenderer:
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!1 &6190119296193400522
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3502128156805934089}
m_Layer: 0
m_Name: CatRightPoint
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &3502128156805934089
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6190119296193400522}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 12.07, y: -1.315, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 2298792418077467027}
m_RootOrder: 7
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &7044844882782499427
GameObject:
m_ObjectHideFlags: 0
@ -2792,6 +2859,14 @@ PrefabInstance:
propertyPath: m_FlipX
value: 1
objectReference: {fileID: 0}
- target: {fileID: 8767186862898821743, guid: e2e08f4bea037a14da41e5490ce6d393, type: 3}
propertyPath: _otherPoint
value:
objectReference: {fileID: 9079661336676261219}
- target: {fileID: 8767186862898821743, guid: e2e08f4bea037a14da41e5490ce6d393, type: 3}
propertyPath: _startAtOther
value: 1
objectReference: {fileID: 0}
- target: {fileID: 8843339730488359881, guid: e2e08f4bea037a14da41e5490ce6d393, type: 3}
propertyPath: m_FlipX
value: 1
@ -2843,6 +2918,17 @@ GameObject:
m_CorrespondingSourceObject: {fileID: 7363258296528702430, guid: e2e08f4bea037a14da41e5490ce6d393, type: 3}
m_PrefabInstance: {fileID: 839973794089554723}
m_PrefabAsset: {fileID: 0}
--- !u!114 &8215517585804257612 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 8767186862898821743, guid: e2e08f4bea037a14da41e5490ce6d393, type: 3}
m_PrefabInstance: {fileID: 839973794089554723}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9ae63fcd437df0c4c91e553fb159986c, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &8612418700374271145 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 8947907653433374602, guid: e2e08f4bea037a14da41e5490ce6d393, type: 3}
@ -2935,6 +3021,10 @@ PrefabInstance:
propertyPath: m_FlipY
value: 1
objectReference: {fileID: 0}
- target: {fileID: 8767186862898821743, guid: e2e08f4bea037a14da41e5490ce6d393, type: 3}
propertyPath: _otherPoint
value:
objectReference: {fileID: 3502128156805934089}
- target: {fileID: 8855434573853191878, guid: e2e08f4bea037a14da41e5490ce6d393, type: 3}
propertyPath: m_LocalPosition.x
value: 4.33
@ -2985,6 +3075,17 @@ GameObject:
m_CorrespondingSourceObject: {fileID: 7363258296528702430, guid: e2e08f4bea037a14da41e5490ce6d393, type: 3}
m_PrefabInstance: {fileID: 2574215485148474433}
m_PrefabAsset: {fileID: 0}
--- !u!114 &6490317461649069614 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 8767186862898821743, guid: e2e08f4bea037a14da41e5490ce6d393, type: 3}
m_PrefabInstance: {fileID: 2574215485148474433}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9ae63fcd437df0c4c91e553fb159986c, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &6887175643397659595 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 8947907653433374602, guid: e2e08f4bea037a14da41e5490ce6d393, type: 3}

View file

@ -1649,6 +1649,7 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 6903108778393898136}
- component: {fileID: 8767186862898821743}
m_Layer: 0
m_Name: Cat
m_TagString: Untagged
@ -1672,6 +1673,19 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &8767186862898821743
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7537329938738626932}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9ae63fcd437df0c4c91e553fb159986c, type: 3}
m_Name:
m_EditorClassIdentifier:
_otherPoint: {fileID: 0}
--- !u!1 &7816188901787332666
GameObject:
m_ObjectHideFlags: 0

View file

@ -0,0 +1,51 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using HeavenStudio.Util;
namespace HeavenStudio.Games.Scripts_LumBEARjack
{
public class LBJCatMove : MonoBehaviour
{
[Header("Components")]
[SerializeField] private Transform _otherPoint;
[Header("Properties")]
[SerializeField] private bool _startAtOther;
private Vector3 _thisPosition;
private Coroutine _currentMove;
private void Awake()
{
_thisPosition = transform.position;
if (_startAtOther) transform.position = _otherPoint.position;
}
public void Move(double beat, double length, bool inToScene)
{
if (_currentMove != null) StopCoroutine(_currentMove);
_currentMove = StartCoroutine(MoveCo(beat, length, inToScene));
}
private IEnumerator MoveCo(double beat, double length, bool inToScene)
{
if (length <= 0)
{
transform.position = inToScene ? _thisPosition : _otherPoint.position;
yield break;
}
float normalized = Conductor.instance.GetPositionFromBeat(beat, length, false);
while (normalized <= 1f)
{
normalized = Conductor.instance.GetPositionFromBeat(beat, length);
Vector3 newPos = Vector3.Lerp(inToScene ? _otherPoint.position : _thisPosition, inToScene ? _thisPosition : _otherPoint.position, normalized);
transform.position = newPos;
yield return null;
}
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9ae63fcd437df0c4c91e553fb159986c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -103,7 +103,8 @@ namespace HeavenStudio.Games.Loaders
defaultLength = 0.5f,
parameters = new()
{
new("main", LumBEARjack.MainCatChoice.Right, "Main Cats")
new("main", LumBEARjack.MainCatChoice.Right, "Main Cats"),
new("instant", false, "Instant")
}
},
new("sigh", "Rest")
@ -259,11 +260,13 @@ namespace HeavenStudio.Games
[SerializeField] private Transform _cutObjectHolder;
[SerializeField] private Animator _catRight;
[SerializeField] private LBJCatMove _catRightMove;
[SerializeField] private GameObject[] _catRightObjectsSmall = new GameObject[4];
[SerializeField] private GameObject[] _catRightObjectsBig = new GameObject[1];
[SerializeField] private GameObject[] _catRightObjectsHuge = new GameObject[3];
[SerializeField] private Animator _catLeft;
[SerializeField] private LBJCatMove _catLeftMove;
[SerializeField] private GameObject[] _catLeftObjectsSmall = new GameObject[4];
[SerializeField] private GameObject[] _catLeftObjectsBig = new GameObject[1];
[SerializeField] private GameObject[] _catLeftObjectsHuge = new GameObject[3];
@ -271,9 +274,12 @@ namespace HeavenStudio.Games
[Header("Parameters")]
[SerializeField] private double _catAnimationOffsetStart = -0.5;
[SerializeField] private double _catAnimationOffsetEnd = 0.5;
[SerializeField] private double _catMoveLength = 0.5;
private List<double> _bearNoBopBeats = new();
private Dictionary<double, CatPutChoice> _catPuts = new();
private Dictionary<double, MainCatChoice> _mainCatPresences = new();
private MainCatChoice _startMainCat = MainCatChoice.Right;
public static LumBEARjack instance;
@ -340,7 +346,7 @@ namespace HeavenStudio.Games
switch (cat)
{
case CatPutChoice.Alternate:
bool right = true; // proper start to be implemented
bool right = _startMainCat != MainCatChoice.Left;
bool first = true;
foreach (var e in _catPuts)
@ -350,24 +356,22 @@ namespace HeavenStudio.Games
{
case CatPutChoice.Alternate:
if (!first) right = !right;
if (CatPresenceAtBeat(beat) != MainCatChoice.Both) right = CatPresenceAtBeat(beat) != MainCatChoice.Left;
break;
case CatPutChoice.Right:
right = true;
right = CatPresenceAtBeat(beat) != MainCatChoice.Left;
break;
case CatPutChoice.Left:
right = false;
right = CatPresenceAtBeat(beat) == MainCatChoice.Right;
break;
}
first = false;
}
return right;
// Add checks for if cat is in
case CatPutChoice.Left:
return false;
return CatPresenceAtBeat(beat) == MainCatChoice.Right;
default:
return true;
return CatPresenceAtBeat(beat) != MainCatChoice.Left;
}
}
@ -377,6 +381,7 @@ namespace HeavenStudio.Games
public override void OnGameSwitch(double beat)
{
HandleCatPresence(beat);
PersistObjects(beat);
HandleBops(beat);
HandleCatAnimation(beat);
@ -384,11 +389,97 @@ namespace HeavenStudio.Games
public override void OnPlay(double beat)
{
HandleCatPresence(beat);
PersistObjects(beat);
HandleBops(beat);
HandleCatAnimation(beat);
}
private void HandleCatPresence(double beat)
{
List<RiqEntity> allPresences = EventCaller.GetAllInGameManagerList("lumbearjack", new string[] { "cats" });
foreach (var e in allPresences)
{
if (_mainCatPresences.ContainsKey(e.beat)) continue;
_mainCatPresences.Add(e.beat, (MainCatChoice)e["main"]);
}
_startMainCat = CatPresenceBeforeBeat(beat);
switch (_startMainCat)
{
case MainCatChoice.Right:
ActivateCatVisualPresence(beat, true, true, true);
ActivateCatVisualPresence(beat, false, false, true);
break;
case MainCatChoice.Left:
ActivateCatVisualPresence(beat, false, true, true);
ActivateCatVisualPresence(beat, true, false, true);
break;
case MainCatChoice.Both:
ActivateCatVisualPresence(beat, true, true, true);
ActivateCatVisualPresence(beat, true, false, true);
break;
}
var allPresencesAfterBeat = allPresences.FindAll(x => x.beat >= beat);
foreach (var e in allPresencesAfterBeat)
{
double eventBeat = e.beat;
bool instant = e["instant"];
MainCatChoice beforeCats = CatPresenceBeforeBeat(e.beat);
MainCatChoice atCats = (MainCatChoice)e["main"];
if (beforeCats == atCats) continue;
switch (atCats)
{
case MainCatChoice.Right:
BeatAction.New(this, new()
{
new(e.beat, delegate
{
if (beforeCats == MainCatChoice.Both)
{
ActivateCatVisualPresence(eventBeat, true, true, true);
ActivateCatVisualPresence(eventBeat, false, false, instant);
return;
}
ActivateCatVisualPresence(eventBeat, true, true, instant);
ActivateCatVisualPresence(eventBeat, false, false, instant);
})
});
break;
case MainCatChoice.Left:
BeatAction.New(this, new()
{
new(e.beat, delegate
{
if (beforeCats == MainCatChoice.Both)
{
ActivateCatVisualPresence(eventBeat, false, true, instant);
ActivateCatVisualPresence(eventBeat, true, false, true);
return;
}
ActivateCatVisualPresence(eventBeat, false, true, instant);
ActivateCatVisualPresence(eventBeat, true, false, instant);
})
});
break;
case MainCatChoice.Both:
BeatAction.New(this, new()
{
new(e.beat, delegate
{
ActivateCatVisualPresence(eventBeat, true, true, (beforeCats == MainCatChoice.Right) ? true : instant);
ActivateCatVisualPresence(eventBeat, true, false, (beforeCats == MainCatChoice.Left) ? true : instant);
})
});
break;
}
}
}
private void PersistObjects(double beat)
{
List<RiqEntity> allEligibleEvents = EventCaller.GetAllInGameManagerList("lumbearjack", new string[] { "small", "big", "huge", "smallS", "bigS", "hugeS" }).FindAll(x => x.beat < beat && x.beat + x.length > beat);
@ -468,7 +559,7 @@ namespace HeavenStudio.Games
double nextGameSwitchBeat = double.MaxValue;
if (nextGameSwitch != null) nextGameSwitchBeat = nextGameSwitch.beat;
bool catRight = true; // again properise
bool catRight = _startMainCat != MainCatChoice.Left;
bool first = true;
foreach (var e in allEvents)
@ -491,12 +582,13 @@ namespace HeavenStudio.Games
{
case CatPutChoice.Alternate:
if (!first) catRight = !catRight;
if (CatPresenceAtBeat(e.beat) != MainCatChoice.Both) catRight = CatPresenceAtBeat(e.beat) != MainCatChoice.Left;
break;
case CatPutChoice.Left:
catRight = false;
catRight = CatPresenceAtBeat(e.beat) == MainCatChoice.Right;
break;
default:
catRight = true;
catRight = CatPresenceAtBeat(e.beat) != MainCatChoice.Left;
break;
}
@ -774,6 +866,34 @@ namespace HeavenStudio.Games
}
}
private void ActivateCatVisualPresence(double beat, bool inToScene, bool right, bool instant = false)
{
LBJCatMove move = right ? _catRightMove : _catLeftMove;
move.Move(beat, instant ? 0 : _catMoveLength, inToScene);
}
private MainCatChoice CatPresenceAtBeat(double beat)
{
MainCatChoice cat = MainCatChoice.Right;
foreach (var p in _mainCatPresences)
{
if (p.Key > beat) break;
cat = p.Value;
}
return cat;
}
private MainCatChoice CatPresenceBeforeBeat(double beat)
{
MainCatChoice cat = MainCatChoice.Right;
foreach (var p in _mainCatPresences)
{
if (p.Key >= beat) break;
cat = p.Value;
}
return cat;
}
#endregion
#region Misc

View file

@ -292,5 +292,6 @@ MonoBehaviour:
- Assets/Scripts/Games/LumBEARjack/LBJSmallObject.cs
- Assets/Scripts/Games/LumBEARjack/LBJBear.cs
- Assets/Scripts/Games/LumBEARjack/LBJHugeObject.cs
- Assets/Scripts/Games/LumBEARjack/LBJCatMove.cs
PathsToSkipImportEvent: []
PathsToIgnoreOverwriteSettingOnAttribute: []