enemy death respawn
This commit is contained in:
parent
2bf623d71b
commit
399ae7d7f2
|
|
@ -62,7 +62,7 @@ MeshRenderer:
|
||||||
m_RenderingLayerMask: 1
|
m_RenderingLayerMask: 1
|
||||||
m_RendererPriority: 0
|
m_RendererPriority: 0
|
||||||
m_Materials:
|
m_Materials:
|
||||||
- {fileID: 2100000, guid: 2613116b8a9839f4eb8abb181b83477e, type: 2}
|
- {fileID: 0}
|
||||||
m_StaticBatchInfo:
|
m_StaticBatchInfo:
|
||||||
firstSubMesh: 0
|
firstSubMesh: 0
|
||||||
subMeshCount: 0
|
subMeshCount: 0
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ MeshRenderer:
|
||||||
m_RenderingLayerMask: 1
|
m_RenderingLayerMask: 1
|
||||||
m_RendererPriority: 0
|
m_RendererPriority: 0
|
||||||
m_Materials:
|
m_Materials:
|
||||||
- {fileID: 2100000, guid: ad5de8193a625af48b1318e417ae6c7e, type: 2}
|
- {fileID: 0}
|
||||||
m_StaticBatchInfo:
|
m_StaticBatchInfo:
|
||||||
firstSubMesh: 0
|
firstSubMesh: 0
|
||||||
subMeshCount: 0
|
subMeshCount: 0
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ MeshRenderer:
|
||||||
m_RenderingLayerMask: 1
|
m_RenderingLayerMask: 1
|
||||||
m_RendererPriority: 0
|
m_RendererPriority: 0
|
||||||
m_Materials:
|
m_Materials:
|
||||||
- {fileID: 2100000, guid: 5c1e5d25177fa1740921151b338e4d3b, type: 2}
|
- {fileID: 0}
|
||||||
m_StaticBatchInfo:
|
m_StaticBatchInfo:
|
||||||
firstSubMesh: 0
|
firstSubMesh: 0
|
||||||
subMeshCount: 0
|
subMeshCount: 0
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ MeshRenderer:
|
||||||
m_RenderingLayerMask: 1
|
m_RenderingLayerMask: 1
|
||||||
m_RendererPriority: 0
|
m_RendererPriority: 0
|
||||||
m_Materials:
|
m_Materials:
|
||||||
- {fileID: 2100000, guid: 9636898e0cabdf64d99f5040090fe41e, type: 2}
|
- {fileID: 0}
|
||||||
m_StaticBatchInfo:
|
m_StaticBatchInfo:
|
||||||
firstSubMesh: 0
|
firstSubMesh: 0
|
||||||
subMeshCount: 0
|
subMeshCount: 0
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ MeshRenderer:
|
||||||
m_RenderingLayerMask: 1
|
m_RenderingLayerMask: 1
|
||||||
m_RendererPriority: 0
|
m_RendererPriority: 0
|
||||||
m_Materials:
|
m_Materials:
|
||||||
- {fileID: 2100000, guid: cf8ec3e416933f743be4df134d5e44b1, type: 2}
|
- {fileID: 0}
|
||||||
m_StaticBatchInfo:
|
m_StaticBatchInfo:
|
||||||
firstSubMesh: 0
|
firstSubMesh: 0
|
||||||
subMeshCount: 0
|
subMeshCount: 0
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ MeshRenderer:
|
||||||
m_RenderingLayerMask: 1
|
m_RenderingLayerMask: 1
|
||||||
m_RendererPriority: 0
|
m_RendererPriority: 0
|
||||||
m_Materials:
|
m_Materials:
|
||||||
- {fileID: 2100000, guid: 645f88d72b3eef14ea19d492a14cf019, type: 2}
|
- {fileID: 0}
|
||||||
m_StaticBatchInfo:
|
m_StaticBatchInfo:
|
||||||
firstSubMesh: 0
|
firstSubMesh: 0
|
||||||
subMeshCount: 0
|
subMeshCount: 0
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ MeshRenderer:
|
||||||
m_RenderingLayerMask: 1
|
m_RenderingLayerMask: 1
|
||||||
m_RendererPriority: 0
|
m_RendererPriority: 0
|
||||||
m_Materials:
|
m_Materials:
|
||||||
- {fileID: 2100000, guid: 8e74db0c7188ac54caf60d60c6f47ad8, type: 2}
|
- {fileID: 0}
|
||||||
m_StaticBatchInfo:
|
m_StaticBatchInfo:
|
||||||
firstSubMesh: 0
|
firstSubMesh: 0
|
||||||
subMeshCount: 0
|
subMeshCount: 0
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ MeshRenderer:
|
||||||
m_RenderingLayerMask: 1
|
m_RenderingLayerMask: 1
|
||||||
m_RendererPriority: 0
|
m_RendererPriority: 0
|
||||||
m_Materials:
|
m_Materials:
|
||||||
- {fileID: 2100000, guid: 1b30e6bfb9cebd5418e40f107af416af, type: 2}
|
- {fileID: 0}
|
||||||
m_StaticBatchInfo:
|
m_StaticBatchInfo:
|
||||||
firstSubMesh: 0
|
firstSubMesh: 0
|
||||||
subMeshCount: 0
|
subMeshCount: 0
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ MeshRenderer:
|
||||||
m_RenderingLayerMask: 1
|
m_RenderingLayerMask: 1
|
||||||
m_RendererPriority: 0
|
m_RendererPriority: 0
|
||||||
m_Materials:
|
m_Materials:
|
||||||
- {fileID: 2100000, guid: 29a955f37eb0e3549a9a2dfdc8ebcff6, type: 2}
|
- {fileID: 0}
|
||||||
m_StaticBatchInfo:
|
m_StaticBatchInfo:
|
||||||
firstSubMesh: 0
|
firstSubMesh: 0
|
||||||
subMeshCount: 0
|
subMeshCount: 0
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,47 @@ public class GameManager : NetworkBehaviour
|
||||||
Debug.LogError("Couldn't find loot data for " + type);
|
Debug.LogError("Couldn't find loot data for " + type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void OnEnemyDeath(enemyScript enemy, Vector3 spawnPos)
|
||||||
|
{
|
||||||
|
instance.onEnemyDeath(enemy,spawnPos);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onEnemyDeath(enemyScript enemy, Vector3 spawnPos)
|
||||||
|
{
|
||||||
|
if (!isServer)
|
||||||
|
{
|
||||||
|
Debug.LogError("Server function called on client. This cant happen");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
string enemyName = enemy.transform.name;
|
||||||
|
int enemyLevel = enemy.level;
|
||||||
|
|
||||||
|
NetworkServer.Destroy(enemy.gameObject);
|
||||||
|
|
||||||
|
foreach(EnemySpawnEntry entry in enemySpawns)
|
||||||
|
{
|
||||||
|
if (entry.prefab.name.Contains(enemyName.Replace("(Clone)","")))
|
||||||
|
{
|
||||||
|
StartCoroutine(SpawnLater(entry.prefab, spawnPos, 5, enemyLevel));
|
||||||
|
Debug.Log("Found enemy prefab for " + enemyName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Debug.LogError("Unable to find matching prefab for " + enemyName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
IEnumerator SpawnLater(GameObject go, Vector3 pos, float timer, int level)
|
||||||
|
{
|
||||||
|
yield return new WaitForSeconds(timer);
|
||||||
|
GameObject newGo = Instantiate(go, pos, Quaternion.identity);
|
||||||
|
|
||||||
|
NetworkServer.Spawn(newGo);
|
||||||
|
newGo.GetComponent<enemyScript>().SetLevel(level);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
fileFormatVersion: 2
|
|
||||||
guid: 5b07afdbcf13e43438545d591cfd2e4b
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
|
|
@ -104,7 +104,7 @@ MeshRenderer:
|
||||||
m_RenderingLayerMask: 1
|
m_RenderingLayerMask: 1
|
||||||
m_RendererPriority: 0
|
m_RendererPriority: 0
|
||||||
m_Materials:
|
m_Materials:
|
||||||
- {fileID: 2100000, guid: 2613116b8a9839f4eb8abb181b83477e, type: 2}
|
- {fileID: 0}
|
||||||
m_StaticBatchInfo:
|
m_StaticBatchInfo:
|
||||||
firstSubMesh: 0
|
firstSubMesh: 0
|
||||||
subMeshCount: 0
|
subMeshCount: 0
|
||||||
|
|
|
||||||
|
|
@ -395,16 +395,36 @@ public class enemyScript : NetworkBehaviour
|
||||||
GameObject newLoot = Instantiate(GameManager.instance.GetRandomLoot(), lootSpawnPos, Quaternion.identity);
|
GameObject newLoot = Instantiate(GameManager.instance.GetRandomLoot(), lootSpawnPos, Quaternion.identity);
|
||||||
|
|
||||||
NetworkServer.Spawn(newLoot);
|
NetworkServer.Spawn(newLoot);
|
||||||
yield return new WaitForSecondsRealtime(5);
|
yield return new WaitForSecondsRealtime(3);
|
||||||
transform.position = defaultPos;
|
|
||||||
|
|
||||||
|
if (!isServer)
|
||||||
|
{
|
||||||
|
CmdDie();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GameManager.OnEnemyDeath(this, defaultPos);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* transform.position = defaultPos;
|
||||||
health = (int)maxHealth;
|
health = (int)maxHealth;
|
||||||
magicalHealth = (int)maxHealth;
|
magicalHealth = (int)maxHealth;*/
|
||||||
|
|
||||||
//animationString = "Idle";
|
//animationString = "Idle";
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Command]
|
||||||
|
void CmdDie()
|
||||||
|
{
|
||||||
|
GameManager.OnEnemyDeath(this,defaultPos);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void OnHealthChange(int oldVlaue, int newValue){
|
public void OnHealthChange(int oldVlaue, int newValue){
|
||||||
healthBar.SetHealth(newValue,maxHealth);
|
healthBar.SetHealth(newValue,maxHealth);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -694,7 +694,7 @@ public class playerNetwork : NetworkBehaviour
|
||||||
startClient.instance.networkManager.StopClient();
|
startClient.instance.networkManager.StopClient();
|
||||||
SceneManager.LoadScene("GameLogin");
|
SceneManager.LoadScene("GameLogin");
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR || UNITY_SERVER
|
||||||
#else
|
#else
|
||||||
PlayGamesPlatform.Instance.SignOut();
|
PlayGamesPlatform.Instance.SignOut();
|
||||||
Firebase.Auth.FirebaseAuth.DefaultInstance.SignOut();
|
Firebase.Auth.FirebaseAuth.DefaultInstance.SignOut();
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
{
|
{
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"com.unity.2d.animation": {
|
"com.unity.2d.animation": {
|
||||||
"version": "9.1.1",
|
"version": "9.0.3",
|
||||||
"depth": 1,
|
"depth": 1,
|
||||||
"source": "registry",
|
"source": "registry",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"com.unity.2d.common": "8.0.2",
|
"com.unity.2d.common": "8.0.1",
|
||||||
"com.unity.2d.sprite": "1.0.0",
|
"com.unity.2d.sprite": "1.0.0",
|
||||||
"com.unity.collections": "1.1.0",
|
"com.unity.collections": "1.1.0",
|
||||||
"com.unity.modules.animation": "1.0.0",
|
"com.unity.modules.animation": "1.0.0",
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
"url": "https://packages.unity.com"
|
"url": "https://packages.unity.com"
|
||||||
},
|
},
|
||||||
"com.unity.2d.aseprite": {
|
"com.unity.2d.aseprite": {
|
||||||
"version": "1.1.4",
|
"version": "1.0.0",
|
||||||
"depth": 1,
|
"depth": 1,
|
||||||
"source": "registry",
|
"source": "registry",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
"url": "https://packages.unity.com"
|
"url": "https://packages.unity.com"
|
||||||
},
|
},
|
||||||
"com.unity.2d.common": {
|
"com.unity.2d.common": {
|
||||||
"version": "8.0.2",
|
"version": "8.0.1",
|
||||||
"depth": 2,
|
"depth": 2,
|
||||||
"source": "registry",
|
"source": "registry",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
@ -46,12 +46,12 @@
|
||||||
"url": "https://packages.unity.com"
|
"url": "https://packages.unity.com"
|
||||||
},
|
},
|
||||||
"com.unity.2d.psdimporter": {
|
"com.unity.2d.psdimporter": {
|
||||||
"version": "8.0.5",
|
"version": "8.0.2",
|
||||||
"depth": 1,
|
"depth": 1,
|
||||||
"source": "registry",
|
"source": "registry",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"com.unity.2d.animation": "9.1.1",
|
"com.unity.2d.animation": "9.0.1",
|
||||||
"com.unity.2d.common": "8.0.2",
|
"com.unity.2d.common": "8.0.1",
|
||||||
"com.unity.2d.sprite": "1.0.0"
|
"com.unity.2d.sprite": "1.0.0"
|
||||||
},
|
},
|
||||||
"url": "https://packages.unity.com"
|
"url": "https://packages.unity.com"
|
||||||
|
|
@ -63,12 +63,12 @@
|
||||||
"dependencies": {}
|
"dependencies": {}
|
||||||
},
|
},
|
||||||
"com.unity.2d.spriteshape": {
|
"com.unity.2d.spriteshape": {
|
||||||
"version": "9.0.3",
|
"version": "9.0.2",
|
||||||
"depth": 1,
|
"depth": 1,
|
||||||
"source": "registry",
|
"source": "registry",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"com.unity.mathematics": "1.1.0",
|
"com.unity.mathematics": "1.1.0",
|
||||||
"com.unity.2d.common": "8.0.2",
|
"com.unity.2d.common": "8.0.1",
|
||||||
"com.unity.modules.physics2d": "1.0.0"
|
"com.unity.modules.physics2d": "1.0.0"
|
||||||
},
|
},
|
||||||
"url": "https://packages.unity.com"
|
"url": "https://packages.unity.com"
|
||||||
|
|
@ -83,7 +83,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"com.unity.2d.tilemap.extras": {
|
"com.unity.2d.tilemap.extras": {
|
||||||
"version": "3.1.2",
|
"version": "3.1.1",
|
||||||
"depth": 1,
|
"depth": 1,
|
||||||
"source": "registry",
|
"source": "registry",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
@ -95,12 +95,11 @@
|
||||||
"url": "https://packages.unity.com"
|
"url": "https://packages.unity.com"
|
||||||
},
|
},
|
||||||
"com.unity.burst": {
|
"com.unity.burst": {
|
||||||
"version": "1.8.15",
|
"version": "1.8.7",
|
||||||
"depth": 3,
|
"depth": 3,
|
||||||
"source": "registry",
|
"source": "registry",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"com.unity.mathematics": "1.2.1",
|
"com.unity.mathematics": "1.2.1"
|
||||||
"com.unity.modules.jsonserialize": "1.0.0"
|
|
||||||
},
|
},
|
||||||
"url": "https://packages.unity.com"
|
"url": "https://packages.unity.com"
|
||||||
},
|
},
|
||||||
|
|
@ -133,14 +132,14 @@
|
||||||
"depth": 0,
|
"depth": 0,
|
||||||
"source": "builtin",
|
"source": "builtin",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"com.unity.2d.animation": "9.1.1",
|
"com.unity.2d.animation": "9.0.3",
|
||||||
"com.unity.2d.pixel-perfect": "5.0.3",
|
"com.unity.2d.pixel-perfect": "5.0.3",
|
||||||
"com.unity.2d.psdimporter": "8.0.5",
|
"com.unity.2d.psdimporter": "8.0.2",
|
||||||
"com.unity.2d.sprite": "1.0.0",
|
"com.unity.2d.sprite": "1.0.0",
|
||||||
"com.unity.2d.spriteshape": "9.0.3",
|
"com.unity.2d.spriteshape": "9.0.2",
|
||||||
"com.unity.2d.tilemap": "1.0.0",
|
"com.unity.2d.tilemap": "1.0.0",
|
||||||
"com.unity.2d.tilemap.extras": "3.1.2",
|
"com.unity.2d.tilemap.extras": "3.1.1",
|
||||||
"com.unity.2d.aseprite": "1.1.4"
|
"com.unity.2d.aseprite": "1.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"com.unity.ide.rider": {
|
"com.unity.ide.rider": {
|
||||||
|
|
|
||||||
17
ProjectSettings/BurstAotSettings_StandaloneLinux64.json
Normal file
17
ProjectSettings/BurstAotSettings_StandaloneLinux64.json
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"MonoBehaviour": {
|
||||||
|
"Version": 4,
|
||||||
|
"EnableBurstCompilation": true,
|
||||||
|
"EnableOptimisations": true,
|
||||||
|
"EnableSafetyChecks": false,
|
||||||
|
"EnableDebugInAllBuilds": false,
|
||||||
|
"DebugDataKind": 1,
|
||||||
|
"EnableArmv9SecurityFeatures": false,
|
||||||
|
"CpuMinTargetX32": 0,
|
||||||
|
"CpuMaxTargetX32": 0,
|
||||||
|
"CpuMinTargetX64": 0,
|
||||||
|
"CpuMaxTargetX64": 0,
|
||||||
|
"CpuTargetsX64": 72,
|
||||||
|
"OptimizeFor": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -5,10 +5,10 @@ EditorBuildSettings:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Scenes:
|
m_Scenes:
|
||||||
- enabled: 1
|
- enabled: 0
|
||||||
path: Assets/Scenes/GameLogin.unity
|
path: Assets/Scenes/GameLogin.unity
|
||||||
guid: 8f7fc7ae237f341739c369fc7d9f4b75
|
guid: 8f7fc7ae237f341739c369fc7d9f4b75
|
||||||
- enabled: 1
|
- enabled: 0
|
||||||
path: Assets/Scenes/MenuScene.unity
|
path: Assets/Scenes/MenuScene.unity
|
||||||
guid: a141cf40801414f09a4017e4a9f84683
|
guid: a141cf40801414f09a4017e4a9f84683
|
||||||
- enabled: 1
|
- enabled: 1
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,2 @@
|
||||||
m_EditorVersion: 2022.3.33f1
|
m_EditorVersion: 2022.3.7f1
|
||||||
m_EditorVersionWithRevision: 2022.3.33f1 (b2c853adf198)
|
m_EditorVersionWithRevision: 2022.3.7f1 (b16b3b16c7a0)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user