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