Commit 94759b2c authored by Parsa Rahmaty's avatar Parsa Rahmaty

The nodes drop

parent 0833cbb3
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &2813114490005280564
--- !u!1 &8953703217792660207
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
......@@ -8,50 +8,50 @@ GameObject:
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2813114490005280567}
- component: {fileID: 2813114490005280560}
- component: {fileID: 2813114490005280561}
- component: {fileID: 2813114490005280563}
- component: {fileID: 1469019900825895114}
- component: {fileID: 1239118069581175081}
- component: {fileID: 1551914874522532703}
- component: {fileID: 8953703217792660204}
- component: {fileID: 8953703217792660203}
- component: {fileID: 8953703217792660202}
- component: {fileID: 8953703217792660200}
- component: {fileID: 5704020906800342289}
- component: {fileID: 5366595633663589618}
- component: {fileID: 5675172427026800260}
- component: {fileID: 6082561672976095912}
m_Layer: 9
m_Name: StackNode
m_Name: Stack Node
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &2813114490005280567
--- !u!4 &8953703217792660204
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2813114490005280564}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_GameObject: {fileID: 8953703217792660207}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 10, y: 0.25, z: 10}
m_Children:
- {fileID: 6023010212252713845}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &2813114490005280560
--- !u!33 &8953703217792660203
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2813114490005280564}
m_GameObject: {fileID: 8953703217792660207}
m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &2813114490005280561
--- !u!23 &8953703217792660202
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2813114490005280564}
m_GameObject: {fileID: 8953703217792660207}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
......@@ -84,39 +84,40 @@ MeshRenderer:
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!114 &2813114490005280563
--- !u!114 &8953703217792660200
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2813114490005280564}
m_GameObject: {fileID: 8953703217792660207}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8fa5977b14e9a8141884e3f5569471f6, type: 3}
m_Name:
m_EditorClassIdentifier:
rotationSpeed: 20
--- !u!114 &1469019900825895114
descendTime: 0.2
--- !u!114 &5704020906800342289
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2813114490005280564}
m_GameObject: {fileID: 8953703217792660207}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6af9c6b1989ec8b4985459fa969b2f02, type: 3}
m_Name:
m_EditorClassIdentifier:
health: 1
--- !u!54 &1239118069581175081
--- !u!54 &5366595633663589618
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2813114490005280564}
m_GameObject: {fileID: 8953703217792660207}
serializedVersion: 2
m_Mass: 1
m_Drag: 0
......@@ -126,95 +127,28 @@ Rigidbody:
m_Interpolate: 0
m_Constraints: 90
m_CollisionDetection: 0
--- !u!65 &1551914874522532703
--- !u!65 &5675172427026800260
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2813114490005280564}
m_GameObject: {fileID: 8953703217792660207}
m_Material: {fileID: 13400000, guid: 767de626f0734e747b948a518e3e7918, type: 2}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 1.0000001, y: 2, z: 1.0000002}
m_Center: {x: 0.000000059604645, y: 0, z: -0.00000008940697}
--- !u!1 &5094898662465186538
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6023010212252713845}
- component: {fileID: 1203169594875834969}
- component: {fileID: 5788632802884759433}
m_Layer: 9
m_Name: Sphere
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &6023010212252713845
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5094898662465186538}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.682, y: 0, z: 0}
m_LocalScale: {x: 0.1, y: 4, z: 0.1}
m_Children: []
m_Father: {fileID: 2813114490005280567}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!33 &1203169594875834969
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5094898662465186538}
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &5788632802884759433
MeshRenderer:
--- !u!114 &6082561672976095912
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5094898662465186538}
m_GameObject: {fileID: 8953703217792660207}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e3cf5829d03eb97459c57901b7efff3d, type: 3}
m_Name:
m_EditorClassIdentifier:
fileFormatVersion: 2
guid: 6673329a28c72c44a95878ed59481a5b
guid: 0f97df7b8a1fb3045acf290253e12f29
PrefabImporter:
externalObjects: {}
userData:
......
......@@ -310,7 +310,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 1
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!1 &768744112
GameObject:
......@@ -341,7 +341,7 @@ Transform:
m_Children:
- {fileID: 58095959}
m_Father: {fileID: 0}
m_RootOrder: 4
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &963194225
GameObject:
......@@ -705,7 +705,7 @@ Transform:
- {fileID: 1389915128}
- {fileID: 1384577411}
m_Father: {fileID: 0}
m_RootOrder: 2
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1827272340
MonoBehaviour:
......@@ -725,6 +725,80 @@ MonoBehaviour:
cannonColliders:
- {fileID: 1389915129}
- {fileID: 1384577412}
--- !u!1 &1862334597
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1862334598}
- component: {fileID: 1862334599}
m_Layer: 0
m_Name: Game Events
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1862334598
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1862334597}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1871572808}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1862334599
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1862334597}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 80a56d9f1a6c9ca4ebf74de39ef27528, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &1871572807
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1871572808}
m_Layer: 0
m_Name: Game Manager
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1871572808
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1871572807}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1862334598}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &2140978673
GameObject:
m_ObjectHideFlags: 0
......@@ -769,7 +843,7 @@ Transform:
m_Children:
- {fileID: 963194228}
m_Father: {fileID: 0}
m_RootOrder: 0
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &2140978676
MonoBehaviour:
......@@ -828,7 +902,7 @@ Transform:
m_Children:
- {fileID: 1217394286}
m_Father: {fileID: 0}
m_RootOrder: 3
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &2145345064
MonoBehaviour:
......@@ -915,5 +989,11 @@ PrefabInstance:
propertyPath: m_Name
value: Node Holder
objectReference: {fileID: 0}
- target: {fileID: 4028788090995854451, guid: 90b16e9d09448504aa823b8ca0032ddf,
type: 3}
propertyPath: stackNodeObject
value:
objectReference: {fileID: 5704020906800342289, guid: 0f97df7b8a1fb3045acf290253e12f29,
type: 3}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 90b16e9d09448504aa823b8ca0032ddf, type: 3}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Movable : MonoBehaviour
{
private Vector3 startPosition;
public Vector3 targetPosition { get; private set; }
private float time;
private float timeToReachTarget;
void Start()
{
startPosition = targetPosition = transform.position;
}
void Update()
{
time += Time.deltaTime / timeToReachTarget;
transform.position = Vector3.Lerp(startPosition, targetPosition, time);
}
public void SetDestination(Vector3 destination, float time)
{
this.time = 0;
startPosition = transform.position;
timeToReachTarget = time;
targetPosition = destination;
}
}
fileFormatVersion: 2
guid: e3cf5829d03eb97459c57901b7efff3d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GameEvents : MonoBehaviour
{
[HideInInspector] public static GameEvents instance;
private void Awake()
{
instance = this;
}
public event Action onHitEvent;
public void TriggerOnHitEvent()
{
onHitEvent?.Invoke();
}
}
fileFormatVersion: 2
guid: 80a56d9f1a6c9ca4ebf74de39ef27528
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -4,7 +4,7 @@ using UnityEngine;
public class Stack : MonoBehaviour
{
public int numberOfNodes;
[SerializeField] private int numberOfNodes;
[HideInInspector] public int nodesLeft;
private NodeHolder nodeHolder = null;
......@@ -12,6 +12,12 @@ public class Stack : MonoBehaviour
void Awake()
{
nodeHolder = gameObject.transform.GetChild(0).GetComponent<NodeHolder>();
refreshStack(numberOfNodes);
}
private void refreshStack(int nodeCount)
{
numberOfNodes = nodesLeft = nodeCount;
nodeHolder.MakeNodes(numberOfNodes);
}
......@@ -19,10 +25,16 @@ public class Stack : MonoBehaviour
{
if (collision.gameObject.tag == "Cannonball")
{
GameEvents.instance.TriggerOnHitEvent();
// Destroy the last stack node
Destroy(collision.gameObject);
nodeHolder.RemoveBottomNode();
nodesLeft--;
if(nodesLeft == 0)
{
refreshStack((int)(numberOfNodes * 1.5f));
}
}
}
}
......@@ -5,9 +5,33 @@ using UnityEngine;
public class StackNode : MonoBehaviour
{
[SerializeField] private float rotationSpeed = 10f;
[SerializeField] private float descendTime = 0.2f;
private float descendDistance = 0.5f;
private Movable movable;
private void Awake()
{
movable = gameObject.GetComponent<Movable>();
}
void Start()
{
GameEvents.instance.onHitEvent += Descend;
}
void FixedUpdate()
{
transform.localEulerAngles += new Vector3(0f, rotationSpeed * Time.fixedDeltaTime, 0f);
}
private void Descend()
{
movable.SetDestination(movable.targetPosition - new Vector3(0f, descendDistance, 0f), descendTime);
}
private void OnDestroy()
{
GameEvents.instance.onHitEvent -= Descend;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment