public void OnEnemyHitEffect(OnEnemyHit.HitDetails details) { // Prevent multiple hits at the same time. if (Time.time - lastEnemyHitTime > stats.TIME_BETWEEN_ENEMY_HIT && stats.status != CharacterDefinitions.CharacterStats.StatusTypes.dead) { // Play hit sound. GameObject globalSound = (GameObject)Instantiate(Resources.Load("GlobalSoundSource")); GlobalSoundPlay soundScript = globalSound.GetComponent <GlobalSoundPlay>(); soundScript.playGlobalSound(details.hitSfx, 0.4f); lastEnemyHitTime = Time.time; hCUI.consumeHp(20); if (hCUI.currentHp <= 0) { resetAnimationStatus(); stats.status = CharacterDefinitions.CharacterStats.StatusTypes.dead; animator.SetBool("DieBack", true); GlobalEvents geScript = gameController.GetComponent <GlobalEvents>(); geScript.showGameOverScreen(); } else { stats.status = CharacterDefinitions.CharacterStats.StatusTypes.injured; Invoke("hitAnimationToNormal", stats.TIME_WITH_HIT_EXPRESSION); } } }
// Start is called before the first frame update protected override void Start() { base.Start(); transform.position = startPosition; Vector2 origin = new Vector2(transform.position.x, transform.position.y); direction = (target - origin).normalized; // We instantiate any trail system (particle emitter). trailEffectSystem = (GameObject)Instantiate(trailEffectSystem, transform); // Set the trail to point in the opposite direction trailEffectSystem.transform.position = transform.position; trailEffectSystem.transform.rotation = transform.rotation; // 20% screen margin to be off-limits. setOffLimitOffset(0.2f); // Instantiate a Global Sound Source. GameObject globalSound = (GameObject)Instantiate(Resources.Load("GlobalSoundSource")); GlobalSoundPlay soundScript = globalSound.GetComponent <GlobalSoundPlay>(); soundScript.playGlobalSound(appearSound, 0.4f); skill = MagicBase.MagicName.Fireball; }
void Start() { GameObject globalSound = (GameObject)Instantiate(Resources.Load("GlobalSoundSource")); GlobalSoundPlay soundScript = globalSound.GetComponent<GlobalSoundPlay>(); soundScript.playGlobalSound(appearSound, volume); }