8ydilnik

event | sistem

Sep 18th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.16 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class iventsistem : MonoBehaviour
  6. {
  7.     public static iventsistem instance;
  8.     public delegate void action();
  9.     public event action time;
  10.     public event action Win;
  11.     public event action Lose;
  12.     public event action Sound;
  13.  
  14.     // Start is called before the first frame update
  15.     void Awake()
  16.     {
  17.         //// if event not empty
  18.         if (instance == null)
  19.         {
  20.             instance = this;
  21.         }
  22.  
  23.     }
  24.  
  25.     //event time
  26.     public void Ontime()
  27.     {
  28.         // if event not empty
  29.         if (time != null)
  30.         {
  31.             time();
  32.         }
  33.     }
  34.  
  35.     //event win
  36.     public void OnWin()
  37.     {
  38.         // if event not empty
  39.         if (Win != null)
  40.         {
  41.             Win();
  42.         }
  43.     }
  44.  
  45.     //event lose
  46.     public void OnLose()
  47.     {
  48.         // if event not empty
  49.         if (Lose != null)
  50.         {
  51.             Lose();
  52.         }
  53.     }
  54.  
  55.     //event sound
  56.     public void OnSound()
  57.     {
  58.         // if event not empty
  59.         if (Sound != null)
  60.         {
  61.             Sound();
  62.         }
  63.     }
  64. }
Add Comment
Please, Sign In to add comment