private void Awake() { if (instance == null) { instance = this; } else { Destroy(this); } }
// Start is called before the first frame update void Start() { moneyText = statsPanel.transform.Find("CashAmountText").GetComponent <Text>(); credText = statsPanel.transform.Find("CredAmountText").GetComponent <Text>(); weedText = statsPanel.transform.Find("WeedAmountText").GetComponent <Text>(); night = GameObject.Find("NightTimeFade").GetComponent <Night>(); cam = GameObject.FindGameObjectWithTag("MainCamera"); spawnNPC = GameObject.Find("Spawner").GetComponent <SpawnNPC>(); stamina = maxStamina; weeds = FindObjectsOfType <WeedPlant>(); UpdateYield(); // remember to add the initial type of plantable weed to the plantable list }
public void SpawnBoss(int i, int j) { if (Main.netMode == NetmodeID.MultiplayerClient) { var packet = new SpawnNPC(Main.myPlayer, i * 16 + 40, j * 16 + 556, NPCType <VitricBoss>()); packet.Send(-1, -1, false); return; } int n = NPC.NewNPC(i * 16 + 40, j * 16 + 556, NPCType <VitricBoss>()); var npc = Main.npc[n]; if (npc.type == NPCType <VitricBoss>()) { (Dummy(i, j).modProjectile as VitricBossAltarDummy).boss = Main.npc[n]; } }
public override void OnInspectorGUI() { SpawnNPC spawnNPC = target as SpawnNPC; //base inspector if (baseEditor = EditorGUILayout.BeginToggleGroup(new GUIContent("Base inspector.", ""), baseEditor)) { base.OnInspectorGUI(); } EditorGUILayout.EndToggleGroup(); //Edit spawn data if (EditSpawnData = EditorGUILayout.BeginToggleGroup(new GUIContent("Edit SpawnData.", ""), EditSpawnData)) { spawnNPC.spawnNPCData = EditSpawnDataArray(spawnNPC.spawnNPCData); } EditorGUILayout.EndToggleGroup(); //Edit spawn entity if (EditSpawnEntity = EditorGUILayout.BeginToggleGroup(new GUIContent("Edit SpawnEntity.", ""), EditSpawnEntity)) { spawnNPC.spawnEntityArray = EditSpawnEntityArray(spawnNPC.spawnEntityArray, spawnNPC.spawnNPCData.Select(x => x.Name).ToArray()); } EditorGUILayout.EndToggleGroup(); }
void Search() { searchedOutput_ObjectDock = new ObjectDock[]{}; searchedOutput_SpawnNPC = new SpawnNPC[]{}; ObjectDock[] AllObjectDocks = Util.ConvertObjectArray<ObjectDock> (Object.FindObjectsOfType (typeof(ObjectDock))); SpawnNPC[] AllSpawnNPC = Util.ConvertObjectArray<SpawnNPC> (Object.FindObjectsOfType (typeof(SpawnNPC))); GameEventLifeCycle[] AllGameEventLifecycle = Util.ConvertObjectArray<GameEventLifeCycle> (Object.FindObjectsOfType(typeof(GameEventLifeCycle))); ObjectDock[] SearchedOutObjectDocksByEventType = new ObjectDock[]{}; SpawnNPC[] SearchedOutSpawnNPCByEventType = new SpawnNPC[]{}; GameEventLifeCycle[] SearchedOutGameEventLifeCycleByEventType = new GameEventLifeCycle[]{}; ObjectDock[] SearchedOutObjectDocksByObjectReference = new ObjectDock[]{}; SpawnNPC[] SearchedOutSpawnNPCByObjectReference = new SpawnNPC[]{}; GameEventLifeCycle[] SearchedOutGameEventLifeCycleByObjectReference = new GameEventLifeCycle[]{}; if (IsSearchByEventType) { //search every objectdocks, check gameevent type IEnumerable<ObjectDock> docks = AllObjectDocks.Where (x => x.objectDockData.Count (y => y.event_at_start.Concat (y.event_at_end.AsEnumerable ()).Count (z => z.type == searchEventType) > 0) > 0 ); if (docks != null && docks.Count () > 0) { SearchedOutObjectDocksByEventType = docks.ToArray (); } //search every spawnNPC, check gameevent type IEnumerable<SpawnNPC> spawns = AllSpawnNPC.Where (x => x.Event_At_All_Spawned_DieOut.Count ( y => y.type == searchEventType) > 0); if (spawns != null && spawns.Count () > 0) { SearchedOutSpawnNPCByObjectReference = spawns.ToArray (); } //search every gameevent lifecycle, check gameevent type IEnumerable<GameEventLifeCycle> gameEventLifeCycles = AllGameEventLifecycle.Where (x => x.eventOnBirth.Count (y => y.type == searchEventType) > 0) .Concat( AllGameEventLifecycle.Where (x => x.eventOnDestroy.Count (y => y.type == searchEventType) > 0)) .Concat( AllGameEventLifecycle.Where (x => x.eventOnUnitDie.Count (y => y.type == searchEventType) > 0)); if (gameEventLifeCycles != null && gameEventLifeCycles.Count () > 0) { SearchedOutGameEventLifeCycleByEventType = gameEventLifeCycles.ToArray (); } searchedOutput_ObjectDock = SearchedOutObjectDocksByEventType; searchedOutput_SpawnNPC = SearchedOutSpawnNPCByObjectReference; searchedOutput_GameEventLC = SearchedOutGameEventLifeCycleByEventType; } if (IsSearchByObjectInReceiverField) { //search every object dock, check gameevent 's receiver IEnumerable<ObjectDock> docks = AllObjectDocks.Where (x => x.objectDockData.Count (y => y.event_at_start.Concat (y.event_at_end.AsEnumerable ()).Count (z => z.receiver == SearchObjectReference) > 0) > 0 ); if (docks != null && docks.Count () > 0) { SearchedOutObjectDocksByObjectReference = docks.ToArray (); } //search every spawnNPC, check gameevent 's receiver IEnumerable<SpawnNPC> spawns = AllSpawnNPC.Where (x => x.Event_At_All_Spawned_DieOut.Count ( y => y.receiver == SearchObjectReference) > 0); if (spawns != null && spawns.Count () > 0) { SearchedOutSpawnNPCByObjectReference = spawns.ToArray (); } //search every gameevent lifecycle, check gameevent 's receiver IEnumerable<GameEventLifeCycle> gameEventLifeCycles = AllGameEventLifecycle.Where (x => x.eventOnBirth.Count (y => y.receiver == SearchObjectReference) > 0) .Concat( AllGameEventLifecycle.Where (x => x.eventOnDestroy.Count (y => y.receiver == SearchObjectReference) > 0)) .Concat( AllGameEventLifecycle.Where (x => x.eventOnUnitDie.Count (y => y.receiver == SearchObjectReference) > 0)); if (gameEventLifeCycles != null && gameEventLifeCycles.Count () > 0) { SearchedOutGameEventLifeCycleByObjectReference = gameEventLifeCycles.ToArray (); } if (searchedOutput_ObjectDock == null || searchedOutput_ObjectDock.Length == 0) { searchedOutput_ObjectDock = SearchedOutObjectDocksByObjectReference; } else { searchedOutput_ObjectDock = searchedOutput_ObjectDock.Intersect (SearchedOutObjectDocksByObjectReference.AsEnumerable ()).ToArray (); } if (searchedOutput_SpawnNPC == null || searchedOutput_SpawnNPC.Length == 0) { searchedOutput_SpawnNPC = SearchedOutSpawnNPCByObjectReference; } else { searchedOutput_SpawnNPC = searchedOutput_SpawnNPC.Intersect (SearchedOutSpawnNPCByObjectReference.AsEnumerable ()).ToArray (); } if (searchedOutput_GameEventLC == null || searchedOutput_GameEventLC.Length == 0) { searchedOutput_GameEventLC = SearchedOutGameEventLifeCycleByObjectReference; } else { searchedOutput_GameEventLC = searchedOutput_GameEventLC.Intersect (SearchedOutGameEventLifeCycleByObjectReference.AsEnumerable ()).ToArray (); } } }
void Search() { searchedOutput_ObjectDock = new ObjectDock[] {}; searchedOutput_SpawnNPC = new SpawnNPC[] {}; ObjectDock[] AllObjectDocks = Util.ConvertObjectArray <ObjectDock> (Object.FindObjectsOfType(typeof(ObjectDock))); SpawnNPC[] AllSpawnNPC = Util.ConvertObjectArray <SpawnNPC> (Object.FindObjectsOfType(typeof(SpawnNPC))); GameEventLifeCycle[] AllGameEventLifecycle = Util.ConvertObjectArray <GameEventLifeCycle> (Object.FindObjectsOfType(typeof(GameEventLifeCycle))); ObjectDock[] SearchedOutObjectDocksByEventType = new ObjectDock[] {}; SpawnNPC[] SearchedOutSpawnNPCByEventType = new SpawnNPC[] {}; GameEventLifeCycle[] SearchedOutGameEventLifeCycleByEventType = new GameEventLifeCycle[] {}; ObjectDock[] SearchedOutObjectDocksByObjectReference = new ObjectDock[] {}; SpawnNPC[] SearchedOutSpawnNPCByObjectReference = new SpawnNPC[] {}; GameEventLifeCycle[] SearchedOutGameEventLifeCycleByObjectReference = new GameEventLifeCycle[] {}; if (IsSearchByEventType) { //search every objectdocks, check gameevent type IEnumerable <ObjectDock> docks = AllObjectDocks.Where(x => x.objectDockData.Count(y => y.event_at_start.Concat(y.event_at_end.AsEnumerable()).Count(z => z.type == searchEventType) > 0) > 0 ); if (docks != null && docks.Count() > 0) { SearchedOutObjectDocksByEventType = docks.ToArray(); } //search every spawnNPC, check gameevent type IEnumerable <SpawnNPC> spawns = AllSpawnNPC.Where(x => x.Event_At_All_Spawned_DieOut.Count( y => y.type == searchEventType) > 0); if (spawns != null && spawns.Count() > 0) { SearchedOutSpawnNPCByObjectReference = spawns.ToArray(); } //search every gameevent lifecycle, check gameevent type IEnumerable <GameEventLifeCycle> gameEventLifeCycles = AllGameEventLifecycle.Where(x => x.eventOnBirth.Count(y => y.type == searchEventType) > 0) .Concat( AllGameEventLifecycle.Where(x => x.eventOnDestroy.Count(y => y.type == searchEventType) > 0)) .Concat( AllGameEventLifecycle.Where(x => x.eventOnUnitDie.Count(y => y.type == searchEventType) > 0)); if (gameEventLifeCycles != null && gameEventLifeCycles.Count() > 0) { SearchedOutGameEventLifeCycleByEventType = gameEventLifeCycles.ToArray(); } searchedOutput_ObjectDock = SearchedOutObjectDocksByEventType; searchedOutput_SpawnNPC = SearchedOutSpawnNPCByObjectReference; searchedOutput_GameEventLC = SearchedOutGameEventLifeCycleByEventType; } if (IsSearchByObjectInReceiverField) { //search every object dock, check gameevent 's receiver IEnumerable <ObjectDock> docks = AllObjectDocks.Where(x => x.objectDockData.Count(y => y.event_at_start.Concat(y.event_at_end.AsEnumerable()).Count(z => z.receiver == SearchObjectReference) > 0) > 0 ); if (docks != null && docks.Count() > 0) { SearchedOutObjectDocksByObjectReference = docks.ToArray(); } //search every spawnNPC, check gameevent 's receiver IEnumerable <SpawnNPC> spawns = AllSpawnNPC.Where(x => x.Event_At_All_Spawned_DieOut.Count( y => y.receiver == SearchObjectReference) > 0); if (spawns != null && spawns.Count() > 0) { SearchedOutSpawnNPCByObjectReference = spawns.ToArray(); } //search every gameevent lifecycle, check gameevent 's receiver IEnumerable <GameEventLifeCycle> gameEventLifeCycles = AllGameEventLifecycle.Where(x => x.eventOnBirth.Count(y => y.receiver == SearchObjectReference) > 0) .Concat( AllGameEventLifecycle.Where(x => x.eventOnDestroy.Count(y => y.receiver == SearchObjectReference) > 0)) .Concat( AllGameEventLifecycle.Where(x => x.eventOnUnitDie.Count(y => y.receiver == SearchObjectReference) > 0)); if (gameEventLifeCycles != null && gameEventLifeCycles.Count() > 0) { SearchedOutGameEventLifeCycleByObjectReference = gameEventLifeCycles.ToArray(); } if (searchedOutput_ObjectDock == null || searchedOutput_ObjectDock.Length == 0) { searchedOutput_ObjectDock = SearchedOutObjectDocksByObjectReference; } else { searchedOutput_ObjectDock = searchedOutput_ObjectDock.Intersect(SearchedOutObjectDocksByObjectReference.AsEnumerable()).ToArray(); } if (searchedOutput_SpawnNPC == null || searchedOutput_SpawnNPC.Length == 0) { searchedOutput_SpawnNPC = SearchedOutSpawnNPCByObjectReference; } else { searchedOutput_SpawnNPC = searchedOutput_SpawnNPC.Intersect(SearchedOutSpawnNPCByObjectReference.AsEnumerable()).ToArray(); } if (searchedOutput_GameEventLC == null || searchedOutput_GameEventLC.Length == 0) { searchedOutput_GameEventLC = SearchedOutGameEventLifeCycleByObjectReference; } else { searchedOutput_GameEventLC = searchedOutput_GameEventLC.Intersect(SearchedOutGameEventLifeCycleByObjectReference.AsEnumerable()).ToArray(); } } }