public void SpawnEvent(bool state, Event_.EventType eventType, Event_.EventDirection eventDirection, float delayTimer) { currentState = state; currentEventType = eventType; currentEventDirection = eventDirection; spawnDelayTimer = delayTimer; }
//User Input || !Physics private void Update() { //If true then run the events if (runEventTimer) { if (timer >= 60.0f) { baseSystem.DepletionRate = 2; } if (timer >= 180.0f) { baseSystem.DepletionRate = 3; } timer += Time.deltaTime; float timMin = (timer / 300) * 100; //progress slider value is equal to the timer value // timer / minutes in an hour / seconds in a minute * 5 minutes progressText.text = (timMin.ToString("f0") + "%"); //Debug.Log((timer)); foreach (var activeEvent in events) { if (timer >= activeEvent.timeStamp && !activeEvent.BeenUsed) { //Grab the type, store it if (activeEvent.type != Event_.EventType.NONE) { currentEventType = activeEvent.type; } else { currentEventType = Event_.EventType.NONE; } //Grab the direction, store it if (activeEvent.direction != Event_.EventDirection.NONE) { currentEventDirection = activeEvent.direction; } else { currentEventDirection = Event_.EventDirection.NONE; } switch (currentEventType) { case Event_.EventType.NONE: //do nothing - Debug message Debug.Log("<color=red>Critical Error:</color> Event Name: " + activeEvent.name + " did not have a valid event type."); break; case Event_.EventType.ENEMY_SHIP: //Where on screen to place the warning image switch (currentEventDirection) { case Event_.EventDirection.NONE: //do nothing - Debug message Debug.Log("<color=red>Critical Error:</color> Event Name: " + activeEvent.name + " did not have a valid event direction."); break; case Event_.EventDirection.TOP: { warningImageLocation[0].gameObject.SetActive(true); warningImageLocation[0].transform.GetChild(0).GetComponent <Image>().sprite = eventImage[0]; //Run the event launcher warningImageLocation[0].BroadcastMessage("RunEvent", true, SendMessageOptions.DontRequireReceiver); spawnLocation[0].GetComponent <Event_Spawner>().SpawnEvent(true, currentEventType, currentEventDirection, spawnDelayTimer); break; } case Event_.EventDirection.LEFT: { warningImageLocation[1].gameObject.SetActive(true); warningImageLocation[1].transform.GetChild(0).GetComponent <Image>().sprite = eventImage[0]; //Run the event launcher warningImageLocation[1].BroadcastMessage("RunEvent", true, SendMessageOptions.DontRequireReceiver); spawnLocation[1].GetComponent <Event_Spawner>().SpawnEvent(true, currentEventType, currentEventDirection, spawnDelayTimer); break; } case Event_.EventDirection.RIGHT: { warningImageLocation[2].gameObject.SetActive(true); warningImageLocation[2].transform.GetChild(0).GetComponent <Image>().sprite = eventImage[0]; //Run the event launcher warningImageLocation[2].BroadcastMessage("RunEvent", true, SendMessageOptions.DontRequireReceiver); spawnLocation[2].GetComponent <Event_Spawner>().SpawnEvent(true, currentEventType, currentEventDirection, spawnDelayTimer); break; } case Event_.EventDirection.BOTTOM: { warningImageLocation[3].gameObject.SetActive(true); warningImageLocation[3].transform.GetChild(0).GetComponent <Image>().sprite = eventImage[0]; //Run the event launcher warningImageLocation[3].BroadcastMessage("RunEvent", true, SendMessageOptions.DontRequireReceiver); spawnLocation[3].GetComponent <Event_Spawner>().SpawnEvent(true, currentEventType, currentEventDirection, spawnDelayTimer); break; } default: break; } break; case Event_.EventType.ASTEROID: //Where on screen to place the warning image switch (currentEventDirection) { case Event_.EventDirection.NONE: //do nothing - Debug message //Debug.Log("<color=red>Critical Error: Event Name: " + activeEvent.name + " did not have a valid event direction.</color>"); break; case Event_.EventDirection.TOP: { warningImageLocation[0].gameObject.SetActive(true); warningImageLocation[0].transform.GetChild(0).GetComponent <Image>().sprite = eventImage[1]; //Run the event launcher warningImageLocation[0].BroadcastMessage("RunEvent", true, SendMessageOptions.DontRequireReceiver); spawnLocation[0].GetComponent <Event_Spawner>().SpawnEvent(true, currentEventType, currentEventDirection, spawnDelayTimer); break; } case Event_.EventDirection.LEFT: { warningImageLocation[1].gameObject.SetActive(true); warningImageLocation[1].transform.GetChild(0).GetComponent <Image>().sprite = eventImage[1]; //Run the event launcher warningImageLocation[1].BroadcastMessage("RunEvent", true, SendMessageOptions.DontRequireReceiver); spawnLocation[1].GetComponent <Event_Spawner>().SpawnEvent(true, currentEventType, currentEventDirection, spawnDelayTimer); break; } case Event_.EventDirection.RIGHT: { warningImageLocation[2].gameObject.SetActive(true); warningImageLocation[2].transform.GetChild(0).GetComponent <Image>().sprite = eventImage[1]; //Run the event launcher warningImageLocation[2].BroadcastMessage("RunEvent", true, SendMessageOptions.DontRequireReceiver); spawnLocation[2].GetComponent <Event_Spawner>().SpawnEvent(true, currentEventType, currentEventDirection, spawnDelayTimer); break; } case Event_.EventDirection.BOTTOM: { warningImageLocation[3].gameObject.SetActive(true); warningImageLocation[3].transform.GetChild(0).GetComponent <Image>().sprite = eventImage[1]; //Run the event launcher warningImageLocation[3].BroadcastMessage("RunEvent", true, SendMessageOptions.DontRequireReceiver); spawnLocation[3].GetComponent <Event_Spawner>().SpawnEvent(true, currentEventType, currentEventDirection, spawnDelayTimer); break; } default: break; } break; default: break; } //Debug.Log("<color=white> "+ "Current Event: "+ activeEvent.type + " : " + activeEvent.direction + " </color>"); activeEvent.BeenUsed = true; } else if (activeEvent.BeenUsed) { countOfUsed++; } //Stop the timer when all events have been used if (countOfUsed >= events.Count) { runEventTimer = false; //Debug.Log("<color=white>Stopped the event timer.</color>"); } } //Reset count after each pass countOfUsed = 0; } else { } if (!endOfEvent) { int maxValue; maxValue = Convert.ToInt32("100"); int currentValue; //currentValue = Convert.ToInt32(progressText.text); int.TryParse(progressText.text, out currentValue); if (currentValue >= maxValue) { endOfEvent = true; } } //warningImage[0].transform.position; }