private float GetKeyActiveValue(MonobitKeySettings settings) { if (settings.keyCode == KeyCode.Horizontal && settings.axisAction == AxisAction.Positive) { if (Input.GetAxis("Horizontal") > 0.0f) { return(Math.Abs(Input.GetAxis("Horizontal"))); } return(0.0f); } else if (settings.keyCode == KeyCode.Horizontal && settings.axisAction == AxisAction.Negative) { if (Input.GetAxis("Horizontal") < 0.0f) { return(Math.Abs(Input.GetAxis("Horizontal"))); } return(0.0f); } else if (settings.keyCode == KeyCode.Horizontal && settings.axisAction == AxisAction.Zero) { if (Input.GetAxis("Horizontal") == 0.0f) { return(1.0f); } return(0.0f); } else if (settings.keyCode == KeyCode.Vertical && settings.axisAction == AxisAction.Positive) { if (Input.GetAxis("Vertical") > 0.0f) { return(Math.Abs(Input.GetAxis("Vertical"))); } return(0.0f); } else if (settings.keyCode == KeyCode.Vertical && settings.axisAction == AxisAction.Negative) { if (Input.GetAxis("Vertical") < 0.0f) { return(Math.Abs(Input.GetAxis("Vertical"))); } return(0.0f); } else if (settings.keyCode == KeyCode.Vertical && settings.axisAction == AxisAction.Zero) { if (Input.GetAxis("Vertical") == 0.0f) { return(1.0f); } return(0.0f); } else if (settings.keyCode == KeyCode.Fire1) { return(IsKeyAction("Fire1", settings.buttonAction) ? 1.0f : 0.0f); } else if (settings.keyCode == KeyCode.Fire2) { return(IsKeyAction("Fire2", settings.buttonAction) ? 1.0f : 0.0f); } else if (settings.keyCode == KeyCode.Fire3) { return(IsKeyAction("Fire3", settings.buttonAction) ? 1.0f : 0.0f); } else if (settings.keyCode == KeyCode.Jump) { return(IsKeyAction("Jump", settings.buttonAction) ? 1.0f : 0.0f); } else if (settings.keyCode == KeyCode.Everytime) { return(1.0f); } return(0.0f); }
void DoAction(MonobitKeySettings settings, float keyActiveValue) { switch (settings.actionType) { case ActionType.Move: gameObject.transform.position += gameObject.transform.right * settings.Position.x * keyActiveValue; gameObject.transform.position += gameObject.transform.up * settings.Position.y * keyActiveValue; gameObject.transform.position += gameObject.transform.forward * settings.Position.z * keyActiveValue; break; case ActionType.Rotate: gameObject.transform.Rotate(settings.Rotation * keyActiveValue); break; case ActionType.ChangeAnimLayerWeight: if (animView != null && animView.m_Animator != null) { AnimLayerInfo info = settings.layerInfo[settings.SelectLayer]; animView.m_Animator.SetLayerWeight(info.m_Index, info.m_animWeight * keyActiveValue); } break; case ActionType.ChangeAnimParam: if (keyActiveValue > 0.0f) { if (animView != null && animView.m_Animator != null) { AnimParamInfo info = settings.paramInfo[settings.SelectParam]; switch (info.m_Type) { case MonobitAnimatorView.AnimatorControllerParameterType.Bool: animView.m_Animator.SetBool(info.m_Name, info.m_boolValue); break; case MonobitAnimatorView.AnimatorControllerParameterType.Float: animView.m_Animator.SetFloat(info.m_Name, info.m_floatValue * keyActiveValue); break; case MonobitAnimatorView.AnimatorControllerParameterType.Int: animView.m_Animator.SetInteger(info.m_Name, (int)(info.m_intValue * keyActiveValue)); break; case MonobitAnimatorView.AnimatorControllerParameterType.Trigger: break; } } } break; case ActionType.Instantiate: if (keyActiveValue >= 1.0f) { switch (settings.instantiateType) { case InstantiateType.Absolute: { Quaternion rotation = Quaternion.Euler(settings.Rotation); MonobitNetwork.Instantiate(settings.instantiatePrefab.name, settings.Position, rotation, 0); } break; case InstantiateType.Relative: { Vector3 position = gameObject.transform.position; position += gameObject.transform.right * settings.Position.x; position += gameObject.transform.up * settings.Position.y; position += gameObject.transform.forward * settings.Position.z; Quaternion rotation = gameObject.transform.rotation * Quaternion.Euler(settings.Rotation); MonobitNetwork.Instantiate(settings.instantiatePrefab.name, position, rotation, 0); } break; case InstantiateType.RandomAbsolute: { Vector3 position = new Vector3(UnityEngine.Random.Range(settings.PositionMin.x, settings.PositionMax.x), UnityEngine.Random.Range(settings.PositionMin.y, settings.PositionMax.y), UnityEngine.Random.Range(settings.PositionMin.z, settings.PositionMax.z)); Quaternion rotation = Quaternion.Euler(UnityEngine.Random.Range(settings.RotationMin.x, settings.RotationMax.x), UnityEngine.Random.Range(settings.RotationMin.y, settings.RotationMax.y), UnityEngine.Random.Range(settings.RotationMin.z, settings.RotationMax.z)); MonobitNetwork.Instantiate(settings.instantiatePrefab.name, position, rotation, 0); } break; } } break; } }