private void Update() { if (!mainMenu) { float ratio = (float)(RedCell.allRedCells.Count - 50) / (float)(108 - 50); hpBar.fillAmount = ratio; ratio = (float)Bacteria.allBact.Count / 300f; infectionBar.fillAmount = ratio; redCellCounter.text = "Until critical: " + (RedCell.allRedCells.Count - 50 < 0 ? 0 : RedCell.allRedCells.Count - 50).ToString(); bacteriaCounter.text = "Infection: " + Mathf.Round(ratio * 100) + "%"; bool bodiesReady = antibodyMeterCount >= ANTIBODY_MAX; antibodiesMessage.SetActive(bodiesReady); if (bodiesReady && Input.GetKeyDown(KeyCode.Space)) { antibodyMeterCount = 0; WhiteCell.DeployAntibodies(antibody); antibodyMeter.fillAmount = (float)antibodyMeterCount / (float)ANTIBODY_MAX; } startTimer -= Time.deltaTime * 0.2f; if (RedCell.allRedCells.Count <= 50 && !stopped && startTimer <= 0) { stopped = true; StartCoroutine(EndSequence(false)); //Time.timeScale = 0; } if (Bacteria.allBact.Count <= 0 && !stopped && startTimer <= 0) { stopped = true; StartCoroutine(EndSequence(true)); //Time.timeScale = 0; } } }
/// <summary> /// Randomly spawns NUMBER_OF_ARROWS_TO_SPAWN arrows and adds them to the vehicles list /// </summary> void Start() { // Initialize Viruses for (int i = 0; i < NUMBER_OF_VIRUSES_TO_SPAWN; i++) { float spawnY = Random.Range (Camera.main.ScreenToWorldPoint(new Vector2(0, 0)).y, Camera.main.ScreenToWorldPoint(new Vector2(0, Screen.height)).y); float spawnX = Random.Range (Camera.main.ScreenToWorldPoint(new Vector2(0, 0)).x, Camera.main.ScreenToWorldPoint(new Vector2(Screen.width, 0)).x); Vector2 spawnPosition = new Vector2(spawnX, spawnY); Virus virus = Instantiate <Virus>(virusPrefab, spawnPosition, Quaternion.identity); virus.Init(); viruses.Add(virus); } // Initialize White Cells for (int i = 0; i < NUMBER_OF_WHITE_CELLS_TO_SPAWN; i++) { float spawnY = Random.Range (Camera.main.ScreenToWorldPoint(new Vector2(0, 0)).y, Camera.main.ScreenToWorldPoint(new Vector2(0, Screen.height)).y); float spawnX = Random.Range (Camera.main.ScreenToWorldPoint(new Vector2(0, 0)).x, Camera.main.ScreenToWorldPoint(new Vector2(Screen.width, 0)).x); Vector2 spawnPosition = new Vector2(spawnX, spawnY); WhiteCell whiteCell = Instantiate <WhiteCell>(whiteCellPrefab, spawnPosition, Quaternion.identity); whiteCell.Init(); whiteCells.Add(whiteCell); } // Initialize the player controlled WhiteCell player.Init(); }
public void createCell() { //choose a position int index = Random.Range(0, Generators.transform.childCount); Vector3 pos = Generators.transform.GetChild(index).transform.position; //create cell WhiteCell c = WhiteCell.Instantiate(celluleBlanchePrefab); c.transform.SetParent(CellulesBlanches.transform, false); c.transform.position = pos; }