实现长按移动
This commit is contained in:
parent
36a961c130
commit
36d0b12ff8
@ -1,11 +1,3 @@
|
|||||||
public enum ERandomShopType
|
|
||||||
{
|
|
||||||
Health,
|
|
||||||
Attack,
|
|
||||||
Defence,
|
|
||||||
Gold,
|
|
||||||
}
|
|
||||||
|
|
||||||
public class EventLevel4Actor1 : ActorController
|
public class EventLevel4Actor1 : ActorController
|
||||||
{
|
{
|
||||||
ShopComm.E_ShopFloor floor = ShopComm.E_ShopFloor.F4;
|
ShopComm.E_ShopFloor floor = ShopComm.E_ShopFloor.F4;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -156,6 +157,32 @@ public class PlayerManager : Singleton<PlayerManager>
|
|||||||
this._playerController = null;
|
this._playerController = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const float KeepKeyTime = 0.2f;
|
||||||
|
Dictionary<KeyCode, float> DictKeyKeep = new Dictionary<KeyCode, float>()
|
||||||
|
{
|
||||||
|
{KeyCode.UpArrow,-1 },
|
||||||
|
{KeyCode.DownArrow,-1 },
|
||||||
|
{KeyCode.LeftArrow,-1 },
|
||||||
|
{KeyCode.RightArrow,-1 },
|
||||||
|
|
||||||
|
{KeyCode.JoystickButton8,-1 },
|
||||||
|
{KeyCode.JoystickButton10,-1 },
|
||||||
|
{KeyCode.JoystickButton11,-1},
|
||||||
|
{KeyCode.JoystickButton9,-1},
|
||||||
|
};
|
||||||
|
|
||||||
|
KeyCode[] KeepKeys = {
|
||||||
|
KeyCode.UpArrow,
|
||||||
|
KeyCode.DownArrow,
|
||||||
|
KeyCode.LeftArrow,
|
||||||
|
KeyCode.RightArrow,
|
||||||
|
|
||||||
|
KeyCode.JoystickButton8,
|
||||||
|
KeyCode.JoystickButton10,
|
||||||
|
KeyCode.JoystickButton1,
|
||||||
|
KeyCode.JoystickButton9,
|
||||||
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 检查输入
|
/// 检查输入
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -199,6 +226,51 @@ public class PlayerManager : Singleton<PlayerManager>
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
#region 长按
|
||||||
|
|
||||||
|
for(int i=0; i< KeepKeys.Length; i++)
|
||||||
|
{
|
||||||
|
KeyCode key = KeepKeys[i];
|
||||||
|
|
||||||
|
if (!Input.GetKey(key))
|
||||||
|
DictKeyKeep[key] = -1;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (DictKeyKeep[key] == -1)
|
||||||
|
DictKeyKeep[key] = Time.time;
|
||||||
|
else if(Time.time - DictKeyKeep[key] >= KeepKeyTime)
|
||||||
|
{
|
||||||
|
DictKeyKeep[key] = -1;
|
||||||
|
switch (key)
|
||||||
|
{
|
||||||
|
case KeyCode.UpArrow:
|
||||||
|
case KeyCode.JoystickButton8:
|
||||||
|
GameManager.Instance.EventManager.OnMoveInput?.Invoke(EDirectionType.UP);
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
case KeyCode.DownArrow:
|
||||||
|
case KeyCode.JoystickButton10:
|
||||||
|
GameManager.Instance.EventManager.OnMoveInput?.Invoke(EDirectionType.DOWN);
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
case KeyCode.LeftArrow:
|
||||||
|
case KeyCode.JoystickButton11:
|
||||||
|
GameManager.Instance.EventManager.OnMoveInput?.Invoke(EDirectionType.LEFT);
|
||||||
|
break;
|
||||||
|
case KeyCode.RightArrow:
|
||||||
|
case KeyCode.JoystickButton9:
|
||||||
|
GameManager.Instance.EventManager.OnMoveInput?.Invoke(EDirectionType.RIGHT);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ public class SoundManager : MonoSingleton<SoundManager>
|
|||||||
/// <param name="clipName">音频名称</param>
|
/// <param name="clipName">音频名称</param>
|
||||||
public void PlaySound(ESoundType type, string clipName)
|
public void PlaySound(ESoundType type, string clipName)
|
||||||
{
|
{
|
||||||
Debug.Log($"PlaySound {type}:{clipName} |_musicName {_musicName} | LockEnable {LockEnable} ");
|
//Debug.Log($"PlaySound {type}:{clipName} |_musicName {_musicName} | LockEnable {LockEnable} ");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
|
Loading…
Reference in New Issue
Block a user