Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Our pvp mode class, travels between scenes (A,B,C)
  2. class PVPMode : MonoBehavior {
  3.  
  4.     list<Enemies> _enemies;
  5.  
  6.     void Awake() { DontDestroyOnLoad(this.gameobject); }
  7.  
  8.     void Update() {
  9.         if(TenMinutesPassed()) {
  10.             _enemies = GetNewEnemies();
  11.         }
  12.     }
  13.  
  14.     // we got to the scene A and clicked on pvp ui objects which got active
  15.     public void OnPVPUIAwake(PvpUI ui)
  16.     {
  17.         ui.SetEnemies(_enemies);
  18.     }
  19.  
  20. }
  21.  
  22. // I sit in scene A!
  23. class PVPStartup : MonoBehavior {
  24.  
  25.     void OnEnable() {
  26.         var ui = GetComponent<PvpUI>();
  27.         findObjectOfType<PVPMode>().OnPVPUIAwake(ui); // could cache the value but it's not the main trouble right now
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement