Items #3
@ -5,15 +5,21 @@ public class PlayerView : MonoBehaviour
|
||||
{
|
||||
public Action OnStep;
|
||||
public Action OnAttackEnd;
|
||||
public Action OnAttack;
|
||||
public GameObject charBarCanvas;
|
||||
|
||||
public void Step()
|
||||
private void Step()
|
||||
{
|
||||
OnStep?.Invoke();
|
||||
}
|
||||
|
||||
public void AttackEnd()
|
||||
private void AttackEnd()
|
||||
{
|
||||
OnAttackEnd?.Invoke();
|
||||
}
|
||||
|
||||
private void Attack()
|
||||
{
|
||||
OnAttack?.Invoke();
|
||||
}
|
||||
}
|
||||
|
@ -213792,6 +213792,13 @@ AnimationClip:
|
||||
m_HasGenericRootTransform: 0
|
||||
m_HasMotionFloatCurves: 0
|
||||
m_Events:
|
||||
- time: 1.4333333
|
||||
functionName: Attack
|
||||
data:
|
||||
objectReferenceParameter: {fileID: 0}
|
||||
floatParameter: 0
|
||||
intParameter: 0
|
||||
messageOptions: 0
|
||||
- time: 2
|
||||
functionName: AttackEnd
|
||||
data:
|
||||
|
@ -400,49 +400,49 @@ AnimatorController:
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 0}
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: BackToIdle
|
||||
m_Type: 9
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 0}
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: Build
|
||||
m_Type: 9
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 0}
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: TreeAttack
|
||||
m_Type: 9
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 0}
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: Move
|
||||
m_Type: 9
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 0}
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: SuperJump
|
||||
m_Type: 9
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 0}
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: Frozen
|
||||
m_Type: 9
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 0}
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: isMoving
|
||||
m_Type: 4
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 0}
|
||||
m_Controller: {fileID: 9100000}
|
||||
m_AnimatorLayers:
|
||||
- serializedVersion: 5
|
||||
m_Name: Base Layer
|
||||
|
@ -17,4 +17,4 @@ MonoBehaviour:
|
||||
type: 3}
|
||||
manaCost: 10
|
||||
damage: 10
|
||||
speed: 0.1
|
||||
speed: 10
|
||||
|
@ -1,4 +1,5 @@
|
||||
using HexFiled;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Chars
|
||||
{
|
||||
@ -19,11 +20,12 @@ namespace Chars
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public void Attack(HexDirection direction)
|
||||
public void Attack(Vector2 direction)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
public void Damage(float dmg)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
|
@ -1,4 +1,6 @@
|
||||
using HexFiled;
|
||||
|
||||
using HexFiled;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Chars
|
||||
{
|
||||
@ -7,7 +9,7 @@ namespace Chars
|
||||
public void Move(HexDirection direction);
|
||||
public void Spawn();
|
||||
public void Death();
|
||||
public void Attack(HexDirection direction);
|
||||
public void Attack(Vector2 direction);
|
||||
public void Damage(float dmg);
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ using HexFiled;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
|
||||
namespace Chars
|
||||
{
|
||||
struct AnimLength
|
||||
@ -33,7 +34,7 @@ namespace Chars
|
||||
private float _hp;
|
||||
private float _mana;
|
||||
private Weapon _weapon;
|
||||
private List<HexCell> _cellsToEdge;
|
||||
private Vector3 _direction;
|
||||
private CharBar _charBar;
|
||||
|
||||
public bool IsBusy => _isBusy;
|
||||
@ -49,7 +50,6 @@ namespace Chars
|
||||
_hexGrid = hexGrid;
|
||||
_isBusy = false;
|
||||
_color = playerData.color;
|
||||
|
||||
}
|
||||
|
||||
public void Move(HexDirection direction)
|
||||
@ -109,37 +109,34 @@ namespace Chars
|
||||
}
|
||||
}
|
||||
|
||||
private void SetUpActions()
|
||||
{
|
||||
_playerView.OnStep += () =>
|
||||
private void Step()
|
||||
{
|
||||
_isBusy = false;
|
||||
_cell.PaintHex(_color);
|
||||
_animator.SetBool("isMoving", _isBusy);
|
||||
};
|
||||
_playerView.OnAttackEnd += () =>
|
||||
}
|
||||
|
||||
private void AttackEnd()
|
||||
{
|
||||
_isBusy = false;
|
||||
_mana -= _weapon.manaCost;
|
||||
UpdateCanvas();
|
||||
}
|
||||
|
||||
private void Attacking()
|
||||
{
|
||||
var ball = Object.Instantiate(_weapon.objectToThrow,
|
||||
_instance.transform.position + new Vector3(0, 2), Quaternion.identity);
|
||||
var sequence = DOTween.Sequence();
|
||||
_cellsToEdge.ForEach(cell =>
|
||||
{
|
||||
|
||||
sequence.Append(ball.transform
|
||||
.DOMove(cell.transform.position + new Vector3(0, 2), _weapon.speed).SetEase(Ease.Linear));
|
||||
});
|
||||
sequence.onComplete += () => { Object.Destroy(ball); };
|
||||
sequence.onUpdate += () =>
|
||||
{
|
||||
if (ball == null)
|
||||
{
|
||||
sequence.Kill();
|
||||
ball.transform.DOMove(new Vector3(_direction.x * 100,2, _direction.y * 100), _weapon.speed)
|
||||
.SetEase(Ease.Linear)
|
||||
.OnComplete(() => Object.Destroy(ball));
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
private void SetUpActions()
|
||||
{
|
||||
_playerView.OnStep += Step;
|
||||
_playerView.OnAttackEnd += AttackEnd;
|
||||
_playerView.OnAttack += Attacking;
|
||||
}
|
||||
|
||||
private void UpdateCanvas()
|
||||
@ -153,22 +150,17 @@ namespace Chars
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void Attack(HexDirection direction)
|
||||
|
||||
public void Attack(Vector2 direction)
|
||||
{
|
||||
if (_cell.GetNeighbor(direction) && _mana - _weapon.manaCost >= 0)
|
||||
{
|
||||
_cellsToEdge = new List<HexCell>();
|
||||
_isBusy = true;
|
||||
_instance.transform.DOLookAt(_cell.GetNeighbor(direction).transform.position, 0.1f);
|
||||
_animator.SetTrigger("Attack");
|
||||
var curCell = _cell.GetNeighbor(direction);
|
||||
_cellsToEdge.Add(curCell);
|
||||
while (curCell.GetNeighbor(direction) != null)
|
||||
}
|
||||
|
||||
public void Aim(Vector2 direction)
|
||||
{
|
||||
curCell = curCell.GetNeighbor(direction);
|
||||
_cellsToEdge.Add(curCell);
|
||||
}
|
||||
}
|
||||
_playerView.transform.LookAt(new Vector3(direction.x,0, direction.y) + _playerView.transform.position);
|
||||
_direction = direction;
|
||||
}
|
||||
|
||||
public void Damage(float dmg)
|
||||
|
@ -14,6 +14,7 @@ namespace Chars
|
||||
private FloatingJoystick _moveJoystick;
|
||||
private FloatingJoystick _attackJoystick;
|
||||
private Camera _camera;
|
||||
private Vector2 _attackDircetion;
|
||||
|
||||
|
||||
public PlayerControl(Player player, PlayerData playerData)
|
||||
@ -23,23 +24,25 @@ namespace Chars
|
||||
_moveJoystick = joyView.MoveJoystick;
|
||||
_attackJoystick = joyView.AttackJoystick;
|
||||
_camera = Camera.main;
|
||||
|
||||
_attackJoystick.OnTouchUp += DoAttack;
|
||||
}
|
||||
|
||||
private void DoAttack()
|
||||
{
|
||||
_player.Attack(_attackDircetion);
|
||||
}
|
||||
|
||||
public void FixedExecute()
|
||||
{
|
||||
|
||||
if (!_player.IsBusy && _moveJoystick.Direction != Vector2.zero)
|
||||
{
|
||||
_player.Move(VectorToDirection(_moveJoystick.Direction.normalized));
|
||||
|
||||
}
|
||||
|
||||
if (!_player.IsBusy && _attackJoystick.Direction != Vector2.zero)
|
||||
if (!_player.IsBusy && _attackJoystick.isPressed)
|
||||
{
|
||||
_player.Attack(VectorToDirection(_attackJoystick.Direction.normalized));
|
||||
|
||||
_attackDircetion = _attackJoystick.Direction.normalized;
|
||||
_player.Aim(_attackDircetion);
|
||||
}
|
||||
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user