// Update is called once per frame void Update() { SceneVars sv = go.GetComponent <SceneVars>(); OverallHealth = ((100f - sv.PCDead) / 100); OverallBar.fillAmount = OverallHealth; }
void OnTriggerEnter2D(Collider2D other) // change to OnCollisionEnter { SceneVars sv = go.GetComponent <SceneVars>(); ChangeDirection = true; if (IsDead == false && other.GetComponent <Movement>().Infected == true && Infected == false && Immune == false) // set infected { int OurInfectLevel = sv.InfectionProb; int OtherInfectLevel = sv.InfectionProb; if (other.GetComponent <Movement>().Mask == true) { OurInfectLevel = -sv.PCMaskTransmit; } if (Mask == true) { OurInfectLevel = -sv.PCMaskInfect; } Random rnd = new Random(); if (Random.Range(0, 100) < OurInfectLevel) { BecomeInfected(); other.GetComponent <Movement>().TotalTimesSpread++; other.GetComponent <Movement>().RunningTotalTimesSpread++; //Debug.Log("Transmission!"); } } if (other.GetComponent <Movement>().IsDead == true) { ChangeDirection = false; } }
// Start is called before the first frame update void Start() { GameObject go = GameObject.Find("Scores"); SceneVars sv = go.GetComponent <SceneVars>(); exampleText = GetComponent <Text>(); ExampleScore = 0; }
// Start is called before the first frame update void Start() { Random rnd = new Random(); GameObject go = GameObject.Find("Scores"); SceneVars sv = go.GetComponent <SceneVars>(); int TotalBlobs = sv.TotalBlobs; GameObject PrefabChoice; for (int i = 0; i < TotalBlobs; i++) { sv.TotalAlive++; if (Random.Range(0, 100) < sv.PCSD) { PrefabChoice = myPrefabSD; } else { PrefabChoice = myPrefab; } //GameObject NewObject = Instantiate(PrefabChoice, new Vector3(Random.Range(sv.xOrigin, sv.xSize), Random.Range(sv.yOrigin, sv.ySize), 0), Quaternion.identity); sv.Cells.Add(Instantiate(PrefabChoice, new Vector3(Random.Range(sv.xOrigin, sv.xSize), Random.Range(sv.yOrigin, sv.ySize), 0), Quaternion.identity)); sv.Cells[i].GetComponent <Movement>().xDirection = Random.Range(-1f, 1f); sv.Cells[i].GetComponent <Movement>().yDirection = Random.Range(-1f, 1f); sv.Cells[i].GetComponent <Movement>().BlobHealth = Random.Range(10, 101); //NewObject.transform.localScale = new Vector3(sv.BlobScale, sv.BlobScale, sv.BlobScale); sv.TotalNeverInfected++; if (Random.Range(0, 100) < sv.PCInfected) { //Debug.Log("Set infect on init"); sv.Cells[i].GetComponent <Movement>().Infected = true; sv.Cells[i].GetComponent <Movement>().TickRecovered = sv.CurrentTick + Random.Range(1, (sv.RecoveryPeriod + 1)); //pre existing infection sv.TotalInfected++; sv.TotalNeverInfected--; } if (Random.Range(0, 100) < sv.PCMasks) { sv.Cells[i].GetComponent <Movement>().Mask = true; } else { sv.Cells[i].GetComponent <Movement>().Mask = false; } if (Random.Range(0, 100) < sv.PCSelfIsolating) { sv.Cells[i].GetComponent <Movement>().SelfIsolating = true; } else { sv.Cells[i].GetComponent <Movement>().SelfIsolating = false; } } }
// Start is called before the first frame update void Start() { NewObject = Instantiate(bar, new Vector3(5f, 8.5f, 0), Quaternion.Euler(-90, 0, 0)); GameObject go = GameObject.Find("Scores"); SceneVars sv = go.GetComponent <SceneVars>(); TempLength = 1; }
// Update is called once per frame void Update() { SceneVars sv = go.GetComponent <SceneVars>(); int barLength = sv.TotalBlobs - sv.TotalDead; //Debug.Log(barLength); barScale = (float)barLength / (float)sv.TotalBlobs; TempLength = TempLength - 0.01f; NewObject.transform.localScale = new Vector3(barScale, 1, 1); NewObject.transform.position = new Vector3(5f - (barScale / 2), 8.5f, 0); }
void BecomeInfected() { SceneVars sv = go.GetComponent <SceneVars>(); Infected = true; Infectious = true; sv.TotalInfected++; TotalTimesInfected++; TickRecovered = sv.CurrentTick + sv.RecoveryPeriod; NextHealthCheck = sv.CurrentTick + 1; TickUninfectious = sv.CurrentTick + sv.InfectiousPeriod; }
void SetDead() { SceneVars sv = go.GetComponent <SceneVars>(); IsDead = true; Infected = false; Infectious = false; sv.TotalAlive--; sv.TotalDead++; sv.TotalInfected--; sv.TotalNeverInfected--; BlobHealth = 0; }
void Start() { if (Infected) { Infected = true; } Random.seed = BlobSeed; rb = GetComponent <Rigidbody>(); go = GameObject.Find("Scores"); SceneVars sv = go.GetComponent <SceneVars>(); NextRefinfectDay = sv.CurrentTick + sv.DelayReinfect; NextSReinfectDayCheck = sv.CurrentTick + 1; ShowInfect = Instantiate(InfectPart, transform.position, Quaternion.identity); ShowInfect.GetComponent <ParticleSystem>().Play(); ShowInfect.transform.parent = gameObject.transform; }
//---------------------------------------------------------------------MONO METHODS: void Start() { anim = anim.GetComponent <Animator>(); anim.SetBool("Fade", false); Fill = ScareBar.transform.Find("Fill Area").Find("Fill").GetComponent <Image>(); Bar.value = ScareMeterValue; Bar.maxValue = ScareMeterValue; maxScareMeterValue = ScareMeterValue; today = GameDay; tempDayEnds = DayEnds; tempDayStart = DayStart; RealTimePerDay *= 60; tempRealTimePerDay = RealTimePerDay; day = true; GameClock = DayStart; sceneVars = GameObject.FindObjectOfType <SceneVars>(); }
//---------------------------------------------------------------------MONO METHODS: void Start() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } DontDestroyOnLoad(gameObject); numOfCharacters = GameObject.FindGameObjectsWithTag("Characters").Length; characters = new GameObject[numOfCharacters]; ShinningCharacters = new CharacterValues[numOfCharacters]; characters = GameObject.FindGameObjectsWithTag("Characters"); StartCoroutine(test()); }
void Update() { SceneVars sv = go.GetComponent <SceneVars>(); var mesh = new Mesh(); mesh.name = "My lines"; mesh.vertices = new Vector3[] { new Vector3((sv.TotalInfected / 10), 0, 0), new Vector3(2, 0, 0), new Vector3(0, 0, 0), new Vector3(0, 2, 0), new Vector3(0, 2, 0), new Vector3(2, 2, 0), }; mesh.colors = new Color[] { Color.red, Color.red, Color.blue, Color.blue, Color.green, Color.yellow }; mesh.SetIndices(new int[] { 0, 1, 2, 3, 4, 5 }, MeshTopology.Lines, 0, true); GetComponent <MeshFilter>().sharedMesh = mesh; }
//---------------------------------------------------------------------MONO METHODS: void Start() { charAnim = GetComponentInChildren <Animator>(); add = false; moving = true; insanityHits = InsanityThresholds; Agent = GetComponent <NavMeshAgent>(); Agent.speed = CharacterSpeed; sceneVars = GameObject.FindObjectOfType <SceneVars>(); if (sceneVars.ShinningCharacters != null && UnityEngine.SceneManagement.SceneManager.GetActiveScene().name != "Hotel") { Debug.Log("Day two, it came here"); foreach (var characters in sceneVars.ShinningCharacters) { if (characters.Character == transform.gameObject.name) { InsanityValue = characters.InsanityValue; endDestination = CharacterMovement[InsanityValue].PatrolOnThisInsanityLevel[0].Room; } } } else { endDestination = CharacterMovement[0].PatrolOnThisInsanityLevel[0].Room; } //set up of character status bars CharFill = CharBar.transform.Find("Fill Area").Find("Fill").GetComponent <Image>(); CharSlider.value = InsanityValue * InsanityThresholds + (InsanityThresholds - insanityHits); CharSlider.maxValue = InsanityThresholds * TotalInsanityValue; //UpdateStatus(); }
// Update is called once per frame void Update() { int x = 1; SceneVars sv = go.GetComponent <SceneVars>(); exampleText = GetComponent <Text>(); string DayText = "Current Day: " + sv.CurrentDay + "\n"; string AliveText = "Total alive: " + sv.TotalAlive + "\n"; double RoundedPCInfected = System.Math.Round(sv.PCInfectedCurrent, 1); string PCInfected = "Percent infected: " + RoundedPCInfected + "\n"; string NLockdown; if (sv.SelfIsolationTimes == 0) { NLockdown = "Next lockdown: " + "NA" + "\n"; } else { NLockdown = "Next lockdown: " + (int)sv.NextLockdownDay + "\n"; } double RoundedPCDead = System.Math.Round(sv.PCDead, 1); string DeadText = "Percentage dead: " + RoundedPCDead + "%" + "\n"; double RoundedPCHighInfected = System.Math.Round(sv.PCHighInfected, 1); string HighInfected = "High infected: " + RoundedPCHighInfected + "%" + "\n"; double R0 = System.Math.Round(sv.AverageR0, 2); string R0Number = "R0: " + R0 + "%" + "\n"; string HighText = "High infected: " + sv.HighInfections + "\n"; exampleText.text = DayText + PCInfected + HighInfected + R0Number + AliveText + DeadText + HighText + NLockdown + AliveText; }
// Update is called once per frame void Update() { SceneVars sv = go.GetComponent <SceneVars>(); float BoxXSize = sv.xSize; float BoxYSize = sv.ySize; float BoxXStart = sv.xOrigin; float BoxYStart = sv.yOrigin; int ChangeChance; //set colours float HealthDiv = BlobHealth / 100; //particle code if (Infected == true) { ShowInfect.GetComponent <ParticleSystem>().enableEmission = true; } else { ShowInfect.GetComponent <ParticleSystem>().enableEmission = false; } //ShowInfect.transform.position=transform.position; float BallSpeed = 0.7f; Random rnd = new Random(); Vector3 PersonPosition = transform.position; if (PersonPosition.x > BoxXSize) { xDirection = xDirection - 0.7f; } if (PersonPosition.x < BoxXStart) { xDirection = xDirection + 0.7f; } if (PersonPosition.y > BoxYSize) { yDirection = yDirection - 0.7f; } if (PersonPosition.y < BoxYStart) { yDirection = yDirection + 0.7f; } float ChangeAmount = 0.3f; ChangeChance = Random.Range(1, 6); if (IsSDBlocked) { //ChangeChance = 1; //ChangeAmount = 0.1f; IsSDBlockedTimer = sv.CurrentTick + 1; } if (Random.Range(1, 5) == 1 || IsSDBlocked) { if (ChangeChance == 1) { xDirection = xDirection + ChangeAmount; } if (ChangeChance == 2) { xDirection = xDirection - ChangeAmount; } } if (Random.Range(1, 5) == 1 || IsSDBlocked) { if (ChangeChance == 1) { yDirection = yDirection + ChangeAmount; } if (ChangeChance == 2) { yDirection = yDirection - ChangeAmount; } } ChangeDirection = false; if (xDirection > 1) { xDirection = 1; } if (yDirection > 1) { yDirection = 1; } if (xDirection < -1) { xDirection = -1; } if (yDirection < -1) { yDirection = -1; } PersonPosition.x += (BallSpeed * xDirection * Time.deltaTime); PersonPosition.y += (BallSpeed * yDirection * Time.deltaTime); //immobilize blob Immobile = false; if (SelfIsolating == true && sv.SelfIsolationNow == true) { Immobile = true; } if (IsDead == true) { Immobile = true; } //perform movement if (Immobile == false) { transform.position = PersonPosition; } IsSDBlocked = false; //Monitor infection if (Infected == true && sv.CurrentTick > TickRecovered) //recovered - set immune { Infected = false; Immune = true; sv.TotalInfected--; sv.TotalImmune++; ImmuneExpires = sv.CurrentTick + sv.ImmunityPeriod; // BlobHealth = ((BlobHealth / 100f) * 66f); } //Apply period reinfection chance if (sv.CurrentTick > NextRefinfectDay) { if (Random.Range(0, 100) < sv.PCDelayedReinfect && Infected == false) { sv.Reinfection = true; BecomeInfected(); } NextRefinfectDay = sv.CurrentTick + sv.DelayReinfect; } //Apply constant spontaneous reinfection chance if (sv.CurrentTick > NextSReinfectDayCheck) { if (Random.Range(0, 10000) < sv.SInfectionCh10000 && Immune == false && Infected == false) { BecomeInfected(); sv.Reinfection = true; } NextSReinfectDayCheck++; } //Apply damage if (Infected == true && sv.CurrentTick > NextHealthCheck && IsDead == false) { BlobHealth = BlobHealth - 15f / (BlobHealth / 2); NextHealthCheck++; } //Kill blob if (BlobHealth < 1 && IsDead == false) { SetDead(); } //monitor immunity if (sv.CurrentTick > ImmuneExpires && Immune == true) { Immune = false; sv.TotalImmune--; } //monitor infectiousness if (sv.CurrentTick > TickUninfectious) { Infectious = false; } }
// Start is called before the first frame update void Start() { GameObject go = GameObject.Find("Scores"); SceneVars sv = go.GetComponent <SceneVars>(); }
// Update is called once per frame void Update() { SceneVars sv = scores.GetComponent <SceneVars>(); int CurrentX = 0; int i, j, k, l, m, n; int graphLength = 1024; float CounterIncrement; CounterIncrement = 1 * (Time.deltaTime * 10); CounterIncrement = CounterIncrement * multiplier; CurrentX = (int)XCounter; if (sv.GameEnd == true) { CounterIncrement = 0; } XCounter = XCounter + CounterIncrement; graphScale = sv.TotalBlobs / graphHeight; graphScale = 2; GetComponent <Renderer>().material.mainTexture = texture; if (CurrentX > 1024) // Scale graph when end reached { Color pixel; for (i = 1; i < graphLength; i += 2) { for (j = 1; j < graphHeight; j++) { pixel = texture.GetPixel(i, j); texture.SetPixel(i / 2, j, pixel); } } for (i = (graphLength / 2); i < 1024; i++) // Clean 50% of background { for (j = 0; j < graphHeight; j++) { texture.SetPixel(i, j, Color.white); } } next100Day++; next100Day = next100Day * 2; XCounter = 512; EndCounter++; multiplier = multiplier / 2f; } /*if (sv.CurrentDay % 10 == 0) // draw grey ten day bar * { * for (i = 0; i < graphHeight; i++) //draw bar * { * texture.SetPixel(CurrentX, i, new Color(0.7f, 0.7f, 0.7f, 1)); * * } * }*/ if (sv.SelfIsolationNow) // draw grey ten day bar { for (i = 0; i < graphHeight; i++) //draw bar { texture.SetPixel(CurrentX, i, new Color(0.5f, 0.5f, 0.5f, 1)); } } for (i = CurrentX - 1; i < 1024; i++) //dead high line { texture.SetPixel(i, OldDeadHigh / graphScale, Color.white); } for (i = CurrentX; i < 1024; i++) { texture.SetPixel(i, sv.HighInfections / graphScale, Color.red); } OldDeadHigh = sv.HighInfections; for (k = 0; k < graphHeight / 10; k++) // horizontal lines { for (l = 0; l < 1024; l++) { texture.SetPixel(l, k * 10, Color.black); } } for (i = 0; i < (int)(sv.TotalImmune); i++) // draw immune { texture.SetPixel(CurrentX, i / graphScale, Color.blue); } for (i = 0; i < (int)(sv.TotalDead); i++) //draw dead { texture.SetPixel(CurrentX, i / graphScale, Color.black); } for (i = 0; i < (int)(sv.TotalInfected); i++) //draw infection { texture.SetPixel(CurrentX, i / graphScale, Color.red); } if (sv.Reinfection) { for (i = 0; i < graphHeight; i++) //draw bar { texture.SetPixel(CurrentX, i, new Color(1, 0, 0, 1)); texture.SetPixel(CurrentX + 1, i, new Color(1, 0, 0, 1)); sv.Reinfection = false; } } texture.SetPixel(CurrentX, sv.TotalDead / graphScale, Color.black); texture.SetPixel(CurrentX, sv.TotalImmune / graphScale, Color.blue); texture.Apply(); }