Items #3
@ -313,28 +313,6 @@ AnimatorStateTransition:
|
|||||||
m_InterruptionSource: 0
|
m_InterruptionSource: 0
|
||||||
m_OrderedInterruption: 1
|
m_OrderedInterruption: 1
|
||||||
m_CanTransitionToSelf: 1
|
m_CanTransitionToSelf: 1
|
||||||
--- !u!1101 &-341059549419662850
|
|
||||||
AnimatorStateTransition:
|
|
||||||
m_ObjectHideFlags: 1
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_Name:
|
|
||||||
m_Conditions: []
|
|
||||||
m_DstStateMachine: {fileID: 0}
|
|
||||||
m_DstState: {fileID: 9131620394910522952}
|
|
||||||
m_Solo: 0
|
|
||||||
m_Mute: 0
|
|
||||||
m_IsExit: 0
|
|
||||||
serializedVersion: 3
|
|
||||||
m_TransitionDuration: 0.25
|
|
||||||
m_TransitionOffset: 0
|
|
||||||
m_ExitTime: 0.53125
|
|
||||||
m_HasExitTime: 1
|
|
||||||
m_HasFixedDuration: 1
|
|
||||||
m_InterruptionSource: 0
|
|
||||||
m_OrderedInterruption: 1
|
|
||||||
m_CanTransitionToSelf: 1
|
|
||||||
--- !u!91 &9100000
|
--- !u!91 &9100000
|
||||||
AnimatorController:
|
AnimatorController:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -570,7 +548,6 @@ AnimatorState:
|
|||||||
- {fileID: -6460354900618266653}
|
- {fileID: -6460354900618266653}
|
||||||
- {fileID: -9165632119200558840}
|
- {fileID: -9165632119200558840}
|
||||||
- {fileID: -528955148574366107}
|
- {fileID: -528955148574366107}
|
||||||
- {fileID: -341059549419662850}
|
|
||||||
m_StateMachineBehaviours: []
|
m_StateMachineBehaviours: []
|
||||||
m_Position: {x: 50, y: 50, z: 0}
|
m_Position: {x: 50, y: 50, z: 0}
|
||||||
m_IKOnFeet: 0
|
m_IKOnFeet: 0
|
||||||
|
@ -12,5 +12,5 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 83b1020f31bf45569f5af6c77fc77d4e, type: 3}
|
m_Script: {fileID: 11500000, guid: 83b1020f31bf45569f5af6c77fc77d4e, type: 3}
|
||||||
m_Name: CameraData
|
m_Name: CameraData
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
offset: {x: 0, y: 0, z: 0}
|
offset: {x: -10, y: 15, z: -15}
|
||||||
smoothSpeed: 0.1
|
smoothSpeed: 0.001
|
||||||
|
@ -13,9 +13,10 @@ MonoBehaviour:
|
|||||||
m_Name: PlayerData
|
m_Name: PlayerData
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
spawnPos:
|
spawnPos:
|
||||||
x: 0
|
x: 7
|
||||||
z: 0
|
z: 8
|
||||||
playerPrefab: {fileID: 7527582019267571087, guid: f102085e8bc4cad4992d43b84dee1055,
|
playerPrefab: {fileID: 7527582019267571087, guid: f102085e8bc4cad4992d43b84dee1055,
|
||||||
type: 3}
|
type: 3}
|
||||||
joystickView: {fileID: 4385872142190176059, guid: 4df6913b39f4979429158c344680d83f,
|
joystickView: {fileID: 4385872142190176059, guid: 4df6913b39f4979429158c344680d83f,
|
||||||
type: 3}
|
type: 3}
|
||||||
|
Tick: 0.8
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
using Controller;
|
using Controller;
|
||||||
using Data;
|
using Data;
|
||||||
using Runtime.Controller;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace CameraControl
|
namespace CamControl
|
||||||
{
|
{
|
||||||
public class CameraControl : IFixedExecute
|
public class CameraControl : IFixedExecute
|
||||||
{
|
{
|
||||||
@ -13,14 +12,18 @@ namespace CameraControl
|
|||||||
private Vector3 _offset;
|
private Vector3 _offset;
|
||||||
private float _smoothSpeed;
|
private float _smoothSpeed;
|
||||||
|
|
||||||
public CameraControl(Camera camera, Transform target, CameraData cameraData)
|
public CameraControl(Camera camera, CameraData cameraData)
|
||||||
{
|
{
|
||||||
_camera = camera;
|
_camera = camera;
|
||||||
_target = target;
|
|
||||||
_offset = cameraData.offset;
|
_offset = cameraData.offset;
|
||||||
_smoothSpeed = cameraData.smoothSpeed;
|
_smoothSpeed = cameraData.smoothSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void InitCameraControl(GameObject target)
|
||||||
|
{
|
||||||
|
_target = target.transform;
|
||||||
|
}
|
||||||
public void FixedExecute()
|
public void FixedExecute()
|
||||||
{
|
{
|
||||||
if (_target == null)
|
if (_target == null)
|
||||||
@ -28,7 +31,7 @@ namespace CameraControl
|
|||||||
Vector3 desiredPosition = _target.position + _offset;
|
Vector3 desiredPosition = _target.position + _offset;
|
||||||
Vector3 smothedPosition =
|
Vector3 smothedPosition =
|
||||||
Vector3.Lerp(_camera.transform.position, desiredPosition, _smoothSpeed * Time.deltaTime);
|
Vector3.Lerp(_camera.transform.position, desiredPosition, _smoothSpeed * Time.deltaTime);
|
||||||
_camera.transform.position = smothedPosition;
|
_camera.transform.position = desiredPosition;
|
||||||
_camera.transform.LookAt(_target);
|
_camera.transform.LookAt(_target);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,8 @@
|
|||||||
using Data;
|
using System;
|
||||||
|
using Data;
|
||||||
using HexFiled;
|
using HexFiled;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using Object = UnityEngine.Object;
|
||||||
|
|
||||||
namespace Chars
|
namespace Chars
|
||||||
{
|
{
|
||||||
@ -12,6 +14,7 @@ namespace Chars
|
|||||||
private GameObject prefab;
|
private GameObject prefab;
|
||||||
private HexCell _cell;
|
private HexCell _cell;
|
||||||
private HexGrid _hexGrid;
|
private HexGrid _hexGrid;
|
||||||
|
public Action<GameObject> OnPlayerSpawned;
|
||||||
|
|
||||||
public GameObject Playerinstance => _instance;
|
public GameObject Playerinstance => _instance;
|
||||||
|
|
||||||
@ -29,8 +32,9 @@ namespace Chars
|
|||||||
if (_cell.GetNeighbor(direction))
|
if (_cell.GetNeighbor(direction))
|
||||||
{
|
{
|
||||||
_cell = _cell.GetNeighbor(direction);
|
_cell = _cell.GetNeighbor(direction);
|
||||||
_instance.transform.Translate(_cell.transform.position);
|
_curentPosition = _cell.coordinates;
|
||||||
|
|
||||||
|
_instance.transform.localPosition = _cell.transform.localPosition;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,7 +43,9 @@ namespace Chars
|
|||||||
if (!_isAlive)
|
if (!_isAlive)
|
||||||
{
|
{
|
||||||
_cell = _hexGrid.GetCellFromCoord(_curentPosition);
|
_cell = _hexGrid.GetCellFromCoord(_curentPosition);
|
||||||
_instance = Object.Instantiate(prefab, _cell.transform.position, Quaternion.identity);
|
_instance = Object.Instantiate(prefab, _cell.transform.parent);
|
||||||
|
_instance.transform.localPosition = _cell.transform.localPosition;
|
||||||
|
OnPlayerSpawned?.Invoke(_instance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
using Data;
|
using Data;
|
||||||
using HexFiled;
|
using HexFiled;
|
||||||
using Runtime.Controller;
|
using Runtime.Controller;
|
||||||
using UnityEditor.Callbacks;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Object = UnityEngine.Object;
|
using Object = UnityEngine.Object;
|
||||||
|
|
||||||
@ -13,6 +12,8 @@ namespace Chars
|
|||||||
private Player _player;
|
private Player _player;
|
||||||
private FloatingJoystick _moveJoystick;
|
private FloatingJoystick _moveJoystick;
|
||||||
private FloatingJoystick _attackJoystick;
|
private FloatingJoystick _attackJoystick;
|
||||||
|
private float _curTime;
|
||||||
|
private float _tick;
|
||||||
|
|
||||||
public PlayerControl(Player player, PlayerData playerData)
|
public PlayerControl(Player player, PlayerData playerData)
|
||||||
{
|
{
|
||||||
@ -20,12 +21,15 @@ namespace Chars
|
|||||||
var joyView = Object.Instantiate(playerData.joystickView);
|
var joyView = Object.Instantiate(playerData.joystickView);
|
||||||
_moveJoystick = joyView.MoveJoystick;
|
_moveJoystick = joyView.MoveJoystick;
|
||||||
_attackJoystick = joyView.AttackJoystick;
|
_attackJoystick = joyView.AttackJoystick;
|
||||||
|
_curTime = Time.time;
|
||||||
|
_tick = playerData.Tick;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Execute()
|
public void Execute()
|
||||||
{
|
{
|
||||||
if (_moveJoystick.Direction != Vector2.zero)
|
if (Time.time - _curTime >= _tick && _moveJoystick.Direction != Vector2.zero)
|
||||||
{
|
{
|
||||||
|
_curTime = Time.time;
|
||||||
_player.Move(VectorToDirection(_moveJoystick.Direction.normalized));
|
_player.Move(VectorToDirection(_moveJoystick.Direction.normalized));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -62,7 +66,7 @@ namespace Chars
|
|||||||
return HexDirection.NW;
|
return HexDirection.NW;
|
||||||
}
|
}
|
||||||
|
|
||||||
return HexDirection.NULL;
|
return HexDirection.W;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using CamControl;
|
||||||
using Chars;
|
using Chars;
|
||||||
using HexFiled;
|
using HexFiled;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@ -23,8 +24,11 @@ namespace Controller
|
|||||||
PlayerControl playerControl = new PlayerControl(player, data.PlayerData);
|
PlayerControl playerControl = new PlayerControl(player, data.PlayerData);
|
||||||
controllers.Add(playerControl);
|
controllers.Add(playerControl);
|
||||||
|
|
||||||
|
CameraControl cameraControl =
|
||||||
|
new CameraControl(UnityEngine.Camera.main, data.CameraData);
|
||||||
|
controllers.Add(cameraControl);
|
||||||
|
player.OnPlayerSpawned += cameraControl.InitCameraControl;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DoSomething(HexCell cell)
|
private void DoSomething(HexCell cell)
|
||||||
{
|
{
|
||||||
Debug.Log("Painted! " + cell.coordinates );
|
Debug.Log("Painted! " + cell.coordinates );
|
||||||
|
@ -10,5 +10,6 @@ namespace Data
|
|||||||
public HexCoordinates spawnPos;
|
public HexCoordinates spawnPos;
|
||||||
public GameObject playerPrefab;
|
public GameObject playerPrefab;
|
||||||
public PlayerControlView joystickView;
|
public PlayerControlView joystickView;
|
||||||
|
public float Tick;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
namespace HexFiled
|
namespace HexFiled
|
||||||
{
|
{
|
||||||
public enum HexDirection {
|
public enum HexDirection {
|
||||||
NE, E, SE, SW, W, NW, NULL
|
NE, E, SE, SW, W, NW
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class HexDirectionExtensions
|
public static class HexDirectionExtensions
|
||||||
|
Loading…
x
Reference in New Issue
Block a user