private void HitSelfReaction(GameObject target, Constants.HitDirection dir, bool isHitInside) { if (target.tag == Constants.TagNames.Player) { IsHit(target.transform.root.gameObject, dir); return; } if (isHitInside && dir == Constants.HitDirection.Bottom && target.tag == Constants.TagNames.Brick) { HitDie(); return; } // Return when hit wall switch (direction) { case Constants.EnemyMoveDireciton.Left: if (dir == Constants.HitDirection.Right) { direction = Constants.EnemyMoveDireciton.Right; velocity.x = moveSpeed; transform.localScale = new Vector3(-1f, transform.localScale.y, transform.localScale.z); } break; case Constants.EnemyMoveDireciton.Right: if (dir == Constants.HitDirection.Left) { direction = Constants.EnemyMoveDireciton.Left; velocity.x = -moveSpeed; transform.localScale = new Vector3(1f, transform.localScale.y, transform.localScale.z); } break; case Constants.EnemyMoveDireciton.Up: if (dir == Constants.HitDirection.Bottom) { direction = Constants.EnemyMoveDireciton.Down; velocity.y = -moveSpeed; } break; case Constants.EnemyMoveDireciton.Down: if (dir == Constants.HitDirection.Top) { direction = Constants.EnemyMoveDireciton.Up; velocity.y = moveSpeed; } break; default: Debug.LogErrorFormat("Enemy {0} move direction error!", gameObject); break; } }
public void IsHit(GameObject source, Constants.HitDirection from) { PlayerController player = source.GetComponent <PlayerController>(); if (player != null) { gameManager.AddScore(1000); player.ChangeToBig(); Destroy(gameObject); } }
public void IsHit(GameObject source, Constants.HitDirection from) { PlayerController player = source.GetComponent <PlayerController>(); if (player == null) { return; } animator.SetTrigger(isFinishedHash); player.LevelFinish(); }
public void IsHit(GameObject source, Constants.HitDirection from) { PlayerController playerController = source.GetComponent <PlayerController>(); if (playerController != null) { playerController.Die(); } else { Destroy(source); } }
private void HitSelfReaction(GameObject target, Constants.HitDirection dir, bool isHitInside) { if (target.tag == Constants.TagNames.Player) { IsHit(target.transform.root.gameObject, dir); return; } if ((isMovingRight && dir == Constants.HitDirection.Left) || (!isMovingRight && dir == Constants.HitDirection.Right)) { isMovingRight = !isMovingRight; transform.localScale = new Vector3(-transform.localScale.x, transform.localScale.y, transform.localScale.z); } }
private void Hit(GameObject target, Constants.HitDirection dir, bool isHitInside) { // Hit self reaction if (hitEvent != null) { hitEvent(target, dir, isHitInside); } // Hit notify the other IInteractableObject interactableObj = target.GetComponentRecursiveUp <IInteractableObject>(); if (interactableObj != null) { //Debug.LogFormat("Object: {2}, Hit: {0}, From: {1}", target.name, dir, gameObject.name); interactableObj.IsHit(gameObject, dir); } }
public void IsHit(GameObject source, Constants.HitDirection from) { PlayerController player = source.GetComponent <PlayerController>(); if (player != null) { if (from == Constants.HitDirection.Top) { player.BounceUponEnemy(); TreadDie(); } else { // Kill Player Debug.LogFormat("Enemy: {0} Kill Player", gameObject.name); player.HitByEnemy(); } } }
public void IsHit(GameObject source, Constants.HitDirection from) { if (from == Constants.HitDirection.Bottom) { if (coinNum < 1) { return; } coinNum--; gameManager.AddCoin(1); gameManager.AddScore(200); animator.SetTrigger(hitHash); if (coinNum < 1) { animator.SetBool(deadHash, true); } } }
public void IsHit(GameObject source, Constants.HitDirection from) { PlayerController player = source.GetComponent <PlayerController>(); if (player == null) { return; } if (from == Constants.HitDirection.Bottom) { if (player.IsBigMario()) { Instantiate(brickBreakParticleGO, transform.position, transform.rotation); Destroy(gameObject); } else { animator.SetTrigger(hitHash); } } }