/// <summary> /// 设置按键操作 /// </summary> /// <param name="down">是否按下</param> /// <param name="mask">当前按键</param> public void SetKey(bool down, KeyNum mask) { if (sendKey != null) { sendKey.SetKey(down, mask); } }
public void updateNumberAndSprite() { // Debug.Log("35 "+H_potion + " / " + S_potion + " / "+Key); H_PotionNum.GetComponent <Text>().text = H_potion + " / " + maxH_potion; S_PotionNum.GetComponent <Text>().text = S_potion + " / " + maxS_potion; KeyNum.GetComponent <Text>().text = Key + " / ?"; if (H_potion <= 0) { H_potion = 0; H_PotionSlot.GetComponent <Image>().sprite = H_PotionSpriteGrey; } else { H_PotionSlot.GetComponent <Image>().sprite = H_PotionSprite; } if (S_potion <= 0) { S_potion = 0; S_PotionSlot.GetComponent <Image>().sprite = S_PotionSpriteGrey; } else { S_PotionSlot.GetComponent <Image>().sprite = S_PotionSprite; } if (Key <= 0) { Key = 0; KeySlot.GetComponent <Image>().sprite = KeySpriteGrey; } else { KeySlot.GetComponent <Image>().sprite = KeySprite; } }
/// <summary> /// 按键状态判断 /// </summary> /// <param name="key">按键</param> public bool GetKey(KeyNum key){ if((midKey&key)==key||(finalKey&key)==key){ return true; } return false; }
/// <summary> /// 解析byte信息为按键数据 /// </summary> /// <param name="message">消息</param> public void Parse(ProtocolBase message) { Reset(); midKey = (KeyNum)message.getByte(); finalKey = (KeyNum)message.getByte(); // UnityEngine.Debug.LogError("last[" + lastKey + "] mid[" + midKey + "] final[" + finalKey + "]"); }
private bool isShow; //提示消息框2是否显示 void Awake() { GameObject keyNumUI = GameObject.Find("UI Root/Camera/Anchor-TopRight/Panel/Key"); //GameObject newsPanel = GameObject.Find("UI Root/Camera/Anchor-TopRight/NewsPanel"); kn = keyNumUI.gameObject.GetComponent <KeyNum>(); }
/// <summary> /// 解析byte信息为按键数据 /// </summary> /// <param name="message">消息</param> public void Parse(ProtocolBase message) { Reset(); midKey = (KeyNum)message.getByte(); finalKey = (KeyNum)message.getByte(); }
SkillBase GetSkill(KeyNum key) { if (skillList != null && skillList.skillTable[joy.key].Count > 0) { return(skillList.skillTable[joy.key][0]); } return(null); }
public void SetKey(KeyNum key,KeyNum mask){ if((mask&lastKey)!=key){ midKey=(midKey&~mask)|key; finalKey=midKey; }else if((mask&midKey)!=key){ finalKey=(finalKey&~mask)|key; } }
SkillRuntime GetSkill(KeyNum key) { if (skillList != null) { return(skillList.GetSkill(key)); } return(null); }
/// <summary> /// 按键抬起操作判断 /// </summary> /// <param name="key">按键</param> public bool GetKeyUp(KeyNum key) { if (((lastKey & key) == key && (midKey & key) != key) || ((midKey & key) == key && (finalKey & key) != key)) { return(true); } return(false); }
public override void Deserialize(ByteProtocol protocol) { skillId = (SkillId)protocol.getInt32(); // UnityEngine.Debug.LogError("get skillId" +(Int32)skillId); coolDownTime = protocol.getRatio(); animTime = protocol.getRatio(); key = (KeyNum)protocol.getByte(); base.Deserialize(protocol); }
public SkillRuntime GetSkill(KeyNum key) { SkillRuntime skill = null; if (skillTable.ContainsKey(key)) { skill = skillTable[key]; } return(skill); }
/// <summary> /// 获取按键对应的摇杆方向 /// </summary> /// <param name="key">摇杆对应按键</param> /// <returns>摇杆方向</returns> public Fixed2 GetJoyStickDirection(KeyNum key) { if (joySticks.ContainsKey(key)) { return(joySticks[key].direction.normalized); } else { return(Fixed2.zero); } }
/// <summary> /// 设置按键操作 /// </summary> /// <param name="mask">当前按键</param> /// <param name="joy">是否按下</param> public void SetJoyStick(KeyNum mask, JoyStickKey joy) { sendKey.SetKey(joy.key, mask); if (joySticks.ContainsKey(mask)) { joySticks[mask] = joy; } else { joySticks.Add(mask, joy); } }
private bool isShow; //提示消息框是否显示 void Awake() { GameObject numLabel = GameObject.Find("UI Root/Camera/Anchor-Center/KeySaleNumPanel/NumSprite/Label"); buyNum = numLabel.gameObject.GetComponent <NumLabel>(); GameObject key = GameObject.Find("UI Root/Camera/Anchor-TopRight/Panel/Key"); keyNum = key.gameObject.GetComponent <KeyNum>(); GameObject stone = GameObject.Find("UI Root/Camera/Anchor-TopRight/Panel/Stones"); stonesNumber = stone.gameObject.GetComponent <Stones>(); }
public void SetJoyStickDirection(KeyNum key, Fixed2 direction) { if (joySticks.ContainsKey(key)) { joySticks[key].direction = direction; } else { joySticks.Add(key, new JoyStickKey(key, direction)); } Key.SetKey(true, key); }
/// <summary> /// 获取按键对应的摇杆方向 /// </summary> /// <param name="key">摇杆对应按键</param> /// <returns>摇杆方向</returns> public Fixed2 GetJoyStickDirection(KeyNum key) { if (joySticks.ContainsKey(key)) { return(joySticks[key].direction); } else { string test = "|||"; foreach (var joy in joySticks) { test += "[" + joy.Key + "]"; } Debug.LogError("未同步的摇杆!!![" + key + "]" + test); return(Fixed2.zero); } }
public JoyStickKey(KeyNum key, Fixed2 direction) { this.key = key; this.direction = direction; }
/// <summary> /// 按键按下操作判断 /// </summary> /// <param name="key">按键</param> public bool GetKeyDown(KeyNum key){ if(((lastKey&key)!=key&&(midKey&key)==key)||((midKey&key)!=key&&(finalKey&key)==key)){ return true; } return false; }
/// <summary> /// 检测按键当前帧是否有抬起操作 /// </summary> /// <param name="key">按键</param> public bool GetKeyUp(KeyNum key) { return(frameKey.GetKeyUp(key)); }
/// <summary> /// 检测按键当前帧是否有按下操作 /// </summary> /// <param name="key">按键</param> public bool GetKeyDown(KeyNum key) { return(frameKey.GetKeyDown(key)); }
/// <summary> /// 设置按键操作 /// </summary> /// <param name="down">是否按下</param> /// <param name="mask">当前按键</param> public void SetKey(bool down, KeyNum mask) { sendKey.SetKey(down, mask); }
/// <summary> /// 水中操作 /// </summary> public void WaterInPlayerMove() { if (!SanMaterPlus.madFlag) { if (MoveCheack() == 1 || MoveCheack() == 2) { if (MoveCheack() == 1) { aTimeX += Time.deltaTime; AccelalationPlus(1); moveSpeed.y *= breaking; } else if (MoveCheack() == 2) { aTimeY += Time.deltaTime; AccelalationPlus(2); moveSpeed.x *= breaking; } } else if (MoveCheack() == 3) { aTimeX += Time.deltaTime; aTimeY += Time.deltaTime; AccelalationPlus(1); AccelalationPlus(2); } else if (MoveCheack() == 0) { moveSpeed.x *= breaking; moveSpeed.y *= breaking; } //左方向の入力 if (Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.LeftArrow)) { transform.localScale = new Vector3(-0.1f, 0.1f, 1); accelalationX = 0; kNum = KeyNum.Left; } //右方向の入力 if (Input.GetKeyDown(KeyCode.D) || Input.GetKeyDown(KeyCode.RightArrow)) { transform.localScale = new Vector3(0.1f, 0.1f, 1); accelalationX = 0; kNum = KeyNum.Right; } //上方向の入力 if (Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.UpArrow)) { accelalationY = 0; kNum = KeyNum.Up; } //下方向の入力 if (Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.DownArrow)) { accelalationY = 0; kNum = KeyNum.Down; } } time += Time.deltaTime; if (time > 1) { OxygenUse(); time = time - time; } }
public void SetKey(bool down, KeyNum mask) { KeyNum key = down?mask:0; SetKey(key, mask); }
/// <summary> /// 重置操作信息 /// </summary> public void Reset() { lastKey = finalKey; midKey = finalKey; }
/// <summary> /// 重置操作信息 /// </summary> protected void Reset(){ lastKey=finalKey; midKey=finalKey; }
public FrameKey() { lastKey = (KeyNum)0; midKey = (KeyNum)0; finalKey = (KeyNum)0; }