dronkowitz

TeamBlastVideos.cs

Oct 13th, 2021 (edited)
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.54 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.Video;
  5. public class TeamBlastVideos : MonoBehaviour
  6. {
  7.    
  8.     public GameObject teamBlastVideoPlayer;
  9.     public VideoPlayer vplayer;
  10.     public AudioSource stageMusic;
  11.     public AudioSource omochaoDialog;
  12.     // Start is called before the first frame update
  13.     void Start()
  14.     {
  15.        
  16.  
  17.  
  18.     }
  19.  
  20.     private void Update()
  21.     {
  22.        
  23.     }
  24.  
  25.     public void SpecialAttack()
  26.     {
  27.         teamBlastVideoPlayer.SetActive(true);
  28.         vplayer.clip = FindObjectOfType<TeamSetup>().CurrentTeam.teamBlast;
  29.        
  30.        
  31.         StartCoroutine(PlayVideo());
  32.     }
  33.  
  34.     public IEnumerator PlayVideo()
  35.     {
  36.         vplayer.Play();
  37.         stageMusic.volume = 0;
  38.         omochaoDialog.volume = 0;
  39.         yield return new WaitForSeconds(1);
  40.         while (vplayer.isPlaying)
  41.         {
  42.             yield return new WaitForEndOfFrame();
  43.         }
  44.         teamBlastVideoPlayer.SetActive(false);
  45.         yield return new WaitForSeconds(1);
  46.  
  47.         Health[] allEnemies = FindObjectsOfType<Health>();
  48.         Transform player = FindObjectOfType<UltimatePlayerMovement>().transform;
  49.  
  50.         foreach (Health enemy in allEnemies)
  51.         {
  52.             float distance = Vector3.Distance(player.position,enemy.transform.position);
  53.             if (distance<30)
  54.             {
  55.                 enemy.TakeDamage(10);
  56.             }
  57.            
  58.         }
  59.  
  60.         stageMusic.volume = 1;
  61.         omochaoDialog.volume = 1;
  62.     }
  63. }
  64.  
Add Comment
Please, Sign In to add comment