public void startPlayers(bool start = true, bool death = false) { // All players foreach (PlayerController player in players) { // Get HP controller HitpointController hitpointController = player.GetComponent <HitpointController> (); // Heal (if start) if (start) { hitpointController.heal(); } // Update death status (if death) if (death) { hitpointController.isDead = !start; } // Update status player.stop = !start; player.isReady = start; } }
void OnTriggerEnter2D(Collider2D other) { if (hitpointController.isDead) { return; } // Reverse moving if hit bullets if (other.CompareTag("Bullet")) { moveSpeed *= -1f; } // Get edge EdgeController edgeController = other.GetComponent <EdgeController> (); // If hit edge with edge controller if (other.CompareTag("Edge") && edgeController) { moveSpeed = edgeController.changeSpeed(moveSpeed); } // Collect if hit item if (other.tag == "Item") { // Item name Item item = other.GetComponent <Item> (); if (item.type == "Star") { stars += item.amount; } if (item.type == "Diamond") { diamonds += item.amount; } if (item.type == "Hitpoint") { hitpointController.heal(item.amount); } // Update UI updateResources(); // Destroy item Destroy(other.gameObject); } }