public override string AutoName() { return("TweenFade: " + ActionHelpers.GetValueLabel(Fsm, gameObject) + " " + tweenDirection + " " + ActionHelpers.GetValueLabel(value)); }
public override string ErrorCheck() { return(ActionHelpers.CheckOwnerPhysicsSetup(Owner)); }
public override string AutoName() { return(ActionHelpers.AutoNameGetProperty(this, parameterKey, value)); }
public override string AutoName() { return(ActionHelpers.AutoName("ReadStickValue", stick, storeVector2Value)); }
public override void OnSceneGUI() { var action = target as HutongGames.PlayMaker.Actions.SetVelocity2d; if (action == null) // shouldn't happen! { return; } var go = action.Fsm.GetOwnerDefaultTarget(action.gameObject); if (go == null) { return; } var transform = go.transform; var space = action.space; var velocity = action.vector.IsNone ? Vector2.zero : action.vector.Value; if (!action.x.IsNone) { velocity.x = action.x.Value; } if (!action.y.IsNone) { velocity.y = action.y.Value; } if (space == Space.Self) { velocity = transform.TransformDirection(velocity); } var constrainX = action.vector.IsNone && action.x.IsNone; var constrainY = action.vector.IsNone && action.y.IsNone; var origin = transform.position; toPos.x = origin.x + velocity.x; toPos.y = origin.y + velocity.y; toPos.z = origin.z; ActionHelpers.DrawArrow(origin, toPos, PlayMakerPrefs.ArrowColor); //if (EditorApplication.isPlayingOrWillChangePlaymode) return; // editor var newPosition = Handles.DoPositionHandle(toPos, space == Space.Self ? go.transform.rotation : Quaternion.identity); newPosition.z = origin.z; newPosition -= origin; if (space == Space.Self) { newPosition = go.transform.InverseTransformDirection(newPosition); } if (constrainX) { newPosition.x = origin.x; } if (constrainY) { newPosition.y = origin.y; } if (Math.Abs(newPosition.x) < 0.0001f) { newPosition.x = 0; } if (Math.Abs(newPosition.y) < 0.0001f) { newPosition.y = 0; } action.vector.Value = new Vector2(newPosition.x, newPosition.y); action.x.Value = newPosition.x; action.y.Value = newPosition.y; //ActionHelpers.DrawTexture(newPosition, FsmEditorStyles.RightArrow, 45, Vector2.zero); if (GUI.changed) { FsmEditor.EditingActions(); //Debug.Log("Save Actions"); //FsmEditor.SaveActions(); } }
void Ggop() { GameObject go = Fsm.GetOwnerDefaultTarget(gameObject); if (go == null) { return; } if (go != goLastFrame) { fsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value); goLastFrame = go; } if (fsm == null) { return; } FsmInt fsmInt = fsm.FsmVariables.GetFsmInt(variableName.Value); if (fsmInt == null) { return; } storeFsmValue = fsmInt.Value; var v1 = storeFsmValue; var v2 = Value.Value; if (ModifyFsmValue.Value) { switch (operation) { case Operation.Add: fsmInt.Value = v1 + v2; StoreResult.Value = fsmInt.Value; break; case Operation.Subtract: fsmInt.Value = v1 - v2; StoreResult.Value = fsmInt.Value; break; case Operation.Multiply: fsmInt.Value = v1 * v2; StoreResult.Value = fsmInt.Value; break; case Operation.Divide: fsmInt.Value = v1 / v2; StoreResult.Value = fsmInt.Value; break; case Operation.Min: fsmInt.Value = Mathf.Min(v1, v2); StoreResult.Value = fsmInt.Value; break; case Operation.Max: fsmInt.Value = Mathf.Max(v1, v2); StoreResult.Value = fsmInt.Value; break; } } else { switch (operation) { case Operation.Add: StoreResult.Value = v1 + v2; break; case Operation.Subtract: StoreResult.Value = v1 - v2; break; case Operation.Multiply: StoreResult.Value = v1 * v2; break; case Operation.Divide: StoreResult.Value = v1 / v2; break; case Operation.Min: StoreResult.Value = Mathf.Min(v1, v2); break; case Operation.Max: StoreResult.Value = Mathf.Max(v1, v2); break; } } }
public override string AutoName() { return(ActionHelpers.AutoName(this, ImageFillAmount)); }
public override string AutoName() { return(ActionHelpers.AutoName(this, intVariable, add)); }
public override string AutoName() { return((activate.Value ? "Activate " : "Deactivate ") + ActionHelpers.GetValueLabel(Fsm, gameObject)); }
public override string AutoName() { return(ActionHelpers.AutoName("ButtonComboEvent", buttons)); }
bool ShouldApplyForce(GameObject go) { int mask = ActionHelpers.LayerArrayToLayerMask(layerMask, invertMask.Value); return(((1 << go.layer) & mask) > 0); }
public void ActionSelectionChange(Gambit gambit, GambitActionTypes selectedValue) { ActionHelpers.AddActionToGambit(gambit, selectedValue); }
public override string AutoName() { return(ActionHelpers.AutoNameRange(this, min, max)); }
void DoBoxCast() { center = Fsm.GetOwnerDefaultTarget(fromGameObject).transform.position; RaycastHit hitInfo; if (ignoreTriggerColliders.Value == true) { Physics.BoxCast(center, halfExtents.Value, direction.Value, out hitInfo, orientation.Value = Quaternion.identity, maxDistance.Value, ActionHelpers.LayerArrayToLayerMask(layerMask, invertMask.Value), QueryTriggerInteraction.Ignore); } else { Physics.BoxCast(center, halfExtents.Value, direction.Value, out hitInfo, orientation.Value = Quaternion.identity, maxDistance.Value, ActionHelpers.LayerArrayToLayerMask(layerMask, invertMask.Value), QueryTriggerInteraction.Collide); } Fsm.RaycastHitInfo = hitInfo; var didHit = hitInfo.collider != null; storeDidHit.Value = didHit; if (didHit) { storeHitObject.Value = hitInfo.collider.GetComponent <Collider>().gameObject; storeHitPoint.Value = Fsm.RaycastHitInfo.point; storeHitNormal.Value = Fsm.RaycastHitInfo.normal; storeHitDistance.Value = Fsm.RaycastHitInfo.distance; Fsm.Event(hitEvent); } }
private void DoRaycast() { repeat = repeatInterval.Value; if (Math.Abs(distance.Value) < Mathf.Epsilon) { return; } var originPos = fromPosition.Value; if (_transform != null) { originPos.x += _transform.position.x; originPos.y += _transform.position.y; } var rayLength = Mathf.Infinity; if (distance.Value > 0) { rayLength = distance.Value; } var dirVector2 = direction.Value.normalized; // normalized to get the proper distance later using fraction from the rayCastHitinfo. if (_transform != null && space == Space.Self) { var dirVector = _transform.TransformDirection(new Vector3(direction.Value.x, direction.Value.y, 0f)); dirVector2.x = dirVector.x; dirVector2.y = dirVector.y; } RaycastHit2D hitInfo; if (minDepth.IsNone && maxDepth.IsNone) { hitInfo = Physics2D.Raycast(originPos, dirVector2, rayLength, ActionHelpers.LayerArrayToLayerMask(layerMask, invertMask.Value)); } else { var _minDepth = minDepth.IsNone? Mathf.NegativeInfinity : minDepth.Value; var _maxDepth = maxDepth.IsNone? Mathf.Infinity : maxDepth.Value; hitInfo = Physics2D.Raycast(originPos, dirVector2, rayLength, ActionHelpers.LayerArrayToLayerMask(layerMask, invertMask.Value), _minDepth, _maxDepth); } Fsm.RecordLastRaycastHit2DInfo(Fsm, hitInfo); var didHit = hitInfo.collider != null; storeDidHit.Value = didHit; if (didHit) { storeHitObject.Value = hitInfo.collider.gameObject; storeHitPoint.Value = hitInfo.point; storeHitNormal.Value = hitInfo.normal; storeHitDistance.Value = hitInfo.distance; storeHitFraction.Value = hitInfo.fraction; Fsm.Event(hitEvent); } if (debug.Value) { var start = new Vector3(originPos.x, originPos.y, 0); if (didHit) { Debug.DrawLine(start, storeHitPoint.Value, debugColor.Value); } else { var debugRayLength = Mathf.Min(rayLength, 1000); var dirVector3 = new Vector3(dirVector2.x, dirVector2.y, 0); var end = start + dirVector3 * debugRayLength; Debug.DrawLine(start, end, debugColor.Value); } } }
public override string AutoName() { return(ActionHelpers.AutoName("ReadButtonValue", button, storeFloatValue)); }
public void DrawPreview(object fieldValue) { if (!showPreview) { return; } var area = ActionHelpers.GetControlPreviewRect(100f); var axisCenter = ActionHelpers.DrawAxisXY(area); Handles.color = previewColor; // init min/max sizes for drawing var max = 40f; var min = 0f; if (maxLength.Value > 0) { min = max * (minLength.Value / maxLength.Value); } // setup x/y scales to fit in area var scaleX = 1f; var scaleY = yScale.Value; if (Mathf.Abs(scaleY) > 1f) { scaleX = 1f / scaleY; scaleY = 1f; } switch (shape) { case Option.Circle: ActionHelpers.DrawOval(axisCenter, max * scaleX, max * scaleY); ActionHelpers.DrawOval(axisCenter, min * scaleX, min * scaleY); break; case Option.Rectangle: ActionHelpers.DrawRect(axisCenter, max * scaleX, max * scaleY); ActionHelpers.DrawRect(axisCenter, min * scaleX, min * scaleY); break; case Option.InArc: var fromAngle = floatParam1.Value; var toAngle = floatParam2.Value; ActionHelpers.DrawArc(axisCenter, fromAngle, toAngle, max * scaleX, max * scaleY); ActionHelpers.DrawArc(axisCenter, fromAngle, toAngle, min * scaleX, min * scaleY); ActionHelpers.DrawSpoke(axisCenter, fromAngle, min, max, scaleX, scaleY); ActionHelpers.DrawSpoke(axisCenter, toAngle, min, max, scaleX, scaleY); break; case Option.AtAngles: var angleStep = floatParam1.Value; if (angleStep < 1) { angleStep = 1; } // make sure we draw at least a dot (should be a better way?!) if (max - min < 1.4f) { min = max - 1.4f; } for (float angle = 0; angle < 360; angle += angleStep) { ActionHelpers.DrawSpoke(axisCenter, angle, min, max, scaleX, scaleY); } break; default: throw new ArgumentOutOfRangeException(); } Handles.color = Color.white; }
public override string AutoName() { return(ActionHelpers.AutoName(this, audioClip)); }
public override string AutoName() { return(ActionHelpers.AutoName("GetEventFloat", getVector3Data)); }
public override string AutoName() { return(ActionHelpers.AutoNameConvert(this, boolVariable, stringVariable)); }
public override string AutoName() { return("SaveVariable: " + ActionHelpers.GetValueLabel(variable.NamedVar)); }
void FindObjectInRange() { if (!isProxyValid()) { return; } GameObject go = Fsm.GetOwnerDefaultTarget(scanOrigin); GameObject listOwner = Fsm.GetOwnerDefaultTarget(arrayListOwner); float range = scanRange.Value; if (ignoreTriggerColliders.Value == true) { Collider[] colliders = Physics.OverlapSphere(go.transform.position, range, ActionHelpers.LayerArrayToLayerMask(layerMask, invertMask.Value), QueryTriggerInteraction.Ignore); if (colliders.Length == 0) { Fsm.Event(ErrorEvent); } foreach (Collider col in colliders) { proxy.Add(col.gameObject, "gameObject"); } } else { Collider[] colliders = Physics.OverlapSphere(go.transform.position, range, ActionHelpers.LayerArrayToLayerMask(layerMask, invertMask.Value), QueryTriggerInteraction.Collide); if (colliders.Length == 0) { Fsm.Event(ErrorEvent); } foreach (Collider col in colliders) { proxy.Add(col.gameObject, "gameObject"); } } // Collider[] colliders = Physics.OverlapSphere(go.transform.position, range, ActionHelpers.LayerArrayToLayerMask(layerMask, invertMask.Value),QueryTriggerInteraction.Ignore); Finish(); }
public override string AutoName() { return(ActionHelpers.AutoName(this, objectVariable, compareTo)); }
public override string AutoName() { return(ActionHelpers.AutoName(this, axisName, store)); }
public override string AutoName() { return(ActionHelpers.AutoName(this, volume)); }
public override string AutoName() { return(ActionHelpers.AutoNameSetVar("SetString", stringVariable, stringValue)); }
/* Not sure it's a good idea to range check at edit time since it can change at runtime * public override string ErrorCheck() * { * if (index.Value<0 || index.Value >= array.Length) * { * return "Index out of Range. Please select an index between 0 and the number of items -1. First item is index 0."; * } * return ""; * }*/ #if UNITY_EDITOR public override string AutoName() { return(ActionHelpers.GetValueLabel(storeValue.NamedVar) + " = " + array.Name + "[" + ActionHelpers.GetValueLabel(index) + "]"); }
public override string ErrorCheck() { return(ActionHelpers.CheckPhysics2dSetup(Fsm.GetOwnerDefaultTarget(gameObject))); }
bool DoSphereCast() { if (distance.Value == 0) { return(false); } var go = Fsm.GetOwnerDefaultTarget(fromGameObject); var originPos = go != null ? go.transform.position : fromPosition.Value; var rayLength = Mathf.Infinity; if (distance.Value > 0) { rayLength = distance.Value; } var dirVector = direction.Value; if (go != null && space == Space.Self) { dirVector = go.transform.TransformDirection(direction.Value); } if (debug.Value) { var debugRayLength = Mathf.Min(rayLength, 1000); Debug.DrawLine(originPos, originPos + dirVector * debugRayLength, debugColor.Value); } RaycastHit hitInfo; Physics.SphereCast(originPos, radius.Value, dirVector, out hitInfo, rayLength, ActionHelpers.LayerArrayToLayerMask(layerMask, invertMask.Value)); Fsm.RaycastHitInfo = hitInfo; var didHit = hitInfo.collider != null; storeDidHit.Value = didHit; return(didHit); }
public override string AutoName() { return("Set FSM Variable: " + ActionHelpers.GetValueLabel(variableName)); }