/// <summary> /// Check collisions with any Dot, BigDot and Ghost (Death hitbox) /// </summary> /// <param name="other"></param> private void OnTriggerEnter(Collider other) { if (other != null) { if (other.gameObject.CompareTag("Dot")) { Dot currentDot = other.gameObject.GetComponent <Dot>(); dotsEaten++; } if (other.gameObject.CompareTag("BigDot")) { BigDot currentBigDot = other.gameObject.GetComponent <BigDot>(); bigDotsEaten++; godmode = true; godmodeTimer = godmodeTime; } if (other.gameObject.CompareTag("Death")) { if (godmode) { Kill(other.gameObject.GetComponentInParent <Ghost>()); } else { Die(); Respawn(); } } } }
public bool initBigDots() { string[] lines = System.IO.File.ReadAllLines("Assets/Data/map.txt"); for (int y = 0; y < lines.Length; y++) { char[] line = lines[y].ToCharArray(); for (int x = 0; x < line.Length; x++) { if (line[x] == 'o') { BigDot dot = GameObject.Instantiate(LargeDotPrefab).GetComponent <BigDot>(); dot.SetPosition(new Vector2((x - (line.Length / 2)) * 22 + 11, (-y + (lines.Length / 2)) * 22)); dotCount++; } } } return(true); }