示例#1
0
 public void Die()
 {
     alive = false;
     deathParticle.Play();
     GetComponent <SpriteRenderer>().enabled       = false;
     sword.GetComponent <SpriteRenderer>().enabled = false;
     sword.swordTrail.enabled = false;
     trailRend.enabled        = false;
     rb.constraints           = RigidbodyConstraints2D.FreezeAll;
     sound.PlayDeathSound();
     StartCoroutine(Respawn());
 }
示例#2
0
    void Update()
    {
        gunTrans   = playerCharacter.GetComponentInChildren <GunController>();
        swordTrans = playerCharacter.GetComponentInChildren <SwordController>();

        if (gunTrans != null && gunTrans.isActiveAndEnabled)
        {
            playerTransform = gunTrans.GetComponent <Transform>();
        }
        else if (swordTrans != null && swordTrans.isActiveAndEnabled)
        {
            playerTransform = swordTrans.GetComponent <Transform>();
        }

        enemyAgent.SetDestination(playerTransform.position);

        enemyPlayerDistance = Mathf.Abs(Vector3.Distance(playerTransform.position, transform.position));

        if (enemyPlayerDistance <= thresholdVisiblityDistance)
        {
            bulletRenderer.enabled = true;
        }
        else
        {
            bulletRenderer.enabled = false;
        }

        if (enemyLife <= 0f)
        {
            // Debug.Log("enemy killed!");
            gameManager.enemyKilled();
            Destroy(gameObject);
        }
    }
示例#3
0
    private void hitPlayer()
    {
        gunTrans   = playerCharacter.GetComponentInChildren <GunController>();
        swordTrans = playerCharacter.GetComponentInChildren <SwordController>();

        if (gunTrans != null && gunTrans.isActiveAndEnabled)
        {
            playerTransform = gunTrans.GetComponent <Transform>();
        }
        else if (swordTrans != null && swordTrans.isActiveAndEnabled)
        {
            playerTransform = swordTrans.GetComponent <Transform>();
        }

        float distance = Vector3.Distance(playerTransform.position, transform.position);

        distance = Mathf.Abs(distance);

        if (distance < enemyHitDistance)
        {
            // Debug.Log("player hit!");
            playerCharacter.GetComponent <PlayerContoller>().playerLife -= enemyHitDamag;
        }
    }
示例#4
0
 public SwordScoreController GetScoreController()
 {
     return(CurrentCharacter.GetComponent <SwordScoreController>());
 }