private void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(this.gameObject);
         return;
     }
     else
     {
         instance = this;
     }
 }
示例#2
0
    } // commented

    /// <summary>
    /// Ensures all references are set for the player
    /// </summary>
    private void InitializePlayerGameObject()
    {
        // Set all necessary references
        rigid      = gameObject.GetComponent <Rigidbody2D>();
        playerStat = GetComponent <PlayerStats>();
        anim       = GetComponent <Animator>();
        equip      = EquipmentManager.instance;

        m_Plane       = GameDetails.instance.m_Plane;
        pooledArrows  = PooledProjectilesController.instance;
        cameraControl = CameraController.instance;

        staminaBar = GameDetails.instance.transform.Find("UiCanvas/VisibleUi/StaminaBar/Stamina_Bar/Stamina_Fill").GetComponent <Image>();
        healthBar  = GameDetails.instance.transform.Find("UiCanvas/VisibleUi/HealthBar/Health_Bar/Health_Fill").GetComponent <Image>();

        // set the lookat on the camera controller to be the playerObject.
        cameraControl.lookAt = this.gameObject.transform;

        // fetch all particleSystems that are children of this gameObject and place them in an array of particleSystems
        particles = GetComponentsInChildren <ParticleSystem>();

        // Find the object called "EventSystem" and make a reference to it
        eventSys = GameObject.Find("EventSystem").GetComponent <EventSystem>();
    }