we used to KILL people WITH HAMMERS for saying things like that
This commit is contained in:
parent
17b1a1e367
commit
daf3218043
8 changed files with 235 additions and 54 deletions
|
|
@ -1,10 +1,48 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Core.Extensions;
|
||||
using UnityEngine;
|
||||
|
||||
public class MeleeWeapon : Weapon
|
||||
{
|
||||
|
||||
public LayerMask entityLayer;
|
||||
[SerializeField] private GameObject debugColliderHitbox;
|
||||
[SerializeField] private Vector2 colliderSize;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (isAiming)
|
||||
{
|
||||
Vector2 mouseWorldPos = PlayerEntityMovement.instance.mouseWorldPos; //using this so i don't have to paste in and recalculate the variable on something i already have lol
|
||||
debugColliderHitbox.gameObject.SetActive(true);
|
||||
transform.Lookat2D(mouseWorldPos);
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
{
|
||||
RaycastHit2D[] enemyList = Physics2D.BoxCastAll(transform.position, colliderSize, Vector3.Angle(transform.position, mouseWorldPos),
|
||||
PlayerEntityMovement.instance.mouseWorldPos, 100f, entityLayer);
|
||||
foreach (RaycastHit2D enemy in enemyList)
|
||||
{
|
||||
if (!enemy.transform.CompareTag(tag) && enemy.transform.TryGetComponent(out Entity isEntity))
|
||||
{
|
||||
isEntity.TakeDamage(damage);
|
||||
}
|
||||
}
|
||||
isAiming = false;
|
||||
thisEntity.hasAttacked = true;
|
||||
TurnHandler.instance.UpdateTurns();
|
||||
ActionUIHandler.instance.UpdateUI();
|
||||
debugColliderHitbox.gameObject.SetActive(false);
|
||||
}
|
||||
else if (Input.GetMouseButtonDown(1))
|
||||
{
|
||||
isAiming = false;
|
||||
debugColliderHitbox.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void AttackEffects()
|
||||
{
|
||||
|
||||
isAiming = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue