protected override void Update() { // stay a purplish hue, Ponyboy if (base.lightTimer <= 0) { //base.enemyLight = gameObject.AddComponent<Light>(); //base.enemyLight.range = 3.5f; base.enemyLight.intensity = 3; base.enemyLight.color = Color.magenta; } //BASE UPDATE base.Update(); //Check shine hit if (shinedCooldown > 0 && playerCombat.CurrentAttack == PlayerCombat.Attacks.Shine) { List <Rect> shineHitboxes = playerCombat.GetActiveAttackHitboxes(); for (int i = 0; i < shineHitboxes.Count; ++i) { if (Helper.AABB(this.HitBoxRect, shineHitboxes[i])) { //Increment times shined but stay within range if (++shinedIncrements > shinedMaxIncrements) { shinedIncrements = shinedMaxIncrements; } //Cooldown for 1 sec so we don't register this multiple times shinedCooldown = 1f; } } shinedCooldown -= Time.deltaTime; } }
/// <summary> /// Sees whether or not it's hitting a player attack /// </summary> /// <returns></returns> protected bool CheckCollisionsWithPlayerHitboxes() { //Get player hitboxes List <Rect> hitboxes = player.GetActiveAttackHitboxes(); //Loop through and if we're colliding (roughly) then return true for (int i = 0; i < hitboxes.Count; ++i) { if ((this.transform.position - new Vector3(hitboxes[i].x, hitboxes[i].y, this.transform.position.z)).sqrMagnitude < hitboxRect.width * hitboxRect.width) { return(true); } } return(false); }