예제 #1
0
    void Start()
    {
        parent      = GetComponentInParent <EnemyMonitor>();
        enemyLevel  = gameObject.transform.Find("Level").GetComponent <TextMeshProUGUI>();
        enemyName   = gameObject.transform.Find("Name").GetComponent <TextMeshProUGUI>();
        enemyHealth = gameObject.transform.Find("Health").GetComponent <TextMeshProUGUI>();

        enemyName.text = parent.enemyStats.enemyName;
    }
예제 #2
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        //On collision, easiest script/method to find the enemy element and calculate the bonuses and feed it into the damage function.
        if (collision.gameObject.tag == "Enemy")
        {
            EnemyMonitor enemy = collision.gameObject.GetComponent <EnemyMonitor>();
            float        elementDamage;

            if (PersistantGameManager.Instance.currentWeapon.itemElement == "" || PersistantGameManager.Instance.currentWeapon.itemElement == enemy.enemyStats.enemyClass)
            {
                elementDamage = 1;
            }
            else if (PersistantGameManager.Instance.currentWeapon.itemElement == "Light")
            {
                elementDamage = 1.2f;
            }
            else if (weaponElements[PersistantGameManager.Instance.currentWeapon.itemElement].Contains(enemy.enemyStats.enemyClass))
            {
                elementDamage = 1.5f;
            }
            else
            {
                elementDamage = 0.5f;
            }

            //Calculates damage then calculates the healing the player does
            double newPlayerDamage   = player.CalculatePlayerDamage(elementDamage);
            float  playerHealthSteal = player.CalculatePlayerHealing();

            //Deals damage and adds health
            enemy.currentHealth  -= newPlayerDamage;
            player.currentHealth += playerHealthSteal;

            player.attackTime = Time.time;
            if (player.currentHealth > player.totalHealth)
            {
                player.currentHealth = player.totalHealth;
            }
        }
    }
예제 #3
0
    void Awake()
    {
        enemy        = gameObject.transform.Find("Enemy").gameObject;
        enemyMonitor = enemy.GetComponent <EnemyMonitor>();
        player       = FindObjectOfType <PlayerControls>().gameObject;
        rb           = enemy.GetComponent <Rigidbody2D>();
        Physics2D.IgnoreCollision(player.GetComponent <BoxCollider2D>(), enemy.GetComponent <BoxCollider2D>());

        //If the attack type needs patrol points it finds them, for redundency if it fails then debug it then destroy itself
        if (patrol || charge)
        {
            try
            {
                patrolPoints.Add(gameObject.transform.Find("Left Point"));
                patrolPoints.Add(gameObject.transform.Find("Right Point"));
            }
            catch
            {
                Debug.Log("!!!!!No Patrol Points for " + gameObject.name + "!!!!!");
                Destroy(gameObject);
            }

            distanceBetweenPoints = Vector2.Distance(patrolPoints[0].position, patrolPoints[1].position);
        }

        //if it is a charge enemy set it to the left most point then set it to move right
        if (charge)
        {
            enemy.transform.position = patrolPoints[0].transform.position;
            currentPointIndex        = 1;
        }

        if (patrol)
        {
            patrolling = true;
        }
    }
예제 #4
0
 void Start()
 {
     //sets scale to default
     sizeOfBar = transform.localScale.x;
     parent    = GetComponentInParent <EnemyMonitor>();
 }