public override void Execute(BattleObject obj, GameAction action) { //Arguments float xFactor = (float)GetArgument("xFactor", obj, action, 0); //Variables from fighter float change_x = obj.GetFloatVar(TussleConstants.MotionVariableNames.XSPEED); float xPref = obj.GetFloatVar(TussleConstants.MotionVariableNames.XPREF); //Values from settings float friction = Settings.current_settings.friction_ratio; float air_control = Settings.current_settings.aircontrol_ratio; if (obj.GetBoolVar(TussleConstants.FighterVariableNames.IS_GROUNDED)) { xFactor = xFactor * friction; } else { xFactor = xFactor * air_control; } if (change_x > xPref) { float diff = change_x - xPref; change_x -= Mathf.Min(diff, xFactor); } else if (change_x < xPref) { float diff = xPref - change_x; change_x += Mathf.Min(diff, xFactor); } //Finally, update our actual speed obj.SendMessage("ChangeXSpeed", change_x); }
public object GetData(BattleObject owner, GameAction action) { if (source == SubactionSource.CONSTANT) { if (type == SubactionVarType.STRING) { return(data); } else if (type == SubactionVarType.INT) { return(int.Parse(data)); } else if (type == SubactionVarType.FLOAT) { return(float.Parse(data)); } else if (type == SubactionVarType.BOOL) { return(bool.Parse(data)); } else { Debug.LogError("SubactionVarData incorrect type: " + type); return(null); } } else if (source == SubactionSource.OWNER) { if (type == SubactionVarType.STRING) { return(owner.GetStringVar(data)); } else if (type == SubactionVarType.INT) { return(owner.GetIntVar(data)); } else if (type == SubactionVarType.FLOAT) { return(owner.GetFloatVar(data)); } else if (type == SubactionVarType.BOOL) { return(owner.GetBoolVar(data)); } else { Debug.LogError("SubactionVarData incorrect type: " + type); return(null); } } else if (source == SubactionSource.ACTION) { if (type == SubactionVarType.STRING) { return(action.GetStringVar(data)); } else if (type == SubactionVarType.INT) { return(action.GetIntVar(data)); } else if (type == SubactionVarType.FLOAT) { return(action.GetFloatVar(data)); } else if (type == SubactionVarType.BOOL) { return(action.GetBoolVar(data)); } else { Debug.LogError("SubactionVarData incorrect type: " + type); return(null); } } else { Debug.LogError("SubactionVarData incorrect source: " + source); return(null); } }