invetory fix
This commit is contained in:
parent
cb8fbbafce
commit
fbbf806bab
@ -13,7 +13,7 @@ namespace GameUI
|
||||
[SerializeField] private GameObject item;
|
||||
[SerializeField] private GameObject grid;
|
||||
|
||||
public event Action<Unit,Item> OnBuildingInvoked;
|
||||
public event Action<Unit, Item> OnBuildingInvoked;
|
||||
|
||||
private List<GameObject> itemsGo;
|
||||
private List<Button> _buttons;
|
||||
@ -51,7 +51,7 @@ namespace GameUI
|
||||
|
||||
private void SwitchButton(Button button)
|
||||
{
|
||||
if(button == null)
|
||||
if (button == null)
|
||||
return;
|
||||
button.onClick.RemoveAllListeners();
|
||||
button.gameObject.SetActive(false);
|
||||
@ -98,7 +98,7 @@ namespace GameUI
|
||||
break;
|
||||
case SpecialWeapon specialWeapon:
|
||||
specialWeapon.Invoke((u) => SwitchButton(button), _unit);
|
||||
OnBuildingInvoked?.Invoke(_unit,specialWeapon);
|
||||
OnBuildingInvoked?.Invoke(_unit, specialWeapon);
|
||||
break;
|
||||
case SwitchingPlaces switchingPlaces:
|
||||
switchingPlaces.Invoke((u) => SwitchButton(button), _unit);
|
||||
|
@ -15,7 +15,7 @@ namespace Items
|
||||
|
||||
public void Invoke(Action<Unit> action)
|
||||
{
|
||||
OnItemUsed += action;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -63,9 +63,18 @@ namespace Items
|
||||
unit.UseItem(this);
|
||||
HexManager.UnitCurrentCell[unit.Color].cell.PaintHex(unit.Color);
|
||||
var cell = HexManager.UnitCurrentCell[unit.Color].cell.GetNeighbor(_direction);
|
||||
OnItemUsed?.Invoke(unit);
|
||||
|
||||
unit.UnitView.AnimActionDic[animName] -= DoPaint;
|
||||
OnItemUsed = null;
|
||||
if (cell == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
cell.PaintHex(unit.Color);
|
||||
bool keepGoing = true;
|
||||
var moveDir = _direction;
|
||||
|
||||
|
||||
itterationMove.ForEach(dir =>
|
||||
{
|
||||
if (!keepGoing) return;
|
||||
@ -89,11 +98,7 @@ namespace Items
|
||||
cell.PaintHex(unit.Color);
|
||||
});
|
||||
|
||||
OnItemUsed?.Invoke(unit);
|
||||
|
||||
|
||||
unit.UnitView.AnimActionDic[animName] -= DoPaint;
|
||||
OnItemUsed = null;
|
||||
}
|
||||
|
||||
public void UseAbility(Unit unit)
|
||||
|
@ -30,7 +30,7 @@ namespace Items.ItemViews
|
||||
Despawn();
|
||||
return;
|
||||
}
|
||||
transform.DOMove(unit.UnitView.transform.position, 0.1f).OnComplete(() =>
|
||||
transform.DOMove(unit.UnitView.transform.position + new Vector3(0,1,0), 0.1f).OnComplete(() =>
|
||||
{
|
||||
unit.PickUpItem(_item);
|
||||
Despawn();
|
||||
|
@ -58,18 +58,19 @@ namespace Items
|
||||
}
|
||||
|
||||
Debug.DrawRay(ray.origin,
|
||||
ray.direction * hit.distance, UnityEngine.Color.red);
|
||||
ray.direction * hit.distance, UnityEngine.Color.red, 10f);
|
||||
}
|
||||
|
||||
|
||||
public void UseAbility(Unit unit, Unit chosenUnit)
|
||||
{
|
||||
if (unit == null)
|
||||
if (chosenUnit == null || unit.isSwitched)
|
||||
{
|
||||
DeAim();
|
||||
return;
|
||||
}
|
||||
unit.UseItem(this);
|
||||
unit.isSwitched = true;
|
||||
DeAim();
|
||||
OnItemUsed?.Invoke(unit);
|
||||
chosenUnit.IsBusy = true;
|
||||
@ -81,6 +82,7 @@ namespace Items
|
||||
chosenUnit.SetCell(unitCell, true);
|
||||
TimerHelper.Instance.StartTimer(() =>
|
||||
{
|
||||
unit.isSwitched = false;
|
||||
chosenUnit.SetCell(choseUnitCell, true, true);
|
||||
unit.SetCell(unitCell, true);
|
||||
chosenUnit.IsStaned = false;
|
||||
|
@ -39,6 +39,7 @@ namespace Units
|
||||
private UnitColor _easyCaptureColor;
|
||||
|
||||
public bool IsStaned;
|
||||
public bool isSwitched;
|
||||
public int AttackBonus => _weapon.modifiedDamage - _weapon.damage;
|
||||
|
||||
|
||||
@ -424,7 +425,8 @@ namespace Units
|
||||
_instance.transform.position);
|
||||
TimerHelper.Instance.StartTimer(() =>
|
||||
{
|
||||
HexManager.PaintHexList(hexToPaint, UnitColor.Grey);
|
||||
|
||||
HexManager.PaintHexList(hexToPaint.Where(x => x.Color == Color).ToList(), UnitColor.Grey);
|
||||
|
||||
Object.Destroy(_instance);
|
||||
OnDeath?.Invoke(this);
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user