public Bacteria CreateBacterium(float posX, float posZ, bool randomRot) { GameObject bact = Instantiate(bacteria, new Vector3(posX, 0, posZ), randomRot? Quaternion.Euler(0, Random.Range(0, 360), 0):Quaternion.identity, GameObject.FindGameObjectWithTag("Bacterias").transform); Bacteria component = bact.GetComponent <Bacteria>(); component.CalculateCluster(); return(component); }
private void InstantiateBacterium() { GameObject bact = Instantiate(BacteriaPrefab, PlayerModel.transform.position, PlayerModel.transform.rotation, GameObject.FindGameObjectWithTag("Bacterias").transform); Bacteria component = bact.GetComponent <Bacteria>(); component.CalculateCluster(); Debug.LogWarning("Added to a cluster with " + component.Cluster.Count + " elements."); }
private void RecalculateHealthMultiplier() { int numberOfBacteriaInProximity = 0; int n = Bacteria.AllBacteria.Count; for (var i = 0; i < n; i++) { Bacteria otherBacteria = Bacteria.AllBacteria[i]; if (otherBacteria == null) { continue; } if (otherBacteria != this && Vector3.Distance(transform.position, otherBacteria.transform.position) < 1.5f) { numberOfBacteriaInProximity++; } } _healthMultiplier = 1f + numberOfBacteriaInProximity * 0.2f; }