Added example entity design (coins), improved files hierarchy
8
InsAsterix/Assets/Prefabs.meta
Normal file
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b0f2140bc003b9faaa7201a227c9db1f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,50 +1,5 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &2512332812932904938
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 5484317930001519873}
|
||||
- component: {fileID: 7733602296147980279}
|
||||
m_Layer: 0
|
||||
m_Name: Grid
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &5484317930001519873
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2512332812932904938}
|
||||
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_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 5134727206501309496}
|
||||
m_Father: {fileID: 8789135867976704976}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!156049354 &7733602296147980279
|
||||
Grid:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2512332812932904938}
|
||||
m_Enabled: 1
|
||||
m_CellSize: {x: 1, y: 1, z: 0}
|
||||
m_CellGap: {x: 0, y: 0, z: 0}
|
||||
m_CellLayout: 0
|
||||
m_CellSwizzle: 0
|
||||
--- !u!1 &5551514546915677804
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -56,6 +11,7 @@ GameObject:
|
|||
- component: {fileID: 5134727206501309496}
|
||||
- component: {fileID: 6923061844279075721}
|
||||
- component: {fileID: 1512619329986204543}
|
||||
- component: {fileID: 4722249481167776362}
|
||||
m_Layer: 0
|
||||
m_Name: Tilemap
|
||||
m_TagString: Untagged
|
||||
|
@ -71,11 +27,11 @@ Transform:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5551514546915677804}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalPosition: {x: 0.5, y: 0.5, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 5484317930001519873}
|
||||
m_Father: {fileID: 8789135867976704976}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1839735485 &6923061844279075721
|
||||
|
@ -265,6 +221,32 @@ TilemapRenderer:
|
|||
m_Mode: 0
|
||||
m_DetectChunkCullingBounds: 0
|
||||
m_MaskInteraction: 0
|
||||
--- !u!61 &4722249481167776362
|
||||
BoxCollider2D:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5551514546915677804}
|
||||
m_Enabled: 1
|
||||
m_Density: 1
|
||||
m_Material: {fileID: 0}
|
||||
m_IsTrigger: 0
|
||||
m_UsedByEffector: 0
|
||||
m_UsedByComposite: 0
|
||||
m_Offset: {x: -0.5, y: 0.5}
|
||||
m_SpriteTilingProperty:
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
pivot: {x: 0, y: 0}
|
||||
oldSize: {x: 0, y: 0}
|
||||
newSize: {x: 0, y: 0}
|
||||
adaptiveTilingThreshold: 0
|
||||
drawMode: 0
|
||||
adaptiveTiling: 0
|
||||
m_AutoTiling: 0
|
||||
serializedVersion: 2
|
||||
m_Size: {x: 1, y: 1}
|
||||
m_EdgeRadius: 0
|
||||
--- !u!1 &5603740947797344480
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -295,7 +277,7 @@ Transform:
|
|||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 1
|
||||
m_Children:
|
||||
- {fileID: 5484317930001519873}
|
||||
- {fileID: 5134727206501309496}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
|
@ -10,8 +10,9 @@ GameObject:
|
|||
m_Component:
|
||||
- component: {fileID: 6214812198674791343}
|
||||
- component: {fileID: 934744677166207459}
|
||||
- component: {fileID: 4219850689256547812}
|
||||
m_Layer: 0
|
||||
m_Name: EntitySpawner
|
||||
m_Name: CoinEntitySpawner
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
|
@ -44,5 +45,19 @@ MonoBehaviour:
|
|||
m_Script: {fileID: 11500000, guid: 1413d9a11f269e28fbcc43187848b3b0, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
EntityToSpawn: {fileID: 5603740947797344480, guid: b650f7033d7b89a36943a33d4fd8730f, type: 3}
|
||||
SpawnPositions: []
|
||||
entityToSpawn: {fileID: 5603740947797344480, guid: b650f7033d7b89a36943a33d4fd8730f, type: 3}
|
||||
nbEntityInstances: 5
|
||||
spawnPositions: []
|
||||
grid: {fileID: 0}
|
||||
--- !u!114 &4219850689256547812
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1261290536216742845}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: aa43d80b783e4f33b93f8dd67670ec4c, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
|
@ -60,6 +60,7 @@ MonoBehaviour:
|
|||
m_Script: {fileID: 11500000, guid: 0885fa9c26ef053c8922d194fabd8c23, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
coinCount: {fileID: 703382666348530784, guid: df2d878b21a1b945784f028101dcc92a, type: 3}
|
||||
--- !u!95 &4923611131825859147
|
||||
Animator:
|
||||
serializedVersion: 5
|
|
@ -1802,6 +1802,7 @@ RectTransform:
|
|||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 1806323321}
|
||||
- {fileID: 445907187}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 5
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
|
@ -2095,10 +2096,18 @@ PrefabInstance:
|
|||
propertyPath: Tilemap
|
||||
value:
|
||||
objectReference: {fileID: 1359661565}
|
||||
- target: {fileID: 934744677166207459, guid: e8524a4699d5e0d378b5b994c0a36044, type: 3}
|
||||
propertyPath: tilemap
|
||||
value:
|
||||
objectReference: {fileID: 1359661565}
|
||||
- target: {fileID: 934744677166207459, guid: e8524a4699d5e0d378b5b994c0a36044, type: 3}
|
||||
propertyPath: EntityToSpawn
|
||||
value:
|
||||
objectReference: {fileID: 5603740947797344480, guid: b650f7033d7b89a36943a33d4fd8730f, type: 3}
|
||||
- target: {fileID: 934744677166207459, guid: e8524a4699d5e0d378b5b994c0a36044, type: 3}
|
||||
propertyPath: nbEntityInstances
|
||||
value: 2
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 934744677166207459, guid: e8524a4699d5e0d378b5b994c0a36044, type: 3}
|
||||
propertyPath: SpawnPositions.Array.size
|
||||
value: 5
|
||||
|
@ -2189,8 +2198,12 @@ PrefabInstance:
|
|||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1261290536216742845, guid: e8524a4699d5e0d378b5b994c0a36044, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: EntitySpawner
|
||||
value: CoinEntitySpawner
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4219850689256547812, guid: e8524a4699d5e0d378b5b994c0a36044, type: 3}
|
||||
propertyPath: coinCount
|
||||
value:
|
||||
objectReference: {fileID: 445907186}
|
||||
- target: {fileID: 6214812198674791343, guid: e8524a4699d5e0d378b5b994c0a36044, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 2
|
||||
|
@ -2237,6 +2250,141 @@ PrefabInstance:
|
|||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: e8524a4699d5e0d378b5b994c0a36044, type: 3}
|
||||
--- !u!1 &445907186
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 445907187}
|
||||
- component: {fileID: 445907189}
|
||||
- component: {fileID: 445907188}
|
||||
m_Layer: 5
|
||||
m_Name: CoinCount
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &445907187
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 445907186}
|
||||
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_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 239918070}
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 184.70001, y: -36.619995}
|
||||
m_SizeDelta: {x: 200, y: 50}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &445907188
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 445907186}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_text: 0
|
||||
m_isRightToLeft: 0
|
||||
m_fontAsset: {fileID: 11400000, guid: a035a7cb8abf3b7408fef0a176af3856, type: 2}
|
||||
m_sharedMaterial: {fileID: 5739899068905773544, guid: a035a7cb8abf3b7408fef0a176af3856, type: 2}
|
||||
m_fontSharedMaterials: []
|
||||
m_fontMaterial: {fileID: 0}
|
||||
m_fontMaterials: []
|
||||
m_fontColor32:
|
||||
serializedVersion: 2
|
||||
rgba: 4294967295
|
||||
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_enableVertexGradient: 0
|
||||
m_colorMode: 3
|
||||
m_fontColorGradient:
|
||||
topLeft: {r: 1, g: 1, b: 1, a: 1}
|
||||
topRight: {r: 1, g: 1, b: 1, a: 1}
|
||||
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
|
||||
bottomRight: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_fontColorGradientPreset: {fileID: 0}
|
||||
m_spriteAsset: {fileID: 0}
|
||||
m_tintAllSprites: 0
|
||||
m_StyleSheet: {fileID: 0}
|
||||
m_TextStyleHashCode: -1183493901
|
||||
m_overrideHtmlColors: 0
|
||||
m_faceColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4294967295
|
||||
m_fontSize: 36
|
||||
m_fontSizeBase: 36
|
||||
m_fontWeight: 400
|
||||
m_enableAutoSizing: 0
|
||||
m_fontSizeMin: 18
|
||||
m_fontSizeMax: 72
|
||||
m_fontStyle: 0
|
||||
m_HorizontalAlignment: 1
|
||||
m_VerticalAlignment: 256
|
||||
m_textAlignment: 65535
|
||||
m_characterSpacing: 0
|
||||
m_wordSpacing: 0
|
||||
m_lineSpacing: 0
|
||||
m_lineSpacingMax: 0
|
||||
m_paragraphSpacing: 0
|
||||
m_charWidthMaxAdj: 0
|
||||
m_enableWordWrapping: 1
|
||||
m_wordWrappingRatios: 0.4
|
||||
m_overflowMode: 0
|
||||
m_linkedTextComponent: {fileID: 0}
|
||||
parentLinkedComponent: {fileID: 0}
|
||||
m_enableKerning: 1
|
||||
m_enableExtraPadding: 0
|
||||
checkPaddingRequired: 0
|
||||
m_isRichText: 1
|
||||
m_parseCtrlCharacters: 1
|
||||
m_isOrthographic: 1
|
||||
m_isCullingEnabled: 0
|
||||
m_horizontalMapping: 0
|
||||
m_verticalMapping: 0
|
||||
m_uvLineOffset: 0
|
||||
m_geometrySortingOrder: 0
|
||||
m_IsTextObjectScaleStatic: 0
|
||||
m_VertexBufferAutoSizeReduction: 0
|
||||
m_useMaxVisibleDescender: 1
|
||||
m_pageToDisplay: 1
|
||||
m_margin: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_isUsingLegacyAnimationComponent: 0
|
||||
m_isVolumetricText: 0
|
||||
m_hasFontAssetChanged: 0
|
||||
m_baseMaterial: {fileID: 0}
|
||||
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
|
||||
--- !u!222 &445907189
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 445907186}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!1 &519420028
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -3004,7 +3152,7 @@ RectTransform:
|
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 100.20001, y: -37.5}
|
||||
m_AnchoredPosition: {x: 99.4, y: -42.6}
|
||||
m_SizeDelta: {x: 170.01404, y: 51.998993}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &1806323322
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Despawn : MonoBehaviour
|
||||
{
|
||||
public delegate void entityDespawnDelegate() ;
|
||||
public entityDespawnDelegate entityDespawnEvent ;
|
||||
|
||||
public void InvokeDespawnEvent() {
|
||||
entityDespawnEvent?.Invoke() ;
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Dummy : MonoBehaviour
|
||||
{
|
||||
Despawn despawn ;
|
||||
void Start()
|
||||
{
|
||||
despawn = gameObject.GetComponent<Despawn>() ;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (Input.GetKey(KeyCode.Space)) {
|
||||
despawn.InvokeDespawnEvent() ;
|
||||
Destroy(gameObject) ;
|
||||
}
|
||||
}
|
||||
}
|
8
InsAsterix/Assets/Scripts/Entities.meta
Normal file
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d88ac8bf6ecfe9408842a8d83ca8d0fd
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
30
InsAsterix/Assets/Scripts/Entities/CoinEntitySpawner.cs
Normal file
|
@ -0,0 +1,30 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
public class CoinEntitySpawner : MonoBehaviour
|
||||
{
|
||||
[FormerlySerializedAs("Coin Count")] public GameObject coinCount ;
|
||||
private TextMeshProUGUI _coinCountTextMeshPro;
|
||||
private EntitySpawner _entitySpawner;
|
||||
void Start()
|
||||
{
|
||||
_entitySpawner = gameObject.GetComponent<EntitySpawner>();
|
||||
_entitySpawner.EntitySpawnEvent += OnCoinSpawn;
|
||||
_coinCountTextMeshPro = coinCount.transform.GetComponent<TextMeshProUGUI>();
|
||||
}
|
||||
|
||||
void OnCoinSpawn(Despawn d)
|
||||
{
|
||||
d.EntityDespawnEvent += OnCoinDespawn;
|
||||
}
|
||||
|
||||
void OnCoinDespawn(Despawn d)
|
||||
{
|
||||
// Incrementing UI coin count
|
||||
_coinCountTextMeshPro.text = (int.Parse(_coinCountTextMeshPro.text) + 1).ToString();
|
||||
}
|
||||
|
||||
}
|
11
InsAsterix/Assets/Scripts/Entities/CoinEntitySpawner.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: aa43d80b783e4f33b93f8dd67670ec4c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
25
InsAsterix/Assets/Scripts/Entities/Despawn.cs
Normal file
|
@ -0,0 +1,25 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Despawn : MonoBehaviour
|
||||
{
|
||||
public delegate void EntityDespawnDelegate(Despawn d) ;
|
||||
public EntityDespawnDelegate EntityDespawnEvent ;
|
||||
|
||||
private int _entityIndex;
|
||||
|
||||
public void SetEntityIndex(int index)
|
||||
{
|
||||
_entityIndex = index;
|
||||
}
|
||||
|
||||
public int GetEntityIndex()
|
||||
{
|
||||
return _entityIndex ;
|
||||
}
|
||||
|
||||
public void InvokeDespawnEvent() {
|
||||
EntityDespawnEvent?.Invoke(this) ;
|
||||
}
|
||||
}
|
31
InsAsterix/Assets/Scripts/Entities/Dummy.cs
Normal file
|
@ -0,0 +1,31 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
public class Dummy : MonoBehaviour, IPointerDownHandler
|
||||
{
|
||||
Despawn despawn ;
|
||||
void Start()
|
||||
{
|
||||
AddPhysics2DRaycaster();
|
||||
despawn = gameObject.GetComponent<Despawn>() ;
|
||||
}
|
||||
|
||||
public void OnPointerDown(PointerEventData eventData)
|
||||
{
|
||||
despawn.InvokeDespawnEvent() ;
|
||||
Destroy(gameObject) ;
|
||||
}
|
||||
|
||||
private void AddPhysics2DRaycaster()
|
||||
{
|
||||
Physics2DRaycaster physicsRaycaster = FindObjectOfType<Physics2DRaycaster>();
|
||||
if (physicsRaycaster == null)
|
||||
{
|
||||
Camera.main.gameObject.AddComponent<Physics2DRaycaster>();
|
||||
}
|
||||
}
|
||||
}
|
51
InsAsterix/Assets/Scripts/Entities/EntitySpawner.cs
Normal file
|
@ -0,0 +1,51 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
using UnityEngine.Tilemaps;
|
||||
|
||||
public class EntitySpawner : MonoBehaviour
|
||||
{
|
||||
[FormerlySerializedAs("EntityToSpawn")] public GameObject entityToSpawn ;
|
||||
[FormerlySerializedAs("NumberOfInstances")] public int nbEntityInstances ;
|
||||
|
||||
[FormerlySerializedAs("SpawnPositions")] public Vector2[] spawnPositions;
|
||||
[FormerlySerializedAs("TileGrid")] public GameObject grid;
|
||||
private GameObject[] _instances;
|
||||
private Transform _gridTransform;
|
||||
|
||||
// EntitySpawnEvent is invoked by EntitySpawner upon spawning entity
|
||||
public delegate void EntitySpawnDelegate(Despawn d) ;
|
||||
public EntitySpawnDelegate EntitySpawnEvent ;
|
||||
|
||||
void Start()
|
||||
|
||||
{
|
||||
_instances = new GameObject[nbEntityInstances];
|
||||
for (int index = 0; index < nbEntityInstances; index++)
|
||||
{
|
||||
SpawnEntity(index) ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// GetEntityInstances returns the array of current instantiated entities
|
||||
GameObject[] GetEntityInstances()
|
||||
{
|
||||
return _instances;
|
||||
}
|
||||
|
||||
// SpawnEntity spawns an entity at a random location in the provided locations array
|
||||
void SpawnEntity(int index) {
|
||||
Vector2 newPositionID = spawnPositions[Random.Range(0,spawnPositions.Length)] ;
|
||||
_instances[index] = Instantiate(entityToSpawn, newPositionID, Quaternion.identity, grid.transform) ;
|
||||
Despawn despawn = _instances[index].GetComponent<Despawn>();
|
||||
despawn.EntityDespawnEvent += OnEntityDespawn;
|
||||
despawn.SetEntityIndex(index);
|
||||
EntitySpawnEvent?.Invoke(despawn);
|
||||
}
|
||||
|
||||
void OnEntityDespawn(Despawn d){
|
||||
SpawnEntity(d.GetEntityIndex()) ;
|
||||
}
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
public class EntitySpawner : MonoBehaviour
|
||||
{
|
||||
[FormerlySerializedAs("Grid")] public GameObject grid;
|
||||
[FormerlySerializedAs("EntityToSpawn")] public GameObject entityToSpawn ;
|
||||
[FormerlySerializedAs("SpawnPositions")] public Vector2[] spawnPositions;
|
||||
|
||||
void Start(){
|
||||
SpawnEntity() ;
|
||||
}
|
||||
|
||||
void SpawnEntity() {
|
||||
Vector2 newPositionID = spawnPositions[Random.Range(0,spawnPositions.Length)] ;
|
||||
GameObject instance = Instantiate(entityToSpawn, newPositionID, Quaternion.identity, grid.transform) ;
|
||||
instance.GetComponent<Despawn>().entityDespawnEvent += onEntityDespawn;
|
||||
}
|
||||
|
||||
void onEntityDespawn(){
|
||||
SpawnEntity() ;
|
||||
}
|
||||
}
|
BIN
InsAsterix/Library/Artifacts/02/022367263bd3c8f4c0d208c0ecd82f39
Normal file
BIN
InsAsterix/Library/Artifacts/05/0578d7052522ad58a01ba5d935cf70d7
Normal file
BIN
InsAsterix/Library/Artifacts/08/08895f4227ee9b2734cebd8d190c38e5
Normal file
BIN
InsAsterix/Library/Artifacts/0d/0dfa34c3757a921cded3f401660896e1
Normal file
BIN
InsAsterix/Library/Artifacts/1b/1b966c873c2056f7167ed2ec79cea502
Normal file
BIN
InsAsterix/Library/Artifacts/1c/1cca009c176bee0931b95ea037ed3608
Normal file
BIN
InsAsterix/Library/Artifacts/1e/1e0b1b9d4c7befc991041ff71db9b546
Normal file
After Width: | Height: | Size: 6.7 KiB |
BIN
InsAsterix/Library/Artifacts/1f/1fb61bf8fcc866f06a1da83d174fce9d
Normal file
BIN
InsAsterix/Library/Artifacts/2a/2a4471e4b6ede24a772740614b013316
Normal file
BIN
InsAsterix/Library/Artifacts/2a/2ab41848da8424fc76b69186fce1de36
Normal file
BIN
InsAsterix/Library/Artifacts/33/33ef5e68d1af42e0f47bc4fab3e92ed9
Normal file
BIN
InsAsterix/Library/Artifacts/50/50241b6ef671333f12cc568889e4b50a
Normal file
BIN
InsAsterix/Library/Artifacts/53/53bb74d389a255d14dc035d5c04364cf
Normal file
BIN
InsAsterix/Library/Artifacts/55/55086b656479d97a7de7a70cac5283b5
Normal file
After Width: | Height: | Size: 554 B |
BIN
InsAsterix/Library/Artifacts/56/56811fe469e092f0b82432aa09fa3814
Normal file
BIN
InsAsterix/Library/Artifacts/65/65f8aacf4d3972c0de30276e58dec087
Normal file
After Width: | Height: | Size: 554 B |
BIN
InsAsterix/Library/Artifacts/70/701194d87009c10c360df075667dd47e
Normal file
BIN
InsAsterix/Library/Artifacts/73/73cb72187d35842666cbcbd40d9ee468
Normal file
BIN
InsAsterix/Library/Artifacts/75/752e55cf78f68aacca0eb0852e9e3d08
Normal file
BIN
InsAsterix/Library/Artifacts/75/7582958982a164efef9f636718886a30
Normal file
BIN
InsAsterix/Library/Artifacts/78/78917c670bbe05d7f5966d27717041ec
Normal file
BIN
InsAsterix/Library/Artifacts/7d/7d24b343a3352882199557a5eb29fd90
Normal file
After Width: | Height: | Size: 700 B |
BIN
InsAsterix/Library/Artifacts/7d/7d3720f3e66b4bfaeb8de6c154ddc2a3
Normal file
BIN
InsAsterix/Library/Artifacts/83/83d0be9c0d1ad0133db679ff331d16d8
Normal file
BIN
InsAsterix/Library/Artifacts/8b/8bd4562a1f2901a25bccf0beed8c99a0
Normal file
BIN
InsAsterix/Library/Artifacts/92/92722078de36daac3982c27a9e3a01fe
Normal file
BIN
InsAsterix/Library/Artifacts/99/9914f2224d53e742528024404adc9652
Normal file
After Width: | Height: | Size: 641 B |
BIN
InsAsterix/Library/Artifacts/9d/9da808d3b359d77911a4a807b3f613d9
Normal file
BIN
InsAsterix/Library/Artifacts/9e/9e90468147c1d3d82d5a5dc0e0b65af8
Normal file
BIN
InsAsterix/Library/Artifacts/a4/a4122b4d158b57df175b95190ddddb8d
Normal file
BIN
InsAsterix/Library/Artifacts/a5/a517f9b0a20d978c67235eaf5a04407f
Normal file
After Width: | Height: | Size: 856 B |
BIN
InsAsterix/Library/Artifacts/ab/ab8716f486fef51d5adf6d23311c568d
Normal file
BIN
InsAsterix/Library/Artifacts/ac/ac9c15ef346cd2b9d406d1374a5a66ff
Normal file
BIN
InsAsterix/Library/Artifacts/ae/ae07460b80c93043aa7c7da93095a362
Normal file
After Width: | Height: | Size: 579 B |
BIN
InsAsterix/Library/Artifacts/ae/aecaa73de54a7b5a59dfabf2653e8352
Normal file
BIN
InsAsterix/Library/Artifacts/b6/b60145b23d05c27a65f441dbbb9e912e
Normal file
BIN
InsAsterix/Library/Artifacts/bd/bd735a62cc37afd0f09ef542d4318323
Normal file
BIN
InsAsterix/Library/Artifacts/be/be38d0976da5838904633c4e9655ba7c
Normal file
BIN
InsAsterix/Library/Artifacts/c9/c96fc26af6da0ea7de697c57e7f50afa
Normal file
BIN
InsAsterix/Library/Artifacts/ca/ca36828c3cbb585ad3ef311206e0d51a
Normal file
BIN
InsAsterix/Library/Artifacts/ce/ce7b94c83a2a5ae9d260546520fe65c3
Normal file
BIN
InsAsterix/Library/Artifacts/cf/cf69549741d2c8674a7adf685373dbab
Normal file
BIN
InsAsterix/Library/Artifacts/d4/d46831cb6a04e176d15ebaad011e201e
Normal file
BIN
InsAsterix/Library/Artifacts/e3/e374115c83f53f99d84636605e6683d3
Normal file
BIN
InsAsterix/Library/Artifacts/e6/e65b77cf5bcc2edd9810439cc3f58492
Normal file
Before Width: | Height: | Size: 3.7 KiB |
BIN
InsAsterix/Library/Artifacts/eb/eb11de7f599192c4f17ddd02cef5d713
Normal file
After Width: | Height: | Size: 6.5 KiB |
BIN
InsAsterix/Library/Artifacts/f9/f916d60778b9b879b383098e0dfe4ac2
Normal file
|
@ -377,9 +377,10 @@
|
|||
-r:"Library/Bee/artifacts/2400b0aEDbg.dag/Unity.VisualStudio.Editor.ref.dll"
|
||||
-r:"Library/Bee/artifacts/2400b0aEDbg.dag/UnityEditor.UI.ref.dll"
|
||||
-r:"Library/Bee/artifacts/2400b0aEDbg.dag/UnityEngine.UI.ref.dll"
|
||||
"Assets/Scripts/Despawn.cs"
|
||||
"Assets/Scripts/Dummy.cs"
|
||||
"Assets/Scripts/EntitySpawner.cs"
|
||||
"Assets/Scripts/Entities/CoinEntitySpawner.cs"
|
||||
"Assets/Scripts/Entities/Despawn.cs"
|
||||
"Assets/Scripts/Entities/Dummy.cs"
|
||||
"Assets/Scripts/Entities/EntitySpawner.cs"
|
||||
-langversion:9.0
|
||||
|
||||
/deterministic
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
{ "pid": 35942, "tid": -1, "ph": "M", "name": "process_name", "args": { "name": "netcorerun.dll" } },
|
||||
{ "pid": 35942, "tid": -1, "ph": "M", "name": "process_sort_index", "args": { "sort_index": "-1" } },
|
||||
{ "pid": 35942, "tid": 1, "ph": "M", "name": "thread_name", "args": { "name": "" } },
|
||||
{ "pid": 35942, "tid": 1, "ts": 1682783120988836, "dur": 735021, "ph": "X", "name": "BuildProgram", "args": {} },
|
||||
{ "pid": 35942, "tid": 1, "ts": 1682783120990479, "dur": 90733, "ph": "X", "name": "BuildProgramContextConstructor", "args": {} },
|
||||
{ "pid": 35942, "tid": 1, "ts": 1682783121582805, "dur": 3895, "ph": "X", "name": "OutputData.Write", "args": {} },
|
||||
{ "pid": 35942, "tid": 1, "ts": 1682783121586703, "dur": 137128, "ph": "X", "name": "Backend.Write", "args": {} },
|
||||
{ "pid": 35942, "tid": 1, "ts": 1682783121587430, "dur": 101449, "ph": "X", "name": "JsonToString", "args": {} },
|
||||
{ "pid": 35942, "tid": 1, "ts": 1682783121728423, "dur": 1235, "ph": "X", "name": "", "args": {} },
|
||||
{ "pid": 35942, "tid": 1, "ts": 1682783121728016, "dur": 1671, "ph": "X", "name": "Write chrome-trace events", "args": {} },
|
||||
{ "pid": 35942, "tid": 1, "ts": 1682953017622515, "dur": 738447, "ph": "X", "name": "BuildProgram", "args": {} },
|
||||
{ "pid": 35942, "tid": 1, "ts": 1682953017623905, "dur": 89361, "ph": "X", "name": "BuildProgramContextConstructor", "args": {} },
|
||||
{ "pid": 35942, "tid": 1, "ts": 1682953018236543, "dur": 5034, "ph": "X", "name": "OutputData.Write", "args": {} },
|
||||
{ "pid": 35942, "tid": 1, "ts": 1682953018241580, "dur": 119359, "ph": "X", "name": "Backend.Write", "args": {} },
|
||||
{ "pid": 35942, "tid": 1, "ts": 1682953018242473, "dur": 94472, "ph": "X", "name": "JsonToString", "args": {} },
|
||||
{ "pid": 35942, "tid": 1, "ts": 1682953018365893, "dur": 1751, "ph": "X", "name": "", "args": {} },
|
||||
{ "pid": 35942, "tid": 1, "ts": 1682953018365405, "dur": 2274, "ph": "X", "name": "Write chrome-trace events", "args": {} },
|
||||
|
|