Example #1
0
 void Start()
 {
     playerRigidbody2D = GetComponent <Rigidbody2D>();
     _playerHelper     = GetComponent <PlayerHelper>();
     soundEffector     = GetComponent <Player>().soundEffector;
     joystick          = GetComponent <Player>().joystick;
 }
 private void OnDestroy()
 {
     if (Singleton == this)
     {
         Singleton = null;
     }
 }
Example #3
0
    // Start is called before the first frame update
    void Start()
    {
        rb    = GetComponent <Rigidbody2D>();
        anim  = GetComponent <Animator>();
        se    = GetComponent <SoundEffector>();
        speed = idleSpeed;

        curHP = maxHP;
    }
 private void Awake()
 {
     if (Singleton != null && Singleton != this)
     {
         Destroy(gameObject);
     }
     else if (Singleton == null)
     {
         Singleton = this;
     }
 }
Example #5
0
    /// <summary>
    /// Applies the singleton pattern.
    /// </summary>
    private void ApplySingleton()
    {
        //Singleton
        if (Instance == null)
        {
            Instance = this;
        }

        if (this != Instance)
        {
            Destroy(gameObject);
        }
    }