13 changed files with 190 additions and 8 deletions
@ -0,0 +1,22 @@ |
|||||
|
using System.Collections; |
||||
|
using System.Collections.Generic; |
||||
|
using UnityEngine; |
||||
|
|
||||
|
public class EnemyName : MonoBehaviour |
||||
|
{ |
||||
|
|
||||
|
|
||||
|
public const string skullGuardian = "SkullGuardian"; |
||||
|
public const string skeletonArcher = "SkeletonArcher"; |
||||
|
public const string skullmage = "SkullMage"; |
||||
|
public const string ashBeetle = "AshBeetle"; |
||||
|
public const string hoodWanderer = "HoodWanderer"; |
||||
|
public const string skullWarlock = "SkullWarlock"; |
||||
|
public const string blastFistMushroom = "BlastFistMushroom"; |
||||
|
public const string shatteringFistMushroom = "ShatteringFistMushroom"; |
||||
|
public const string parasiticMushroom = "ParasiticMushroom"; |
||||
|
public const string emberWraith = "EmberWraith"; |
||||
|
public const string drowsyShroom = "DrowsyShroom"; |
||||
|
public const string bone = "Bone"; |
||||
|
public const string corrosiveSludge = "CorrosiveSludge"; |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: b54737814f2e13f43b76a4f3f2ae304c |
||||
|
MonoImporter: |
||||
|
externalObjects: {} |
||||
|
serializedVersion: 2 |
||||
|
defaultReferences: [] |
||||
|
executionOrder: 0 |
||||
|
icon: {instanceID: 0} |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
@ -0,0 +1,63 @@ |
|||||
|
using System.Collections; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using UnityEditor; |
||||
|
using UnityEngine; |
||||
|
|
||||
|
public class EnemyPool : MonoBehaviour |
||||
|
{ |
||||
|
public static Dictionary<List<string>, float> weakEnemyPool = new Dictionary<List<string>, float>() |
||||
|
{ |
||||
|
{ new List<string> { EnemyName.ashBeetle,EnemyName.hoodWanderer}, 0.25f }, |
||||
|
{ new List<string> { EnemyName.skullGuardian,EnemyName.skullWarlock}, 0.25f }, |
||||
|
{ new List<string> { EnemyName.blastFistMushroom}, 0.25f }, |
||||
|
{ new List<string> { EnemyName.corrosiveSludge,EnemyName.skullmage}, 0.25f } |
||||
|
}; |
||||
|
|
||||
|
public static Dictionary<List<string>, float> strongEnemyPool = new Dictionary<List<string>, float>() |
||||
|
{ |
||||
|
{ new List<string> { EnemyName.skullGuardian,EnemyName.skullmage,EnemyName.skullWarlock}, 0.245f }, |
||||
|
{ new List<string> { EnemyName.shatteringFistMushroom,EnemyName.blastFistMushroom}, 0.125f }, |
||||
|
{ new List<string> { EnemyName.parasiticMushroom,EnemyName.parasiticMushroom,EnemyName.blastFistMushroom}, 0.125f }, |
||||
|
{ new List<string> { EnemyName.emberWraith,EnemyName.emberWraith,EnemyName.corrosiveSludge}, 0.065f }, |
||||
|
{ new List<string> { EnemyName.ashBeetle,EnemyName.ashBeetle,EnemyName.hoodWanderer,EnemyName.hoodWanderer}, 0.125f }, |
||||
|
{ new List<string> { EnemyName.ashBeetle,EnemyName.skullmage}, 0.125f }, |
||||
|
{ new List<string> { EnemyName.emberWraith,EnemyName.emberWraith,EnemyName.corrosiveSludge}, 0.125f }, |
||||
|
{ new List<string> { EnemyName.blastFistMushroom,EnemyName.skullmage,EnemyName.skullWarlock}, 0.065f } |
||||
|
}; |
||||
|
|
||||
|
|
||||
|
public static List<string> GetRandomEnemyPool(Dictionary<List<string>, float> enemyPool) |
||||
|
{ |
||||
|
System.Random random = new System.Random(); |
||||
|
float totalWeight = enemyPool.Values.Sum(); |
||||
|
float randomNumber = (float)random.NextDouble() * totalWeight; |
||||
|
|
||||
|
float cumulativeWeight = 0f; |
||||
|
foreach (var action in enemyPool) |
||||
|
{ |
||||
|
cumulativeWeight += action.Value; |
||||
|
if (randomNumber <= cumulativeWeight) |
||||
|
{ |
||||
|
return action.Key; |
||||
|
} |
||||
|
} |
||||
|
return enemyPool.Keys.Last(); |
||||
|
} |
||||
|
|
||||
|
public static List<GameObject> getEnemyPrefab(List<string> enemyList) |
||||
|
{ |
||||
|
List <GameObject> enemyPrefabs= new List<GameObject>(); |
||||
|
foreach (var enemy in enemyList) |
||||
|
{ |
||||
|
GameObject prefab = AssetDatabase.LoadAssetAtPath<GameObject>("Assets/Prefab/EnemyPrefab/"+enemy+ ".prefab"); |
||||
|
enemyPrefabs.Add(prefab); |
||||
|
} |
||||
|
foreach (var enemy in enemyPrefabs) |
||||
|
{ |
||||
|
Debug.Log(enemy); |
||||
|
} |
||||
|
return enemyPrefabs; |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: 020a499e7b781084aab99b0cff074239 |
||||
|
MonoImporter: |
||||
|
externalObjects: {} |
||||
|
serializedVersion: 2 |
||||
|
defaultReferences: [] |
||||
|
executionOrder: 0 |
||||
|
icon: {instanceID: 0} |
||||
|
userData: |
||||
|
assetBundleName: |
||||
|
assetBundleVariant: |
||||
Binary file not shown.
Loading…
Reference in new issue