public static float GetDistanceRatioValue(CONTROLTYPE type, float ratio) { float retVal = 0.0f; int control = (int)type; if (ratio < CONTROLS[control].Start.X) { retVal = (CONTROLS[control].StartVel.Y / CONTROLS[control].StartVel.X) * (ratio - CONTROLS[control].Start.X) + CONTROLS[control].Start.Y; } else if (ratio > CONTROLS[control].End.X) { retVal = (CONTROLS[control].EndVel.Y / CONTROLS[control].EndVel.X) * (ratio - CONTROLS[control].End.X) + CONTROLS[control].End.Y; } else { float _ratio = (ratio - CONTROLS[control].Start.X) / (CONTROLS[control].End.X - CONTROLS[control].Start.X); float inv_ratio = 1.0f - _ratio; float a = inv_ratio * inv_ratio * inv_ratio; float b = 3.0f * _ratio * (inv_ratio * inv_ratio); float c = 3.0f * (_ratio * _ratio) * inv_ratio; float d = _ratio * _ratio * _ratio; retVal = a * CONTROLS[control].Start.Y + b * (CONTROLS[control].Start.Y + CONTROLS[control].StartVel.Y) + c * (CONTROLS[control].End.Y + CONTROLS[control].EndVel.Y) + d * CONTROLS[control].End.Y; } retVal = (float)Math.Min(1.0f, Math.Max(0.0f, (double)retVal)); return(retVal); }
void ChangeControlType(CONTROLTYPE type) { this.controlType = type; if (playerShoot) { playerShoot.SetControlType((int)type); } }
public void ChangeControls(Toggle option) { if(option == TouchMove) DirectionalMove.isOn = !TouchMove.isOn; else if(option == DirectionalMove) TouchMove.isOn = !DirectionalMove.isOn; if (TouchMove.isOn) controlConfig = CONTROLTYPE.touchMove; else controlConfig = CONTROLTYPE.directionalMove; PlayerPrefs.SetInt("ControlConfig", (int)controlConfig); }
// Update is called once per frame void Update() { if (!isLocalPlayer) { return; } //Debug.Log(controlType); switch (controlType) { case CONTROLTYPE.GAMEPAD: GamePadUpdate(); if (!joyStick) { break; } if (!Mathf.Approximately(joyStick.GetXAxis(), 0.0f) || !Mathf.Approximately(joyStick.GetYAxis(), 0.0f)) { controlType = (CONTROLTYPE.MOBILE); } break; case CONTROLTYPE.MOBILE: MobileUpdate(); break; default: KeyboardUpdate(); if (!joyStick) { break; } if (!Mathf.Approximately(joyStick.GetXAxis(), 0.0f) || !Mathf.Approximately(joyStick.GetYAxis(), 0.0f)) { controlType = (CONTROLTYPE.MOBILE); } break; } string itemName = playerGear.GetItemName(itemIndex); //Debug.Log("ItemChange" + itemIndex + " - " + itemName); go = playerGear.GetItem(itemName); playerWeapon.GetComponent <SpriteRenderer>().sprite = weaponSprite[itemName]; }
public void ChangeControls(Toggle option) { if (option == TouchMove) { DirectionalMove.isOn = !TouchMove.isOn; } else if (option == DirectionalMove) { TouchMove.isOn = !DirectionalMove.isOn; } if (TouchMove.isOn) { controlConfig = CONTROLTYPE.touchMove; } else { controlConfig = CONTROLTYPE.directionalMove; } PlayerPrefs.SetInt("ControlConfig", (int)controlConfig); }
void Awake() { if(!Application.isMobilePlatform) { this.gameObject.SetActive(false); Volume.GetComponent<RectTransform>().localPosition = new Vector3(0, Volume.GetComponent<RectTransform>().localPosition.y, 0); } else if(Application.isMobilePlatform) { if (PlayerPrefs.GetInt("ControlConfig") == 0) { TouchMove.isOn = true; controlConfig = CONTROLTYPE.touchMove; } else { DirectionalMove.isOn = true; controlConfig = CONTROLTYPE.directionalMove; ChangeControls(TouchMove); } } }
void Awake() { if (!Application.isMobilePlatform) { this.gameObject.SetActive(false); Volume.GetComponent <RectTransform>().localPosition = new Vector3(0, Volume.GetComponent <RectTransform>().localPosition.y, 0); } else if (Application.isMobilePlatform) { if (PlayerPrefs.GetInt("ControlConfig") == 0) { TouchMove.isOn = true; controlConfig = CONTROLTYPE.touchMove; } else { DirectionalMove.isOn = true; controlConfig = CONTROLTYPE.directionalMove; ChangeControls(TouchMove); } } }
public void Set_ByCombin(string strCombin) { if (strCombin == null) return; string[] chs = new string[] { strSplit }; string[] strs = strCombin.Split(chs, StringSplitOptions.None); if (strs == null || strs.Length != MaxUnitLen) { return; } int i = 0; try { Caption = strs[i++]; Table = strs[i++]; Fld = strs[i++]; Value = strs[i++]; CtrlType = (CONTROLTYPE)int.Parse(strs[i++]); bCanShow = bool.Parse(strs[i++]); bCanReadOnly = bool.Parse(strs[i++]); OrderNo = int.Parse(strs[i++]); bHideInBrief = bool.Parse(strs[i++]); bEvent = bool.Parse(strs[i++]); clrFore = FF.Fun.MyConvert.CombinStr2Color(strs[i++]); clrBK = FF.Fun.MyConvert.CombinStr2Color(strs[i++]); //FF.Debug.Log("strComBin:" + "Caption:" + Caption + " Color:" + clrBK.ToString()); bShow = bool.Parse(strs[i++]); bReadOnly = bool.Parse(strs[i++]); aryCombox = FF.Fun.MyConvert.CombinStr2ary(strs[i++]); } catch (Exception e) { FF.Ctrl.MsgBox.ShowWarn("XEdeitView.strComBin转换发生错误!" + " " + e.Message); return; } }
public void SetControlType(CONTROLTYPE a_controlType) { m_currentControlMethod = a_controlType; }
// Use this for initialization void Start() { m_currentControlMethod = CONTROLTYPE.AI; }
public void SetControlType(int type) { controlType = (CONTROLTYPE)type; }