Скрипты: Исправлена стилистика скриптов ввода
This commit is contained in:
parent
f1103fe516
commit
3ade281440
@ -243,9 +243,9 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: e3cee3b8892508d478b1c4d0fad4801c, type: 3}
|
m_Script: {fileID: 11500000, guid: e3cee3b8892508d478b1c4d0fad4801c, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
maxSize: 7.5
|
_maxSize: 7.5
|
||||||
camExpandSmoothness: 0.01
|
_camExpandSmoothness: 0.01
|
||||||
trackingPlayer: 1
|
_trackingPlayer: 1
|
||||||
_cam: {fileID: 95433828}
|
_cam: {fileID: 95433828}
|
||||||
--- !u!1 &112562703 stripped
|
--- !u!1 &112562703 stripped
|
||||||
GameObject:
|
GameObject:
|
||||||
@ -2768,11 +2768,10 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: bc14c61ebbe85804bacfb5a675a95310, type: 3}
|
m_Script: {fileID: 11500000, guid: bc14c61ebbe85804bacfb5a675a95310, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
controlType: 0
|
_leftJoystick: {fileID: 1712987976}
|
||||||
leftJoystick: {fileID: 1712987976}
|
_rightJoystick: {fileID: 2060963491}
|
||||||
rightJoystick: {fileID: 2060963491}
|
_attackJoystick: {fileID: 320155194}
|
||||||
attackJoystick: {fileID: 320155194}
|
_defendJoystick: {fileID: 1105100998}
|
||||||
defendJoystick: {fileID: 1105100998}
|
|
||||||
--- !u!114 &1102420990
|
--- !u!114 &1102420990
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -486,9 +486,9 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: e3cee3b8892508d478b1c4d0fad4801c, type: 3}
|
m_Script: {fileID: 11500000, guid: e3cee3b8892508d478b1c4d0fad4801c, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
maxSize: 7.5
|
_maxSize: 7.5
|
||||||
camExpandSmoothness: 0.01
|
_camExpandSmoothness: 0.01
|
||||||
trackingPlayer: 1
|
_trackingPlayer: 1
|
||||||
_cam: {fileID: 95433828}
|
_cam: {fileID: 95433828}
|
||||||
--- !u!1 &112562703 stripped
|
--- !u!1 &112562703 stripped
|
||||||
GameObject:
|
GameObject:
|
||||||
@ -3288,11 +3288,10 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: bc14c61ebbe85804bacfb5a675a95310, type: 3}
|
m_Script: {fileID: 11500000, guid: bc14c61ebbe85804bacfb5a675a95310, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
controlType: 0
|
_leftJoystick: {fileID: 1129072376}
|
||||||
leftJoystick: {fileID: 1129072376}
|
_rightJoystick: {fileID: 1129072379}
|
||||||
rightJoystick: {fileID: 1129072379}
|
_attackJoystick: {fileID: 1129072378}
|
||||||
attackJoystick: {fileID: 1129072378}
|
_defendJoystick: {fileID: 1129072377}
|
||||||
defendJoystick: {fileID: 1129072377}
|
|
||||||
--- !u!114 &1102420990
|
--- !u!114 &1102420990
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -1,51 +1,61 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using System;
|
|
||||||
|
|
||||||
public class CustomInput : MonoBehaviour
|
public class CustomInput : MonoBehaviour
|
||||||
{
|
{
|
||||||
public static Vector2 leftInput, rightInput;
|
#region Static fields
|
||||||
//public static Vector2 attackActionInput, protectActionInput;
|
|
||||||
//public static float rightRegistrationDeadZone = 0.3f;
|
|
||||||
|
|
||||||
public static Action OnTouchDown, OnTouchUp;
|
public static Vector2 leftInput;
|
||||||
/* public static Action OnDefendTouchDown, OnDefendTouchUp;
|
public static Vector2 rightInput;
|
||||||
public static Action OnAttackTouchDown, OnAttackTouchUp;*/
|
public static Action OnTouchDown;
|
||||||
|
public static Action OnTouchUp;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
[Header("Character Control Parameters")]
|
[Header("Character Control Parameters")]
|
||||||
public CharControlType controlType = CharControlType.UI_Joysticks;
|
|
||||||
[SerializeField]
|
[SerializeField] private DynamicJoystick _leftJoystick;
|
||||||
private DynamicJoystick leftJoystick;
|
[SerializeField] private FloatingJoystick _rightJoystick;
|
||||||
[SerializeField]
|
[SerializeField] private FixedJoystick _attackJoystick;
|
||||||
private FloatingJoystick rightJoystick;
|
[SerializeField] private FixedJoystick _defendJoystick;
|
||||||
[SerializeField]
|
|
||||||
private FixedJoystick attackJoystick, defendJoystick;
|
|
||||||
|
|
||||||
private Joystick _currentRightJoystick;
|
private Joystick _currentRightJoystick;
|
||||||
|
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
SetupDeafultControls();
|
SetupDefaultControls();
|
||||||
|
|
||||||
rightJoystick.OnTouchDown += InvokeTouchDown;
|
_rightJoystick.OnTouchDown += InvokeTouchDown;
|
||||||
rightJoystick.OnTouchUp += InvokeTouchUp;
|
_rightJoystick.OnTouchUp += InvokeTouchUp;
|
||||||
|
|
||||||
attackJoystick.OnTouchDown += InvokeTouchDown;
|
_attackJoystick.OnTouchDown += InvokeTouchDown;
|
||||||
attackJoystick.OnTouchUp += InvokeTouchUp;
|
_attackJoystick.OnTouchUp += InvokeTouchUp;
|
||||||
|
|
||||||
defendJoystick.OnTouchDown += InvokeTouchDown;
|
_defendJoystick.OnTouchDown += InvokeTouchDown;
|
||||||
defendJoystick.OnTouchUp += InvokeTouchUp;
|
_defendJoystick.OnTouchUp += InvokeTouchUp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetupDeafultControls()
|
private void Start()
|
||||||
{
|
{
|
||||||
rightJoystick.gameObject.SetActive(true);
|
ResetInput();
|
||||||
defendJoystick.gameObject.SetActive(false);
|
}
|
||||||
attackJoystick.gameObject.SetActive(false);
|
|
||||||
_currentRightJoystick = rightJoystick;
|
private void Update()
|
||||||
|
{
|
||||||
|
leftInput.x = _leftJoystick.Horizontal;
|
||||||
|
leftInput.y = _leftJoystick.Vertical;
|
||||||
|
|
||||||
|
rightInput.x = _currentRightJoystick.Horizontal;
|
||||||
|
rightInput.y = _currentRightJoystick.Vertical;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetupDefaultControls()
|
||||||
|
{
|
||||||
|
_rightJoystick.gameObject.SetActive(true);
|
||||||
|
_defendJoystick.gameObject.SetActive(false);
|
||||||
|
_attackJoystick.gameObject.SetActive(false);
|
||||||
|
_currentRightJoystick = _rightJoystick;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetupActiveJoystick(BonusType bonusType)
|
public void SetupActiveJoystick(BonusType bonusType)
|
||||||
@ -53,15 +63,16 @@ public class CustomInput : MonoBehaviour
|
|||||||
Joystick newActiveJoystick;
|
Joystick newActiveJoystick;
|
||||||
if (bonusType == BonusType.Attack)
|
if (bonusType == BonusType.Attack)
|
||||||
{
|
{
|
||||||
newActiveJoystick = attackJoystick;
|
newActiveJoystick = _attackJoystick;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
newActiveJoystick = defendJoystick;
|
newActiveJoystick = _defendJoystick;
|
||||||
}
|
}
|
||||||
rightJoystick.gameObject.SetActive(false);
|
|
||||||
defendJoystick.gameObject.SetActive(false);
|
_rightJoystick.gameObject.SetActive(false);
|
||||||
attackJoystick.gameObject.SetActive(false);
|
_defendJoystick.gameObject.SetActive(false);
|
||||||
|
_attackJoystick.gameObject.SetActive(false);
|
||||||
|
|
||||||
newActiveJoystick.gameObject.SetActive(true);
|
newActiveJoystick.gameObject.SetActive(true);
|
||||||
_currentRightJoystick = newActiveJoystick;
|
_currentRightJoystick = newActiveJoystick;
|
||||||
@ -71,37 +82,15 @@ public class CustomInput : MonoBehaviour
|
|||||||
{
|
{
|
||||||
OnTouchDown?.Invoke();
|
OnTouchDown?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InvokeTouchUp()
|
private void InvokeTouchUp()
|
||||||
{
|
{
|
||||||
OnTouchUp?.Invoke();
|
OnTouchUp?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void Start()
|
|
||||||
{
|
|
||||||
ResetInput();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ResetInput()
|
private void ResetInput()
|
||||||
{
|
{
|
||||||
leftInput = Vector2.zero;
|
leftInput = Vector2.zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Update()
|
|
||||||
{
|
|
||||||
leftInput.x = leftJoystick.Horizontal;
|
|
||||||
leftInput.y = leftJoystick.Vertical;
|
|
||||||
|
|
||||||
rightInput.x = _currentRightJoystick.Horizontal;
|
|
||||||
rightInput.y = _currentRightJoystick.Vertical;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public enum CharControlType
|
|
||||||
{
|
|
||||||
UI_Joysticks,
|
|
||||||
//Else //test purp for now
|
|
||||||
}
|
}
|
@ -1,15 +1,9 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class InputManagment : MonoBehaviour
|
public class InputManagment : MonoBehaviour
|
||||||
{
|
{
|
||||||
[SerializeField]
|
[SerializeField] private PlayerState _controllablePlayer;
|
||||||
private PlayerState _controllablePlayer;
|
[SerializeField] private CustomInput _customInput;
|
||||||
|
|
||||||
[SerializeField]
|
|
||||||
private CustomInput _customInput;
|
|
||||||
|
|
||||||
private BonusUI _bonusUIManager;
|
private BonusUI _bonusUIManager;
|
||||||
|
|
||||||
@ -24,12 +18,11 @@ public class InputManagment : MonoBehaviour
|
|||||||
|
|
||||||
private void SetupDefault()
|
private void SetupDefault()
|
||||||
{
|
{
|
||||||
_customInput.SetupDeafultControls();
|
_customInput.SetupDefaultControls();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetupBonusJoysticks(Bonus selectedBonus)
|
private void SetupBonusJoysticks(Bonus selectedBonus)
|
||||||
{
|
{
|
||||||
_customInput.SetupActiveJoystick(selectedBonus.bonusType);
|
_customInput.SetupActiveJoystick(selectedBonus.bonusType);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user