private void OnTriggerExit2D(Collider2D collision) { if (collision.CompareTag("SpaceshipPart")) { Debug.Log("UnCollided with SpaceshipPart"); diggablePart = null; } if (collision.CompareTag("EnemyAim")) { aim = null; } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.CompareTag("SpaceshipPart")) { Debug.Log("Collided with SpaceshipPart"); diggablePart = collision.GetComponent <SpaceshipPart>(); } if (collision.CompareTag("EnemyAim")) { aim = collision.GetComponent <EnemyAim>(); } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.CompareTag("Player")) { Debug.Log("Player collided with collect hitbox"); SpaceshipPart parent = transform.parent.gameObject.GetComponent <SpaceshipPart>(); Player player = collision.gameObject.GetComponent <Player>(); parent.Collect(player); } }
private void OnTriggerEnter2D(Collider2D collision) { //Return parts to ship if (collision.CompareTag("Player")) { Player player = collision.GetComponent <Player>(); player.Dazzle(); if (aIDestinationSetter.targetType == TargetType.Player) { GetNewTarget(TargetType.Spaceship); } Debug.Log("Collided with player"); // TODO: set player dazzle or something like that? } else if (collision.CompareTag("Spaceship") && !holdsPart && aIDestinationSetter.targetType == TargetType.Spaceship) { // Debug.Log("Collided with spaceship"); Spaceship spaceship = collision.GetComponent <Spaceship>(); spaceship.StealPart(); holdsPart = true; GetNewTarget(TargetType.EnemyAim); // TODO: remove spaceship part } else if (collision.CompareTag("EnemyAim") && holdsPart) { // Debug.Log("Collided with EnemyAim"); EnemyAim aim = collision.GetComponent <EnemyAim>(); if (holdsPart) { aim.AddSpaceshipPart(); holdsPart = false; SpaceshipPart newPart = Instantiate(_part, aim.transform.position, Quaternion.identity); newPart.DigIn(); } isWaiting = true; StartCoroutine(WaitForNextSteal()); } else if (collision.CompareTag("Enemy")) { // GameObject otherEnemy = collision.gameObject; // TODO: maybe find some sort of avoidance? StartCoroutine(CheckIfStuck()); } else { // Debug.LogWarning("Collided with " + collision); } }