// Start is called before the first frame update
    void Start()
    {
        WeaponH = gameObject.transform.GetChild(0).gameObject;
        spriteR = gameObject.GetComponent <SpriteRenderer>();

        timeStartHit = -20.0f;
        moveScript   = gameObject.GetComponent <NewPlayerMovement>();
        meleeScript  = gameObject.GetComponent <playermelee>();
        rb           = gameObject.GetComponent <Rigidbody2D>();
        isBackBullet = false;

        int default_ = PlayerPrefs.GetInt("use_default");

        if (default_ != 1)
        {
            health = PlayerPrefs.GetInt("hp");
        }
        else
        {
            health = maxHealth;
        }
        //vida maxima na Barra de Vida
        healthBar.SetMaxHealth(maxHealth);
        healthBar.SetHealth(health);
    }
Exemple #2
0
    void checkIfHitByPlayer(Collider2D other)
    {
        if (other.gameObject.CompareTag("Player"))
        {
            // se atacarmos um inimigo precisamos joga-lo para trás
            // vamos criar um vetor na direcao do inimigo

            playermelee playerMeleeScript = other.gameObject.GetComponent <playermelee>();
            if (playerMeleeScript.isAttackingMelee && !isHit)
            {
                Rigidbody2D  rbEnemy         = gameObject.GetComponent <Rigidbody2D>();
                Transform    playerTransform = other.gameObject.GetComponent <Transform>();
                EnemyShotAI  enemyScriptAI   = gameObject.GetComponent <EnemyShotAI>();
                simple_enemy enemyScript     = gameObject.GetComponent <simple_enemy>();

                pushDirection       = (((Vector2)transform.position - (Vector2)playerTransform.position)).normalized;
                enemyScript.health -= 2;

                TimeStartHit = Time.time;
                isHit        = true;
            }
        }
    }
Exemple #3
0
 void Awake()
 {
     playerMScript  = GameObject.Find("player").GetComponent <playermelee>();
     playerGHScript = GameObject.Find("player").GetComponent <PlayerGotHit>();
 }