public void CheckLoss(WhiteBloodCell wbc) { if (player.GetComponent <PlayerTemp> ().currentWhiteBloodCellCount > 150000) { gameOverEvent.Invoke(false); } }
public void SpawnWhiteBloodCell() { GameObject newWhite = (GameObject)Instantiate(whiteBloodCellPrefab, whiteBloodSpawnPoint.GetRandomPoint(), this.transform.rotation); WhiteBloodCell newWhiteScript = newWhite.GetComponent <WhiteBloodCell> (); newWhiteScript.currentBlock = whiteBloodSpawnPoint; newWhiteScript.destination = whiteBloodSpawnPoint.GetRandomPoint(); newWhiteScript.gameControl = this; if (toggleWBC) { newWhiteScript.renderer.enabled = false; } whiteBloodCells.Add(newWhite.GetComponent <WhiteBloodCell>()); }
// Block clicked. Send selected WhiteBloodCell here public void OnMouseOver() { showStats = true; if (dead) { return; } //Quit out if not a right click if (!Input.GetMouseButtonDown(1)) { return; } mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); foreach (GameObject obj in gameControl.selected) { if (obj.tag == "WhiteBloodCell") { WhiteBloodCell cell = obj.GetComponent <WhiteBloodCell> (); //cell.renderer.material.color = Color.white; //cell.isSelected = false; cell.SetDestination(this, mousePos); gameControl.isSelected = true; } else if (obj.tag == "Platelet") { Platelets plate = obj.GetComponent <Platelets> (); //plate.renderer.material.color = Color.yellow; //plate.isSelected = false; plate.SetDestination(this, mousePos); gameControl.isSelected = true; } } StartCoroutine(FireMouseClick()); //gameControl.selected.Clear(); }
void Update() { if (Input.GetKeyDown(KeyCode.F8)) { rngManager.SpawnDiseaseInfection(); } if (IsPaused() || showMenu || upgradeMenuOpen || tutorial.StopGameLogic()) { rngManager.isDisabled = true; } else { rngManager.isDisabled = false; } if (Input.GetKeyDown(KeyCode.Space)) { TogglePauseGame(); showMenu = false; isPause = !isPause; } if (tutorial.StopGameLogic()) { return; } if (Input.GetKeyDown(KeyCode.Escape)) { TogglePauseGame(); if (isPaused) { showMenu = true; } else { showMenu = false; } } if (Input.GetKeyDown(KeyCode.Z)) { TogglePauseGame(); showMenu = false; if (!upgradeMenuOpen) { upgradeMenu.SetActive(true); upgradeMenuOpen = true; } else { upgradeMenu.SetActive(false); upgradeMenuOpen = false; } } if (IsPaused()) { return; } if (Input.GetKeyDown(KeyCode.B)) { toggleRBC = !toggleRBC; Debug.Log("KeyDown!"); changed = false; } if (Input.GetKeyDown(KeyCode.V)) { toggleWBC = !toggleWBC; wbcChanged = false; } // Restore Energy if (energy < MAX_ENERGY) { energy += (ENERGY_RESTORE_PER_SECOND - rbcSpeed) * Time.deltaTime; if (energy < 0) { energy = 0; } } // Check lose condition if (checkLoseCondition()) { StartCoroutine(Lose()); } // Check win condition if (levelProgress >= levelDistance) { StartCoroutine(Win()); } else { levelProgressSpeed = calcLevelProgressSpeed(); levelProgress += levelProgressSpeed * Time.deltaTime; } if (whiteBloodCells != null) { //foreach (WhiteBloodCell cell in whiteBloodCells) { for (int i = 0; i < whiteBloodCells.Count; i++) { WhiteBloodCell cell = (WhiteBloodCell)(whiteBloodCells[i]); if (cell.destroyMe) { Debug.Log("deleting white blood cell..."); //whiteBloodCells.Remove (cell); selected.Remove(cell.gameObject); Destroy(((WhiteBloodCell)(whiteBloodCells[i])).gameObject, 2); whiteBloodCells.RemoveAt(i); //foodLevel += WHITE_BLOOD_CELL_FOOD_RATE * 0.8f; i--; } } wbcChanged = true; } /* * if (liveRBCs < 2 * numRBCs) { * int diff = 2 * numRBCs - liveRBCs; * for (int i = 0; i < diff; i++) { * Vector3 randpt = redBloodSpawnPoint.GetRandomPoint(); * GameObject newRBC = (GameObject)Instantiate (redBloodCellPrefab, new Vector3(randpt.x, randpt.y, 1.0f) , this.transform.rotation); * RedBloodScript newRedScript = newRBC.GetComponent<RedBloodScript> (); * newRBC.renderer.transform.localScale = new Vector3(.1f,.1f,.1f); * newRedScript.currentBlock = redBloodSpawnPoint; * newRedScript.destination = redBloodSpawnPoint.GetRandomPoint (); * newRedScript.origBlock = body.GetBodyPart((diff - i) / (numRBCs / body.blocks.Count)); * newRedScript.destBlock = newRedScript.origBlock; * newRedScript.heartBlock = body.GetChest (); * newRedScript.gameControl = this; * newRedScript.spawnTime = Time.time; * } * liveRBCs += diff; * } */ }
public void OnHitByWhiteCell(WhiteBloodCell cell) { currentWhiteBloodCellCount++; hitByWhiteCellEvent.Invoke(cell); hitAudio.Play(); }