private bool killZed     = false; // has already been killed due to Z val

    // Start is called before the first frame update
    void Start()
    {
        health = maxHealth;
        speed  = maxSpeed;

        if (ui is null)
        {
            ui = GameObject.Find("UIMaster").GetComponent <UIMiddleman>();
        }
        if (lvl == null || lvl.Equals(default(ILevelScript)))
        {
            Component[] temp = GameObject.Find("LevelMaster").GetComponents(typeof(Component));
            foreach (Component c in temp)
            {
                if (c is ILevelScript)
                {
                    lvl = c as ILevelScript;
                    break;
                }
            }
        }

        // Instantiate health bar UI Slider
        healthBar = Instantiate(healthBarPrefab).GetComponent <EnemyHPUI>();
        healthBar.transform.SetParent(GameObject.Find("UIPanel").transform, false);
        hbTransform = healthBar.GetComponent <RectTransform>();
        UpdateHealthBarLocation();

        // Set up RB and player
        rb = GetComponent <Rigidbody>();
        if (!player)
        {
            player = GameObject.Find("PlayerMaster").transform;
        }
    }
Beispiel #2
0
 // Use this for initialization
 void Start()
 {
     Time.timeScale               = 1.0f;
     Cursor.visible               = false;
     Cursor.lockState             = CursorLockMode.Locked;
     _events                      = eventHandler.GetComponent <EventHandler>();
     _events.OnSectionTransition += triggerTransition;
     scripts                      = GetComponents <ILevelScript>();
     currentScript                = scripts[currentScriptIndex];
     //Set first parameters
     currentScript.setParameters(null);
 }
Beispiel #3
0
 //This method subscribes to an event trigger
 void triggerTransition(Transform nextTransition)
 {
     if (currentScript.getCurrentSubsection() == currentScript.getNumberOfSubsections())
     {
         currentScriptIndex++;
         if (currentScriptIndex == scripts.Length)
         {
             Cursor.visible   = true;
             Cursor.lockState = CursorLockMode.None;
             SceneManager.LoadScene(0);
         }
         else
         {
             currentScript = scripts[currentScriptIndex];
             currentScript.setParameters(nextTransition);
         }
     }
     else
     {
         currentScript.setParameters(nextTransition);
     }
 }