Esempio n. 1
0
    // Use this for initialization
    void Start()
    {
        default_resistance   = resistance;
        default_maxSpeed     = maxSpeed;
        default_jumpForce    = jumpForce;
        default_gravityScale = this.GetComponent <Rigidbody2D> ().gravityScale;
        onLadder             = false;
        isDead = false;

        contToUse = 1;

        anim  = GetComponent <Animator> ();
        rBody = GetComponent <Rigidbody2D> ();
        if (GameObject.Find("PlayerUI"))
        {
            ui = GameObject.Find("PlayerUI").GetComponent <PlayerHud>();
        }

        currentHealth = startingHealth;
        if (ui)
        {
            ui.updateHealth();
        }

        if (defaultWeapon == null)
        {
            Debug.LogError("No Default Weapon Set in PlayerController");
        }

        if (currentWeapon == null)
        {
            currentWeapon = Instantiate(defaultWeapon);
        }
        setWeapon();
    }