Items #3
@ -77,7 +77,7 @@ public class Joystick : MonoBehaviour, IPointerDownHandler, IDragHandler, IPoint
|
||||
FormatInput();
|
||||
HandleInput(input.magnitude, input.normalized, radius, cam);
|
||||
handle.anchoredPosition = input * radius * handleRange;
|
||||
OnPadDrag.Invoke(Direction);
|
||||
OnPadDrag?.Invoke(Direction);
|
||||
}
|
||||
|
||||
protected virtual void HandleInput(float magnitude, Vector2 normalised, Vector2 radius, Camera cam)
|
||||
|
@ -3,14 +3,8 @@ using UnityEngine;
|
||||
|
||||
public class PlayerView : MonoBehaviour
|
||||
{
|
||||
private Animator _animator;
|
||||
public Action OnStep;
|
||||
|
||||
void Start()
|
||||
{
|
||||
_animator.GetComponent<Animator>();
|
||||
}
|
||||
|
||||
public void Step()
|
||||
{
|
||||
OnStep?.Invoke();
|
||||
|
@ -54,7 +54,7 @@ namespace Chars
|
||||
_cell.PaintHex(_texture);
|
||||
_animator.SetBool("isMoving", _isMoving);
|
||||
};
|
||||
_instance.transform.DOMove(_cell.transform.position, _tick);
|
||||
_instance.transform.DOMove(_cell.transform.position, _animator.GetCurrentAnimatorClipInfo(0).LongLength);
|
||||
|
||||
}
|
||||
}
|
||||
@ -76,6 +76,7 @@ namespace Chars
|
||||
_isAlive = true;
|
||||
_animator = _instance.GetComponent<Animator>();
|
||||
_playerView = _instance.GetComponent<PlayerView>();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Controller;
|
||||
using Data;
|
||||
using HexFiled;
|
||||
using Runtime.Controller;
|
||||
@ -7,13 +8,12 @@ using Object = UnityEngine.Object;
|
||||
|
||||
namespace Chars
|
||||
{
|
||||
public class PlayerControl : IExecute
|
||||
public class PlayerControl : IFixedExecute
|
||||
{
|
||||
private Player _player;
|
||||
private FloatingJoystick _moveJoystick;
|
||||
private FloatingJoystick _attackJoystick;
|
||||
private float _curTime;
|
||||
private float _tick;
|
||||
|
||||
|
||||
public PlayerControl(Player player, PlayerData playerData)
|
||||
{
|
||||
@ -21,24 +21,17 @@ namespace Chars
|
||||
var joyView = Object.Instantiate(playerData.joystickView);
|
||||
_moveJoystick = joyView.MoveJoystick;
|
||||
_attackJoystick = joyView.AttackJoystick;
|
||||
_curTime = Time.time;
|
||||
_tick = playerData.Tick;
|
||||
_moveJoystick.OnPadDrag += Move;
|
||||
}
|
||||
|
||||
public void Execute()
|
||||
|
||||
|
||||
public void FixedExecute()
|
||||
{
|
||||
if (!_player.IsMoving && _moveJoystick.Direction != Vector2.zero)
|
||||
if (!_player.IsMoving && _moveJoystick.isPressed)
|
||||
{
|
||||
_curTime = Time.time;
|
||||
_player.Move(VectorToDirection(_moveJoystick.Direction.normalized));
|
||||
}
|
||||
}
|
||||
|
||||
private void Move(Vector3 dir)
|
||||
{
|
||||
}
|
||||
|
||||
private static HexDirection VectorToDirection(Vector2 dir)
|
||||
{
|
||||
if (dir.x >= 0 && dir.y <= 1 && dir.x <= 1 && dir.y >= 0.5)
|
||||
@ -73,5 +66,7 @@ namespace Chars
|
||||
|
||||
return HexDirection.W;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user