public override void Initalise() { m_transform = transform; playerScript = GameObject.Find("Player").GetComponent <Player>(); currentColor = startColor; //This sometimes causes null ref excepts currentMass = playerScript.GetCurrentMass(); m_transform.localScale = new Vector3(currentMass / 12f, currentMass / 12f, 1f); speed = 25f / currentMass; int colorChoice = Random.Range(1, 4); switch (colorChoice) { case (1): selfColor = ImmunityColour.BLUE; currentColor = Color.blue; break; case (2): selfColor = ImmunityColour.GREEN; currentColor = Color.green; break; case (3): selfColor = ImmunityColour.RED; currentColor = Color.red; break; } ; ApplyCurrentColor(); FindNewHeading(); }
void OnCollisionEnter2D(Collision2D col) { immuColor = ColorCalculator.GetDominantColour(currentColor); if (col.gameObject.CompareTag("Virus")) { ImmunityColour virusColor = col.gameObject.GetComponent <VirusV2>().GetColor(); if (virusColor != immuColor) { switch (virusColor) { case (ImmunityColour.BLUE): ActivateEffect(PickUpType.SlowDown, 5.0f); virusHit = Instantiate(blue, transform.position, transform.rotation) as GameObject; break; case (ImmunityColour.GREEN): ActivateEffect(PickUpType.DontEat, 5.0f); virusHit = Instantiate(green, transform.position, transform.rotation) as GameObject; break; case (ImmunityColour.RED): ActivateEffect(PickUpType.LoseMass, 1.0f); virusHit = Instantiate(red, transform.position, transform.rotation) as GameObject; break; } } else { //Do nothing } col.gameObject.SetActive(false); } if (canEat) { CheckEating(col.collider); } }
public override void Initalise() { currentColor = startColor; currentMass = GameObject.FindGameObjectWithTag("Player").GetComponent <Player>().GetCurrentMass(); int choice = Random.Range(1, 3); switch (choice) { case (1): selfColor = ImmunityColour.BLUE; break; case (2): selfColor = ImmunityColour.GREEN; break; case (3): selfColor = ImmunityColour.RED; break; } }