Populate minigame with obstacles and monster spawns (#5)
- Simulated "fake" physics and collisions - Object pooling for tiles, obstacles and monster spawns - Base monster scoring with proximity triggers and depth multiplier Co-authored-by: AlexanderT <alexander@foolhardyhorizons.com> Co-authored-by: Michal Pikulski <michal.a.pikulski@gmail.com> Reviewed-on: #5
This commit is contained in:
8
Assets/Scripts/DamianExperiments/Animations.meta
Normal file
8
Assets/Scripts/DamianExperiments/Animations.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c6fd0683cee159c4f899a794af80c7ce
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,84 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!74 &7400000
|
||||
AnimationClip:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: LawnMowerMowing
|
||||
serializedVersion: 7
|
||||
m_Legacy: 0
|
||||
m_Compressed: 0
|
||||
m_UseHighQualityCurve: 1
|
||||
m_RotationCurves: []
|
||||
m_CompressedRotationCurves: []
|
||||
m_EulerCurves: []
|
||||
m_PositionCurves: []
|
||||
m_ScaleCurves: []
|
||||
m_FloatCurves: []
|
||||
m_PPtrCurves:
|
||||
- serializedVersion: 2
|
||||
curve:
|
||||
- time: 0
|
||||
value: {fileID: -4444670910754578914, guid: 464f70d7647a22a4aa688ffc2b6654cc, type: 3}
|
||||
- time: 0.18333334
|
||||
value: {fileID: 5233908553689211412, guid: 464f70d7647a22a4aa688ffc2b6654cc, type: 3}
|
||||
- time: 0.33333334
|
||||
value: {fileID: 7052581180763600252, guid: 464f70d7647a22a4aa688ffc2b6654cc, type: 3}
|
||||
- time: 0.48333332
|
||||
value: {fileID: 4839952163610979709, guid: 464f70d7647a22a4aa688ffc2b6654cc, type: 3}
|
||||
- time: 0.6666667
|
||||
value: {fileID: -4444670910754578914, guid: 464f70d7647a22a4aa688ffc2b6654cc, type: 3}
|
||||
attribute: m_Sprite
|
||||
path:
|
||||
classID: 212
|
||||
script: {fileID: 0}
|
||||
flags: 2
|
||||
m_SampleRate: 60
|
||||
m_WrapMode: 0
|
||||
m_Bounds:
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
m_Extent: {x: 0, y: 0, z: 0}
|
||||
m_ClipBindingConstant:
|
||||
genericBindings:
|
||||
- serializedVersion: 2
|
||||
path: 0
|
||||
attribute: 0
|
||||
script: {fileID: 0}
|
||||
typeID: 212
|
||||
customType: 23
|
||||
isPPtrCurve: 1
|
||||
isIntCurve: 0
|
||||
isSerializeReferenceCurve: 0
|
||||
pptrCurveMapping:
|
||||
- {fileID: -4444670910754578914, guid: 464f70d7647a22a4aa688ffc2b6654cc, type: 3}
|
||||
- {fileID: 5233908553689211412, guid: 464f70d7647a22a4aa688ffc2b6654cc, type: 3}
|
||||
- {fileID: 7052581180763600252, guid: 464f70d7647a22a4aa688ffc2b6654cc, type: 3}
|
||||
- {fileID: 4839952163610979709, guid: 464f70d7647a22a4aa688ffc2b6654cc, type: 3}
|
||||
- {fileID: -4444670910754578914, guid: 464f70d7647a22a4aa688ffc2b6654cc, type: 3}
|
||||
m_AnimationClipSettings:
|
||||
serializedVersion: 2
|
||||
m_AdditiveReferencePoseClip: {fileID: 0}
|
||||
m_AdditiveReferencePoseTime: 0
|
||||
m_StartTime: 0
|
||||
m_StopTime: 0.68333334
|
||||
m_OrientationOffsetY: 0
|
||||
m_Level: 0
|
||||
m_CycleOffset: 0
|
||||
m_HasAdditiveReferencePose: 0
|
||||
m_LoopTime: 1
|
||||
m_LoopBlend: 0
|
||||
m_LoopBlendOrientation: 0
|
||||
m_LoopBlendPositionY: 0
|
||||
m_LoopBlendPositionXZ: 0
|
||||
m_KeepOriginalOrientation: 0
|
||||
m_KeepOriginalPositionY: 1
|
||||
m_KeepOriginalPositionXZ: 0
|
||||
m_HeightFromFeet: 0
|
||||
m_Mirror: 0
|
||||
m_EditorCurves: []
|
||||
m_EulerEditorCurves: []
|
||||
m_HasGenericRootTransform: 0
|
||||
m_HasMotionFloatCurves: 0
|
||||
m_Events: []
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 083a3166fef9168469713bd00eee5308
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 7400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,72 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1102 &-9094513822423650161
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: LawnMowerMowing
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions: []
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 50, y: 50, z: 0}
|
||||
m_IKOnFeet: 0
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: 7400000, guid: 083a3166fef9168469713bd00eee5308, type: 2}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1107 &-2429364330681070164
|
||||
AnimatorStateMachine:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Base Layer
|
||||
m_ChildStates:
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: -9094513822423650161}
|
||||
m_Position: {x: 30, y: 240, z: 0}
|
||||
m_ChildStateMachines: []
|
||||
m_AnyStateTransitions: []
|
||||
m_EntryTransitions: []
|
||||
m_StateMachineTransitions: {}
|
||||
m_StateMachineBehaviours: []
|
||||
m_AnyStatePosition: {x: 50, y: 20, z: 0}
|
||||
m_EntryPosition: {x: 50, y: 120, z: 0}
|
||||
m_ExitPosition: {x: 800, y: 120, z: 0}
|
||||
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
|
||||
m_DefaultState: {fileID: -9094513822423650161}
|
||||
--- !u!91 &9100000
|
||||
AnimatorController:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: _Lawnmower_Anim
|
||||
serializedVersion: 5
|
||||
m_AnimatorParameters: []
|
||||
m_AnimatorLayers:
|
||||
- serializedVersion: 5
|
||||
m_Name: Base Layer
|
||||
m_StateMachine: {fileID: -2429364330681070164}
|
||||
m_Mask: {fileID: 0}
|
||||
m_Motions: []
|
||||
m_Behaviours: []
|
||||
m_BlendingMode: 0
|
||||
m_SyncedLayerIndex: -1
|
||||
m_DefaultWeight: 0
|
||||
m_IKPass: 0
|
||||
m_SyncedLayerAffectsTiming: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: be48400cf83222c49ba9d7b34ab1d9e4
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 9100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
29
Assets/Scripts/DamianExperiments/LawnMowerBehaviour.cs
Normal file
29
Assets/Scripts/DamianExperiments/LawnMowerBehaviour.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using UnityEngine;
|
||||
using Pixelplacement;
|
||||
|
||||
public class LawnMowerBehaviour : MonoBehaviour
|
||||
{
|
||||
private StateMachine stateMachineRef;
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
stateMachineRef = GetComponent<StateMachine>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
public void mowerTouched()
|
||||
{
|
||||
Debug.Log("Mower Touched");
|
||||
}
|
||||
|
||||
public void stateSwitch(string StateName)
|
||||
{
|
||||
Debug.Log("State Switch to: " + StateName);
|
||||
stateMachineRef.ChangeState(StateName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9fba2c868971b20439aaea06a939d8e7
|
||||
69
Assets/Scripts/DamianExperiments/LawnMowerChaseBehaviour.cs
Normal file
69
Assets/Scripts/DamianExperiments/LawnMowerChaseBehaviour.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
using UnityEngine;
|
||||
using Pixelplacement;
|
||||
|
||||
public class LawnMowerChaseBehaviour : MonoBehaviour
|
||||
{
|
||||
public Spline ChaseSpline;
|
||||
public Transform LawnMowerObject;
|
||||
public float chaseDuration;
|
||||
public float chaseDelay;
|
||||
|
||||
private Vector3 _originalScale;
|
||||
private bool _facingRight = true;
|
||||
private bool _movingForward = true;
|
||||
private float _lastPercentage = 0f;
|
||||
private const float AnchorThreshold = 0.1f; // Tolerance for anchor detection
|
||||
|
||||
void Start()
|
||||
{
|
||||
_originalScale = LawnMowerObject.localScale;
|
||||
|
||||
Tween.Spline(
|
||||
ChaseSpline,
|
||||
LawnMowerObject,
|
||||
0,
|
||||
1,
|
||||
false,
|
||||
chaseDuration,
|
||||
chaseDelay,
|
||||
Tween.EaseInOut,
|
||||
Tween.LoopType.PingPong,
|
||||
onComplete: OnTweenComplete
|
||||
);
|
||||
}
|
||||
|
||||
private void OnTweenComplete()
|
||||
{
|
||||
_movingForward = !_movingForward;
|
||||
Flip(_movingForward);
|
||||
}
|
||||
|
||||
private void OnTweenUpdate()
|
||||
{
|
||||
// Find the current percentage along the spline
|
||||
float percentage = ChaseSpline.ClosestPoint(LawnMowerObject.position);
|
||||
|
||||
// Detect anchor arrival and flip accordingly
|
||||
if (_facingRight && percentage >= 1f - AnchorThreshold)
|
||||
{
|
||||
Flip(false); // Face left at end anchor
|
||||
_facingRight = false;
|
||||
}
|
||||
else if (!_facingRight && percentage <= AnchorThreshold)
|
||||
{
|
||||
Flip(true); // Face right at start anchor
|
||||
_facingRight = true;
|
||||
}
|
||||
|
||||
_lastPercentage = percentage;
|
||||
}
|
||||
|
||||
private void Flip(bool faceRight)
|
||||
{
|
||||
var scale = _originalScale;
|
||||
scale.x = Mathf.Abs(scale.x) * (faceRight ? 1 : -1);
|
||||
LawnMowerObject.localScale = scale;
|
||||
}
|
||||
|
||||
void Update() { }
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 426d4511f8eb64747ab44f61973dcf2e
|
||||
Reference in New Issue
Block a user