void OnCollisionEnter2D(Collision2D other) { MoveWithInput player = other.gameObject.GetComponent <MoveWithInput>(); if (player != null) { player.ChangeHealth(-1); } }
void OnTriggerEnter2D(Collider2D other) { MoveWithInput controller = other.GetComponent <MoveWithInput>(); if (controller != null) { if (controller.currentHealth < controller.maxHealth) { controller.ChangeHealth(1); Destroy(gameObject); } } }
void OnTriggerEnter2D(Collider2D otherP) { MoveWithInput controller = otherP.GetComponent <MoveWithInput>(); if (controller != null) { if (ShouldConsumePill(controller)) { ConsumePill(controller); PillPusher.PushPill(transform.position); Destroy(gameObject); } } }
protected override void ConsumePill(MoveWithInput controller) { controller.Consume(this); }
protected override bool ShouldConsumePill(MoveWithInput controller) { return(true); }
protected override bool ShouldConsumePill(MoveWithInput controller) { return(controller.currentPill < controller.maxPill); }
protected override void ConsumePill(MoveWithInput controller) { controller.ChangePill(1); }
private void Start() { _moveScript = GetComponent <MoveWithInput>(); _rotateScript = GetComponent <RotateWithInput>(); }
protected abstract void ConsumePill(MoveWithInput controller);
protected abstract bool ShouldConsumePill(MoveWithInput controller);