// 创建角色显示 public GameObject CreatePlayerDisplay(DefaultLoaderPlayer loaderPlayer, InputPlayerType playerType, bool Shader_RGB_Zero_Alpha_One = true, float scale = 1.0f) { if (m_PlayerConfig == null || !m_PlayerConfig.IsVaild || m_AirConfig == null || !m_AirConfig.IsVaild) { return(null); } if (playerType == InputPlayerType.none) { Debug.LogError("[CreatePlayerDisplay] InputPlayerType is None"); return(null); } if (PlayerControls.GetInstance().GetPlayer(playerType) != null) { Debug.LogError("[CreatePlayerDisplay] InputPlayerType is Exists"); return(null); } GameObject parentObj = new GameObject(m_PlayerName); var parentTrans = parentObj.transform; parentTrans.SetParent(AppConfig.GetInstance().PlayerRoot, false); parentTrans.localPosition = Vector3.zero; parentTrans.localRotation = Quaternion.identity; parentTrans.localScale = new Vector3(scale, scale, 1f); GameObject obj = new GameObject(m_PlayerName, typeof(PlayerDisplay), typeof(PlayerPartMgr)); obj.transform.SetParent(parentTrans, false); PlayerDisplay displayer = obj.GetComponent <PlayerDisplay>(); displayer.Init(loaderPlayer, playerType, Shader_RGB_Zero_Alpha_One); return(obj); }
// 是否有允许按下的按键按下 public bool IsVaildCanPressKeyPress(InputPlayerType playerType) { if (playerType == InputPlayerType.none) { return(false); } var iter = m_KeyControlMap.GetEnumerator(); while (iter.MoveNext()) { if (GetPlayerType(iter.Current.Value) == playerType) { if (GetKeyCanPress(iter.Current.Value)) { KeyCode key = (KeyCode)iter.Current.Key; bool ret = Input.GetKey(key); if (ret) { return(ret); } } } } iter.Dispose(); return(false); }
public void Init(InputPlayerType playerType, ClsnType type, float x, float y, float w, float h) { m_Type = type; m_PlayerType = playerType; m_CreateTimer = Time.realtimeSinceStartup; BoxCollider2D box = this.Box; float rw = w / 100f; if (rw < 0) { rw = -rw; } float rh = h / 100f; if (rh < 0) { rh = -rh; } box.offset = Vector2.zero; box.size = new Vector2(rw, rh); var trans = this.transform; Vector2 pos = new Vector2((x + w / 2f) / 100f, -(y + h / 2f) / 100f); trans.localPosition = pos; trans.localRotation = Quaternion.identity; }
public Clsn CreateClsnBox(InputPlayerType playerType, string name, Transform parent, float x, float y, float w, float h, bool isClsn2 = true) { Clsn r = GetClsnColliderFromPool(name); if (r == null) { return(r); } var trans = r.transform; if (trans.parent != parent) { trans.SetParent(parent, false); } ClsnType tt = isClsn2 ? ClsnType.def: ClsnType.attack; r.Init(playerType, tt, x, y, w, h); if (!r.gameObject.activeSelf) { r.gameObject.SetActive(true); } return(r); }
public void SwitchPlayer(InputPlayerType playerType, PlayerDisplay display) { switch (playerType) { case InputPlayerType._1p: m_1P = display; break; case InputPlayerType._2p: m_2P = display; break; case InputPlayerType._3p: m_3P = display; break; case InputPlayerType._4p: m_4P = display; break; } if (display != null && display.AnimationState == PlayerState.psNone) { display.ChangeState(PlayerState.psStand1); } }
public bool GetStayPos(InputPlayerType playerType, out Vector2 ret) { if (playerType == InputPlayerType.none || m_Config == null || m_Config.Players == null) { ret = Vector2.zero; return(false); } float h = ((float)Screen.height) / 2.0f; float w = ((float)Screen.width) / 2.0f; var players = m_Config.Players; switch (playerType) { case InputPlayerType._1p: ret = new Vector2(-players.p1startx, h - players.p1starty); return(true); case InputPlayerType._2p: ret = new Vector2(-players.p2startx, h - players.p2starty); return(true); case InputPlayerType._3p: ret = new Vector2(-players.p3startx, h - players.p3starty); return(true); case InputPlayerType._4p: ret = new Vector2(-players.p4startx, -players.p4starty); return(true); } ret = Vector2.zero; return(false); }
private void CheckInputValueTime(InputPlayerType type, float removeTime = 0.5f) { if (type == InputPlayerType.none) { return; } PlayerDisplay display = GetPlayer(type); if (display == null) { return; } int key = (int)type; List <InputValue> list; if (!m_KeyMsgMap.TryGetValue(key, out list) || list.Count <= 0) { return; } while (list.Count > 0) { var input = list [0]; if (UnityEngine.Time.unscaledTime - input.tick < 0.5f) { break; } list.RemoveAt(0); } }
public bool CheckPlayerCmdCommandInputOk(InputPlayerType plyType, Mugen.Cmd_Command cmd) { if (plyType == InputPlayerType.none || cmd == null) { return(false); } return(CheckPlayerCmdCommandInputOk(plyType, cmd.keyCommands)); }
bool CheckPlayerCmdCommandInputOk(InputPlayerType plyType, string[] keyCommands) { if (plyType == InputPlayerType.none || keyCommands == null || keyCommands.Length <= 0) { return(false); } return(true); }
public PlayerDisplay GetPlayer(InputPlayerType playerType) { PlayerDisplay ret = null; switch (playerType) { case InputPlayerType._1p: ret = m_1P; break; case InputPlayerType._2p: ret = m_2P; break; case InputPlayerType._3p: ret = m_3P; break; case InputPlayerType._4p: ret = m_4P; break; case InputPlayerType._5p: ret = m_5P; break; case InputPlayerType._6p: ret = m_6P; break; case InputPlayerType._7p: ret = m_7P; break; case InputPlayerType._8p: ret = m_8P; break; case InputPlayerType._9p: ret = m_9P; break; case InputPlayerType._10p: ret = m_10P; break; case InputPlayerType._11p: ret = m_11P; break; case InputPlayerType._12p: ret = m_12P; break; } return(ret); }
public int GetPlayerRunKeyValue(InputPlayerType type) { int key = (int)type; int ret; if (!m_RuntimePlayerKeyValueMap.TryGetValue(key, out ret)) { ret = 0; } return(ret); }
public List <InputValue> GetInputList(InputPlayerType type) { int key = (int)type; List <InputValue> list; if (!m_KeyMsgMap.TryGetValue(key, out list)) { list = null; } return(list); }
// 创建角色显示 public GameObject CreatePlayerDisplay(DefaultLoaderPlayer loaderPlayer, InputPlayerType playerType, bool Shader_RGB_Zero_Alpha_One = true) { if (m_PlayerConfig == null || !m_PlayerConfig.IsVaild || m_AirConfig == null || !m_AirConfig.IsVaild) { return(null); } GameObject obj = new GameObject(m_PlayerName, typeof(PlayerDisplay)); PlayerDisplay displayer = obj.GetComponent <PlayerDisplay>(); displayer.Init(loaderPlayer, playerType, Shader_RGB_Zero_Alpha_One); return(obj); }
public bool CheckPlayerCmdCommandInputOk(InputPlayerType plyType, Mugen.Cmd_Command cmd) { if (plyType == InputPlayerType.none || cmd == null) { return(false); } //#if UNITY_EDITOR if (cmd.isEditorActive) { return(true); } //#endif return(CheckPlayerCmdCommandInputOk(plyType, cmd.keyCommands)); }
public void ClearKeys(InputPlayerType type) { if (type == InputPlayerType.none) { return; } List <InputValue> list; if (m_KeyMsgMap.TryGetValue((int)type, out list)) { list.Clear(); } }
private void SendPlayerKeyControl(InputPlayerType type, int value, bool hasDown, float currentTime) { if (type == InputPlayerType.none || value == 0) { return; } int key = (int)type; List <InputValue> list; if (!m_KeyMsgMap.TryGetValue(key, out list)) { list = new List <InputValue> (); m_KeyMsgMap [key] = list; } if (!hasDown) { if (list.Count > 0) { var item = list [list.Count - 1]; if (item.keyCodeValue == value && !hasDown) { item.tick = Time.realtimeSinceStartup; return; } int v = (item.keyCodeValue & value); if (v != 0) { value = value & (~v); } if (value == 0) { return; } } } InputValue input = new InputValue(); input.keyCodeValue = value; input.tick = currentTime; if (hasDown) { input.downTick = input.tick; // Debug.LogError(input.tick.ToString()); } list.Add(input); }
private PlayerDisplay GetPlayer(InputPlayerType type) { switch (type) { case InputPlayerType._1p: return(PlayerControls.GetInstance().m_1P); case InputPlayerType._2p: return(PlayerControls.GetInstance().m_2P); case InputPlayerType._3p: return(PlayerControls.GetInstance().m_3P); case InputPlayerType._4p: return(PlayerControls.GetInstance().m_4P); } return(null); }
public void Init(DefaultLoaderPlayer loaderPlayer, InputPlayerType playerType, bool Shader_RGB_Zero_Alpha_One = true) { if (m_LoaderPlayer != null) { Clear(); } m_LoaderPlayer = loaderPlayer; m_PlayerType = playerType; CreateLuaPlayer(); var sp = this.SpriteRender; if (sp != null && sp.sharedMaterial != null) { var mat = sp.sharedMaterial; if (Shader_RGB_Zero_Alpha_One) { if (!mat.IsKeywordEnabled("_RGB_A")) { mat.EnableKeyword("_RGB_A"); } if (mat.IsKeywordEnabled("_NO_RGB_A")) { mat.DisableKeyword("_NO_RGB_A"); } } else { if (mat.IsKeywordEnabled("_RGB_A")) { mat.DisableKeyword("_RGB_A"); } if (!mat.IsKeywordEnabled("_NO_RGB_A")) { mat.EnableKeyword("_NO_RGB_A"); } } } PlayerControls.GetInstance().SwitchPlayer(playerType, this); }
public bool GetKeyPress(InputPlayerType playerType, InputControlType ctlype) { if (playerType == InputPlayerType.none || ctlype == InputControlType.none) { return(false); } var iter = m_KeyControlMap.GetEnumerator(); while (iter.MoveNext()) { if (GetPlayerType(iter.Current.Value) == playerType) { if (GetControlType(iter.Current.Value) == ctlype) { KeyCode key = (KeyCode)iter.Current.Key; return(Input.GetKey(key)); } } } iter.Dispose(); return(false); }
public PlayerDisplay GetPlayer(InputPlayerType playerType) { PlayerDisplay ret = null; switch (playerType) { case InputPlayerType._1p: ret = m_1P; break; case InputPlayerType._2p: ret = m_2P; break; case InputPlayerType._3p: ret = m_3P; break; case InputPlayerType._4p: ret = m_4P; break; } return(ret); }
public bool GetKeyPress(InputPlayerType playerType, int ctlype) { return(GetKeyPress(playerType, (InputControlType)ctlype)); }
public void SwitchPlayer(InputPlayerType playerType, PlayerDisplay display) { float x = 0f; switch (playerType) { case InputPlayerType._1p: m_1P = display; x = 100.0f; break; case InputPlayerType._2p: m_2P = display; x = ((float)Screen.width) - 100.0f; if (m_2P != null) { m_2P.IsFlipX = true; } break; case InputPlayerType._3p: m_3P = display; x = 0f; break; case InputPlayerType._4p: m_4P = display; x = 0f; break; case InputPlayerType._5p: m_5P = display; x = 0f; break; case InputPlayerType._6p: m_6P = display; x = 0f; break; case InputPlayerType._7p: m_7P = display; x = 0f; break; case InputPlayerType._8p: m_8P = display; x = 0f; break; case InputPlayerType._9p: m_9P = display; x = 0f; break; case InputPlayerType._10p: m_10P = display; x = 0f; break; case InputPlayerType._11p: m_11P = display; x = 0f; break; case InputPlayerType._12p: m_12P = display; x = 0f; break; } var cam = AppConfig.GetInstance().m_Camera; if (display != null && cam != null) { var stage = StageMgr.GetInstance(); Vector2 stayPos; if (stage.GetStayPos(playerType, out stayPos)) { var pt = cam.ScreenToWorldPoint(new Vector3(stayPos.x, stayPos.y, 0)); display.m_OffsetPos.x = pt.x; //display.m_OffsetPos.y = pt.y - 0.5f; } else { var pt = cam.ScreenToWorldPoint(new Vector3(x, 0, 0)); display.m_OffsetPos.x = pt.x; } display.InternalUpdatePos(); } if (display != null) { display.SwitchPallet((int)playerType - 1); } if (display != null && display.AnimationState == PlayerState.psNone) { if (display.LuaPly == null) { display.PlayAni(PlayerState.psStand1); } } }
private PlayerDisplay GetPlayer(int value) { InputPlayerType type = GetPlayerType(value); return(GetPlayer(type)); }
internal void _SetCtl(InputPlayerType owner, InputPlayerType target) { OwnerCtl = owner; TargetCtl = target; }
private int GetPlayerNoAndInputValue(InputPlayerType player, InputControlType keyCode, bool checkPress, bool canCombine) { return(GetPlayerNoAndInputValue((byte)player, (int)keyCode, checkPress, canCombine)); }
void CheckWuGong(InputPlayerType player, float checkTime) { }
void CheckInputs(InputPlayerType playerType, bool checkPress, float currentTime) { var player = GetPlayer(playerType); if (player == null || !player.CanInputKey()) { if (m_RuntimePlayerKeyValueMap.ContainsKey((int)playerType)) { m_RuntimePlayerKeyValueMap[(int)playerType] = 0; } return; } int value = 0; int v1 = 0; bool canCheckPress = true; var keyList = GetInputList(playerType); float downAndPressDelta = 0; if (keyList != null && keyList.Count > 0) { InputValue lastKey = keyList[keyList.Count - 1]; if (lastKey.downTick > 0) { downAndPressDelta = (currentTime - lastKey.downTick); canCheckPress = downAndPressDelta >= _cPressAndDownDeltaTime; } } if (canCheckPress) { // if (Mathf.Abs(downAndPressDelta) > float.Epsilon) // Debug.LogError(downAndPressDelta.ToString()); // 判断Press var iter = m_KeyControlMap.GetEnumerator(); while (iter.MoveNext()) { if (GetPlayerType(iter.Current.Value) == playerType) { KeyCode key = (KeyCode)iter.Current.Key; if (Input.GetKey(key) && !Input.GetKeyUp(key)) { if (GetKeyCanPress(iter.Current.Value)) { int v = (int)GetControlType(iter.Current.Value); v1 |= v; value |= v; } } } } iter.Dispose(); } // 按下优先级高于Press var it = m_KeyControlMap.GetEnumerator(); int v2 = 0; bool isNoCombine = false; while (it.MoveNext()) { var plyType = GetPlayerType(it.Current.Value); if (plyType == playerType) { KeyCode key = (KeyCode)it.Current.Key; if (Input.GetKeyDown(key) && !Input.GetKeyUp(key)) { int v = (int)GetControlType(it.Current.Value); /* * if (GetKeyCanCombine (it.Current.Value)) { * value |= v; * v2 |= v; * } * else * { * v = v & (~m_CtlMask); * value = v; * v2 = v; * v1 = 0; * }*/ // 检查一下间隔(如果上一个也是DOWN) value |= v; v2 |= v; if (!GetKeyCanCombine(it.Current.Value)) { isNoCombine = true; } } } } it.Dispose(); if (isNoCombine) { value = value & (~m_CtlMask); v1 = 0; v2 = v2 & (~m_CtlMask); } int v3 = 0; it = m_KeyControlMap.GetEnumerator(); while (it.MoveNext()) { if (GetPlayerType(it.Current.Value) == playerType) { KeyCode key = (KeyCode)it.Current.Key; if (Input.GetKeyUp(key)) { int v = (int)GetControlType(it.Current.Value); v3 |= v; } } } it.Dispose(); if (v3 != 0) { v3 = ~v3; value = value & v3; v1 = v1 & v3; v2 = v2 & v3; } bool hasDown = (value & v2) != 0; value = PreProcessInputValue(value, hasDown); // 发送给操作给角色,每个按键先发送给角色, 招式通过其他再判断 m_RuntimePlayerKeyValueMap[(int)playerType] = value; if (value != 0) { if (checkPress) { SendPlayerKeyControl(playerType, value, hasDown, currentTime); } else { // int v = value & (~v1); int v = v2; if (v != 0) { SendPlayerKeyControl(playerType, v, hasDown, currentTime); } } } }