game: Npc spawner pt1

realised that the models need to rigged and animated so stopping here for now
This commit is contained in:
ryan 2025-02-01 01:38:25 +08:00
parent 1601426d0f
commit b25d73d3f0
10 changed files with 88 additions and 52 deletions

View file

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 8bd51d631c448be4994a873ec1aaee70
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: f66c8491b722049409ba44df758dddfd
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: f82a139af63f1fb488367a85f5e3f345
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: d95c3a2e9a39dee4289a159646510527
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: e49446b1e5ffd3e44868005292f43190
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,73 @@
/*
* Author: Lin Hengrui Ryan
* Date: 1/2/25
* Description:
* Npc Manager
*/
using System;
using UnityEngine;
using System;
using System.Collections.Generic;
using UnityEngine.Serialization;
public class NpcManager : MonoBehaviour
{
/// <summary>
/// to test this script
/// </summary>
private void Start()
{
for (int i = 0; i < 4; i++)
{
spawnNpc(true , spawnPoints[i]);
}
}
/// <summary>
/// Assign Npc Manager instance
/// </summary>
public static NpcManager instance;
/// <summary>
/// a list of all the male npcs
/// </summary>
public GameObject[] maleNpcs;
/// <summary>
/// a list of all female npcs
/// </summary>
public GameObject[] femaleNpcs;
/// <summary>
/// a prefab of the police npc
/// </summary>
public GameObject policeNpc;
/// <summary>
/// list of all the spawn points
/// </summary>
public Transform[] spawnPoints;
/// <summary>
/// collection of all exiting npcs
/// </summary>
public GameObject[] currentNpcs;
public void spawnNpc(bool isFemale, Transform spawnPoint)
{
var randomNpc=0;
if (isFemale)
{
randomNpc = UnityEngine.Random.Range(0, femaleNpcs.Length);
}
else
{
randomNpc = UnityEngine.Random.Range(0, maleNpcs.Length);
}
var npc = Instantiate(isFemale ? femaleNpcs[randomNpc] : maleNpcs[randomNpc], spawnPoint.position, Quaternion.identity);
// currentNpcs.SetValue(npc,currentNpcs.Length);
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: df416a088d4174a48859fb9f90dc961a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 58f7e79a87c79824597746e8c1bfe400
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: f58d25b9e504a4f41ab4a71cf87c1845
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -224,6 +224,10 @@ PrefabInstance:
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5866666021909216657, guid: 0940da46cb529f6458578c054115c1e4, type: 3}
propertyPath: m_Controller
value:
objectReference: {fileID: 9100000, guid: b2619aaa78281c142a724c6867b036c6, type: 2}
- target: {fileID: 5941707509770014260, guid: 0940da46cb529f6458578c054115c1e4, type: 3}
propertyPath: m_IsActive
value: 0