public AbstractRequest GetRequester(LogicType type) { AbstractRequest request = null; requesters.TryGetValue(type, out request); return(request); }
public override double GetLogicValue(LogicType logicType) { double result; if (logicType != LogicType.Ratio) { if (logicType != LogicType.Quantity) { if (logicType != LogicType.RequestHash) { result = base.GetLogicValue(logicType); } else { result = RequestedHash; } } else { result = _filledSlots; } } else { result = _filledSlots / 100f; } return(result); }
public static bool ImportDigital(MonitorBox box, FacilityContext context) { if (File.Exists(digitalFile)) { try { List <DigitalInputChannel> channels = new List <DigitalInputChannel>(); var lines = File.ReadAllLines(digitalFile); foreach (var line in lines) { var row = line.Split('\t'); bool connected = (row[4] == "TRUE") ? true : false; LogicType type = (row[3] == "HIGH") ? LogicType.HIGH : LogicType.LOW; DigitalInputChannel channel = new DigitalInputChannel(row[0], Convert.ToInt32(row[1]), Convert.ToInt32(row[2]), connected, row[5], type); channel.AlarmAction = RegisterConverters.GetAction(row[7]); channel.Bypass = (row[6] == "TRUE") ? false : true; channel.Device = box; box.Registers.Add(channel); context.Registers.Add(channel); } context.SaveChanges(); return(true); } catch { return(false); } } else { return(false); } }
private void AddRequest(LogicType type, AbstractRequest request) { if (!requesters.ContainsKey(type)) { requesters.Add(type, request); } }
public static bool ImportOutput(GenericMonitorBox box, FacilityContext context) { if (File.Exists(outputFile)) { try { List <DigitalOutputChannel> channels = new List <DigitalOutputChannel>(); var lines = File.ReadAllLines(outputFile); foreach (var line in lines) { var row = line.Split('\t'); bool connected = (row[4] == "TRUE") ? true : false; LogicType type = (row[3] == "HIGH") ? LogicType.HIGH : LogicType.LOW; DigitalOutputChannel channel = new DigitalOutputChannel(row[0], Convert.ToInt32(row[1]), Convert.ToInt32(row[2]), connected, row[5], type); channel.OutputControl = (row[7] == "SOFTWARE") ? OutputControl.SOFTWARE : OutputControl.HARDWARE; channel.Bypass = (connected) ? false : true; channel.Device = box; box.Registers.Add(channel); context.Registers.Add(channel); } context.SaveChanges(); return(true); } catch { return(false); } } else { return(false); } }
public LogicRule(LogicType logicType, string key, string value, string value2 = "") { LogicType = logicType; LeftKey = key; Value = value; Value2 = value2; }
public string CreateTheoreticalEntity <LogicType>() where LogicType : Entity, new() { LogicType tempEntity = new LogicType(); Logic.ManageEntity(tempEntity); return(tempEntity.ID); }
public void Start() { if (sr == null) { sr = GameObject.Find("BattleSetup").GetComponent <SetupRouter>(); } moveDetection = new MoveDetection(); pLogic = GetComponent <PlayerLogic>(); tLogic = GetComponent <TrainerLogic>(); spriteRenderer = GetComponent <SpriteRenderer>(); if (pLogic != null) { logicType = LogicType.Player; endMove = pLogic.MoveEnd; } else if (tLogic != null) { logicType = LogicType.Trainer; endMove = tLogic.MoveEnd; } else { logicType = LogicType.NPC; endMove = MoveEndStub; } moveSpeedCurrent = moveSpeed; }
public void AddRequest(LogicType type, List <string> paramList) { if (CurrClientId == 0) { foreach (var client in _listClients) { try { client.Value.AddResqueueter(type, paramList); } catch (Exception e) { Console.WriteLine("{0}", e); } } } else { Client currClient; if (_listClients.TryGetValue(CurrClientId, out currClient)) { currClient.AddResqueueter(type, paramList); } else { Log.WarnLine("AddResqueueter cannot find client {0}", CurrClientId); } } }
/// <summary> /// 构造函数 /// </summary> /// <param name="field">字段名称</param> /// <param name="logicType">操作符 in = <>等</param> /// <param name="operatorType">运算符 and or</param> /// <param name="value">比较值</param> public FilterCondition(string field, LogicType logicType, OperatorType operatorType, object value) { Field = field; LogicType = logicType; OperatorType = operatorType; Value = value; }
/// <summary> /// Initializes a new instance of the <see cref="FilterTerm"/> class. /// </summary> /// <param name="filterColumn">The filterColumn<see cref="string"/>.</param> /// <param name="operand">The operand<see cref="OperandType"/>.</param> /// <param name="value">The value<see cref="object"/>.</param> /// <param name="logic">The logic<see cref="LogicType"/>.</param> /// <param name="stage">The stage<see cref="FilterStage"/>.</param> public FilterTerm(string filterColumn, OperandType operand, object value, LogicType logic = LogicType.And, FilterStage stage = FilterStage.First) { RubricName = filterColumn; Operand = operand; Value = value; Logic = logic; Stage = stage; }
/// <summary> /// 设置SQL模板或逻辑操作类型 /// </summary> /// <param name="sqlTemplateOrLogicType">SQL模板或逻辑操作类型</param> private void SetSqlTemplateOrLogicType(string sqlTemplateOrLogicType) { LogicType = GetLogicType(sqlTemplateOrLogicType); if (!LogicType.IsValid()) { SqlTemplate = sqlTemplateOrLogicType; } }
public string GetLogicTypeName(LogicType logicType) { if (logicType == LogicType.None) { return(""); } return(logicType.ToString()); }
/// <summary> /// Rule arg class constructor to abstract the creation of rules /// </summary> /// <param name="ruleId"></param> /// <param name="operands"></param> /// <param name="childRules"></param> /// <param name="logicType"></param> /// <param name="mode"></param> /// <param name="failureCode"></param> public RuleArguments(Guid ruleId, IReadOnlyList<IOperand> operands, IReadOnlyList<IRule> childRules, LogicType logicType, EvaluationMode mode, string failureCode) { RuleId = ruleId; Operands = operands; ChildRules = childRules; LogicType = logicType; Mode = mode; FailureCode = failureCode; }
public Condition(object param, CompareType compareType = CompareType.Equals, LogicType logicType = LogicType.AND) { var items = GetListItems(param, compareType, logicType); if (items.Count > 0) { this.ConditionItems.AddRange(items); } }
/// <summary> /// Initializes a new instance of the <see cref="FilterTerm"/> class. /// </summary> /// <param name="filterColumn">The filterColumn<see cref="MemberRubric"/>.</param> /// <param name="operand">The operand<see cref="OperandType"/>.</param> /// <param name="value">The value<see cref="object"/>.</param> /// <param name="logic">The logic<see cref="LogicType"/>.</param> /// <param name="stage">The stage<see cref="FilterStage"/>.</param> public FilterTerm(MemberRubric filterColumn, OperandType operand, object value, LogicType logic = LogicType.And, FilterStage stage = FilterStage.First) { Operand = operand; Value = value; Logic = logic; ValueType = filterColumn.RubricType; RubricName = filterColumn.RubricName; FilterRubric = filterColumn; Stage = stage; }
static void ChangeLogic(string cur, LogicType logic) { foreach (var temp in AllGameObjects) { if (temp.Icon == cur) { temp.logic_type = temp.logic_type | logic; } } }
internal CompositeCriteria(Criteria left, LogicType logic, Criteria right) { left.ThrowIfNullArgument(nameof(left)); right.ThrowIfNullArgument(nameof(right)); logic.ThrowIfEnumOutOfRange(); _left = left; _right = right; _logic = logic; }
private void SwitchProcedure(LogicType next) { if (_CurLogicType == LogicType.None) { GameLog.Error("---------------------MainProcedure:SwitchProcedure----------_CurLogicType= LogicType.None!!!!"); return; } //GameLog.Debug("---------------------MainProcedure:SwitchProcedure----------_CurLogicType = {0}, next = {1}", _CurLogicType, next); _CurLogicType = next; }
public void AddRequest(LogicType type, AbstractRequest request) { lock (requesters) { if (!requesters.ContainsKey(type)) { requesters.Add(type, request); } } }
public LogicRule(LogicType logicType, params LogicRule[] rules) { LogicType = logicType; if (rules != null) { foreach (var rule in rules) { Rules.Add(rule); } } }
private void HandleLogicUpdate(LogicType logicType, LogicStatus logicStatus) { for (int i = 0; i < App.GetLevelData().LogicData.Count; i++) { if (App.GetLevelData().LogicData[i].type == logicType) { App.GetLevelData().LogicData[i].fulfillmentStatus = logicStatus; } } App.Notify(Notification.LogicUpdated); }
public static LogicRuntimeData GetLogic(LogicType lt) { LogicRuntimeData ld = new LogicRuntimeData(); LogicMapping lm = ms_LogicMapping[(int)lt]; ld.LogicObj = lm.LogicInterface.CreateLogic(); ld.LogicUIObj = lm.LogicUIInterface.CreateLogicUI(); ld.LogicRes = lm.LogicResType; ld.Type = lt; return(ld); }
public static LogicValuePayload GetLogicValue(ILogicable logicable, LogicType logicType) { var value = logicable.GetLogicValue(logicType); var writable = logicable.CanLogicWrite(logicType); return(new LogicValuePayload() { value = value, writable = writable }); }
public static LogicType ToLogicType(object objOpt) { LogicType logicType = LogicType.AND; try { logicType = (LogicType)System.Enum.Parse(typeof(LogicType), Convert.ToString(objOpt), true); } catch { } return(logicType); }
static LogicMapping NewMapping <LOGIC, UI>(LogicType logicType, ResType res) where LOGIC : ILogic, new() where UI : ILogicUI, new() { LogicMapping lm = new LogicMapping(); lm.LogicResType = res; lm.LogicInterface = new LogicFactory <LOGIC>(); lm.LogicUIInterface = new LogicUIFactory <UI>(); return(lm); }
/// <summary> /// Creates a cumulative result that contains all previous dispositions and error messages /// </summary> /// <param name="result">The result.</param> /// <param name="aggregateResult">The aggregate result.</param> /// <param name="logicType">The current rule's logic type</param> public static void Aggregate(this Result result, IResult aggregateResult, LogicType logicType) { result.AddDispositions(aggregateResult.Dispositions); result.AddErrorMessages(aggregateResult.ErrorMessages); //make sure any previous failures are reported UNLESS we are an Or rule if (logicType == LogicType.And && aggregateResult.Type == ResultType.Failed) { result.Type = aggregateResult.Type; } }
public static LogicRuntimeData GetForwardLogic(LogicType lt) { if (lt < LogicType.LOGIC_MAX - 1) { return(GetLogic(++lt)); } else { LogMgr.Log("GetForwardLogic failed."); return(null); } }
public static LogicRuntimeData GetBackLogic(LogicType lt) { if (lt > LogicType.LOGIC_LOGON) { return(GetLogic(--lt)); } else { LogMgr.Log("GetBackLogic failed."); return(null); } }
public LogicStatus GetLogicStatus(LogicType type) { for (int i = 0; i < LogicData.Count; i++) { if (LogicData[i].type == type) { return(LogicData[i].fulfillmentStatus); } } return(LogicStatus.Unfulfilled); }
public void CreateRenderableEntity <LogicType, RenderType>() where LogicType : Entity, new() where RenderType : XNARenderable, new() { LogicType logicEntity = new LogicType(); RenderType renderEntity = new RenderType(); renderEntity.ChangeID(logicEntity.ID); Logic.ManageEntity(logicEntity); Graphics.ManageEntity(renderEntity); }
/// <summary> /// 获取逻辑运算符 /// </summary> /// <param name="LogicType">逻辑条件</param> /// <returns></returns> public static string GetLogicType(LogicType logicType) { switch (logicType) { case LogicType.与: return "&&"; case LogicType.或: return "||"; default: return string.Empty; } }
public void Init() { GameLog.Debug("---------------------------------------MainProcedure:Init---------------------------------------"); _CurLogicType = LogicType.Init; GameLog.Debug("------------MainProcedure:Init----------Application.dataPath = {0}", Application.dataPath); GameLog.Debug("------------MainProcedure:Init----------Application.streamingAssetsPath = {0}", Application.streamingAssetsPath); GameLog.Debug("------------MainProcedure:Init----------Application.persistentDataPath = {0}", Application.persistentDataPath); GameLog.Debug("------------MainProcedure:Init----------Application.temporaryCachePath = {0}", Application.temporaryCachePath); EventManager.RegisterEvent(DataEvent.FinishLoadGameConfig, OnFinishLoadGameConfig); EventManager.RegisterEvent(DataEvent.FinishLoadLoginScenes, OnFinishLoadLoginScenes); }
private static PledgeRule CreateRule(List<int> indices, DataType dataType, RuleType ruleType, LogicType logicType, List<object> operands, EvaluationMode mode = EvaluationMode.Active) { return new PledgeRule { Columns = indices.Select(index => new Column {Index = index}).ToList(), DataType = dataType, RuleType = ruleType, RuleId = Guid.NewGuid(), LogicType = logicType, Operands = operands, Mode = mode, Children = new List<PledgeRule>() }; }
public static ParticleSystemCompiledShaderData BuildGpuLogicPixelShader(IEnumerable<ParticleSystemLogicStep> steps, LogicType logicType, VertexShaderType vsType, bool useUserValues, bool useColours, bool storeLifeData, ContentTargetPlatform targetPlatform, bool useUserDataPositionBuffer, string pathToShaderSystem) { if (steps == null) throw new ArgumentNullException(); StringBuilder output = new StringBuilder(); Random random = new Random(); foreach (ParticleSystemLogicStep step in steps) BuildStep(step, output, 1, random); //fixup the preprocssor defines string shaderCodeFixup = GpuParticleShaderBuilder.BaseShader.Replace("_#", "#"); //insert the custom code string shaderCode = shaderCodeFixup.Replace(GpuParticleShaderBuilder.replaceMarker, output.ToString()); //build the shader header and main method. StringBuilder header = new StringBuilder(); StringBuilder methodHeader = new StringBuilder(); StringBuilder methodPS = new StringBuilder(); methodPS.Append("void PS(float4 texRandIndex : TEXCOORD0"); if (logicType != LogicType.Frame) methodPS.Append(", float4 lifeIndex : TEXCOORD1"); else methodHeader.Append("float4 lifeIndex = 0;"); if (logicType == LogicType.Once) { methodPS.Append(", float4 defaultPosition : TEXCOORD2"); methodPS.Append(", float4 defaultVelocity : TEXCOORD3"); methodPS.Append(", float4 defaultColour : TEXCOORD4"); methodPS.Append(", float4 defaultUserData : TEXCOORD5"); } else { methodHeader.Append("float4 defaultPosition = 0, defaultVelocity = 0;"); methodHeader.Append("float4 defaultColour = 1, defaultUserData = 0;"); } int colIndex = 2; methodPS.Append(", out float4 posOut : COLOR0, out float4 velOut : COLOR1"); if (useColours) methodPS.AppendFormat(", out float4 colOut : COLOR{0}", colIndex++); else methodHeader.Append("float4 colOut = 1;"); if (useUserValues) methodPS.AppendFormat(", out float4 userOut : COLOR{0}", colIndex++); else methodHeader.Append("float4 userOut = 0;"); methodPS.AppendLine(")"); methodPS.AppendLine("{"); methodPS.Append("\t"); methodPS.Append(methodHeader); methodPS.AppendLine(); methodPS.Append("\t"); methodPS.AppendLine(@"PS_Method(texRandIndex,lifeIndex, defaultPosition, defaultVelocity, defaultColour, defaultUserData,posOut, velOut, colOut, userOut);"); methodPS.AppendLine("}"); int colourIndex = -1, userIndex = -1, lifeIndex = -1; if (logicType != LogicType.Once) { int samplerIndex = 3; header.AppendLine(); header.AppendLine("#define TEXTURE_PARTICLE_METHOD"); if (useColours) { colourIndex = samplerIndex; header.AppendLine("#define USER_COLOUR_TEX"); header.AppendLine(string.Format(@"sampler2D ColourSampler : register(ps,s{0});", samplerIndex++)); } if (useUserValues) { userIndex = samplerIndex; header.AppendLine("#define USER_USER_TEX"); header.AppendLine(string.Format(@"sampler2D UserSampler : register(ps,s{0});", samplerIndex++)); } if (storeLifeData && logicType == LogicType.Frame) { lifeIndex = samplerIndex; header.AppendLine("#define USER_LIFE_TEX"); header.AppendLine(string.Format(@"sampler2D LifeSampler : register(ps,s{0});", samplerIndex++)); } if (logicType == LogicType.Frame || logicType == LogicType.FrameMove) header.AppendLine("#define ADD_VELOCITY"); } switch (vsType) { case VertexShaderType.Clone: header.AppendLine("#define VS_CLONE"); break; case VertexShaderType.Frame: header.AppendLine("#define VS_FRAME"); break; case VertexShaderType.Once: header.AppendLine("#define VS_ONCE"); break; } if (useUserDataPositionBuffer) { header.AppendLine("#define POS_WRITTEN_TO_USER"); } StringBuilder completeShader = new StringBuilder(); completeShader.Append(header); completeShader.AppendLine(); completeShader.Append(shaderCode); completeShader.AppendLine(); completeShader.Append(methodPS); completeShader.AppendLine(); completeShader.Append(techniqueCode); completeShader.AppendLine(); if (ShaderCompileDelegate == null) LinkToShaderCompiler(pathToShaderSystem); string errors; byte[] shaderBytes = ShaderCompileDelegate(completeShader.ToString(), "", targetPlatform == ContentTargetPlatform.Xbox360, out errors); if (errors != null) throw new InvalidOperationException("GPU Particle System Pixel Shader failed to compile:" + Environment.NewLine + errors); return new ParticleSystemCompiledShaderData(shaderBytes, targetPlatform == ContentTargetPlatform.Xbox360, colourIndex, userIndex, lifeIndex); }
/// <summary> /// Creates a cumulative result that contains all previous dispositions and error messages /// </summary> /// <param name="result">The result.</param> /// <param name="otherResult">The result to aggregate into the result.</param> /// <param name="logicType">The logic type</param> public static IResult Aggregate(IResult result, IResult otherResult, LogicType logicType) { var aggregateResult = new Result(result.Type); aggregateResult.AddDispositions(result.Dispositions); aggregateResult.AddErrorMessages(result.ErrorMessages); aggregateResult.AddDispositions(otherResult.Dispositions); aggregateResult.AddErrorMessages(otherResult.ErrorMessages); //make sure any previous failures are reported UNLESS we are an Or rule if (logicType == LogicType.And && otherResult.Type != ResultType.Passed) { aggregateResult.Type = otherResult.Type; } return aggregateResult; }
public ConditionLogic(LogicType type) : base(ConditionType.Logic) { LogicType = type; }
private static PledgeRule CreateRule(int index, DataType dataType, RuleType ruleType, LogicType logicType, List<object> operands, EvaluationMode mode = EvaluationMode.Active) { return CreateRule(new List<int> {index}, dataType, ruleType, logicType, operands, mode); }
/// <summary> /// 执行逻辑功能 /// </summary> /// <param name="flowChartManager">绘图管理器</param> /// <param name="logicType">逻辑类型</param> /// <param name="logicData">逻辑数据</param> /// <return>执行结果</return> public virtual bool DoLogicOperation(FlowChartManager flowChartManager, LogicType logicType, object logicData) { bool executeSuccess = true; switch (logicType) { case LogicType.Connect: // 连接图元 { executeSuccess = LogicConnect(flowChartManager, logicData); break; } case LogicType.Disconnect: // 解除连接图元 { executeSuccess = LogicDisconnect(flowChartManager, logicData); break; } case LogicType.BeforeDelete: // 删除图元之前 { executeSuccess = LogicBeforeDelete(flowChartManager, logicData); break; } case LogicType.AfterDelete: // 删除图元之后 { executeSuccess = LogicAfterDelete(flowChartManager, logicData); break; } case LogicType.Edit: // 编辑图元 { executeSuccess = LogicEdit(flowChartManager, logicData); break; } case LogicType.Paste: // 粘贴图元 { executeSuccess = LogicPaste(flowChartManager, logicData); break; } case LogicType.CreateLine: // 创建连接线 { executeSuccess = LogicCreateLine(flowChartManager, logicData); break; } case LogicType.CreateAndConnectLine: // 创建并连接连接线 { executeSuccess = LogicCreateAndConnectLine(flowChartManager, logicData); break; } case LogicType.CreateChart: // 创建绘图 { executeSuccess = LogicCreateChart(flowChartManager, logicData); break; } case LogicType.AfterLoad: // 加载绘图之后的处理 { executeSuccess = LogicAfterLoad(flowChartManager, logicData); break; } case LogicType.InitializeDataElement: // 初始化数据元 { executeSuccess = LogicInitializeDataElement(flowChartManager, logicData); break; } case LogicType.PopUpContextMenu: // 弹出右键菜单 { executeSuccess = LogicPopUpMenuStrip(flowChartManager, logicData); break; } case LogicType.CreateAtPoint: // 在指定点创建图元 { executeSuccess = LogicCreateNodeAtPoint(flowChartManager, logicData); break; } case LogicType.ViewCode: // 打开脚本 { executeSuccess = LogicViewCode(flowChartManager, logicData); break; } case LogicType.ViewFolder: // 打开文件夹 { executeSuccess = LogicViewFolder(flowChartManager, logicData); break; } case LogicType.Save: // 保存绘图 { executeSuccess = LogicSave(flowChartManager, logicData); break; } case LogicType.CompileCode: // 生成脚本 { executeSuccess = LogicCompileCode(flowChartManager, logicData); break; } case LogicType.CheckLogic: // 检查逻辑 { executeSuccess = LogicCheckLogic(flowChartManager, logicData); break; } case LogicType.ManageArguments: // 管理变量 { executeSuccess = LogicManageArguments(flowChartManager, logicData); break; } default: { executeSuccess = false; break; } } return executeSuccess; }
/// <summary> /// 执行逻辑功能 /// </summary> /// <param name="flowChartManager">流程图管理器</param> /// <param name="logicType">逻辑类型</param> /// <param name="logicData">逻辑数据</param> /// <return>执行结果</return> public bool DoLogicFunction(FlowChartManager flowChartManager, LogicType logicType, object logicData) { bool result = true; DataBaseManager dataBaseManager = DataBaseManager.GetDataBaseManager(); GraphManager graphManager = null; DataManager dataManager = null; if(flowChartManager != null) { graphManager = flowChartManager.CurrentGraphManager; dataManager = flowChartManager.CurrentDataManager; } switch(logicType) { case LogicType.Connect: // 连接操作 { object[] data = logicData as object[]; SlotGraphElement slot = data[0] as SlotGraphElement; ConnectorGraphElement connector = data[1] as ConnectorGraphElement; switch (flowChartManager.CurrentChartMode) { case ChartMode.FlowChart: // 编辑流程图模式 { List<GraphElement> list = new List<GraphElement>(); // 记录遍历过的图元的链表 if (connector.IsHeadPoint) // 连入插槽容器 { SlotContainer inSlotContainer = connector.Line.InSlotContainer; if (inSlotContainer != null) { slot.SlotContainer.EventNode = inSlotContainer.EventNode; bool enable = (inSlotContainer.EventNode != null && dataManager.IsConnect(inSlotContainer.EventNode, inSlotContainer)); // 检查是否可以更新绑定事件 if (CheckCanBindEventNode(graphManager, slot.SlotContainer, inSlotContainer.EventNode)) { ReBindEventNode(graphManager, list, slot.SlotContainer, inSlotContainer.EventNode, enable); // 重新绑定当前图元与其连出图元的事件结点 } else { slot.UnBind(); MessageBox.Show("表达式参数与事件类型不匹配!\r\n\r\n请检查连入事件结点的类型是否正确", "连接检查", MessageBoxButtons.OK, MessageBoxIcon.Information); result = false; } } } else // 连出插槽容器 { SlotContainer outSlotContainer = connector.Line.OutSlotContainer; if (outSlotContainer != null) { bool enable = (slot.SlotContainer.EventNode != null && dataManager.IsConnect(slot.SlotContainer.EventNode, slot.SlotContainer)); // 检查是否可以更新绑定事件 if (CheckCanBindEventNode(graphManager, connector.Line, slot.SlotContainer.EventNode)) { ReBindEventNode(graphManager, list, connector.Line, slot.SlotContainer.EventNode, enable); // 重新绑定当前图元与其连出图元的事件结点 } else { slot.UnBind(); MessageBox.Show("表达式参数与事件类型不匹配!\r\n\r\n请检查连入事件结点的类型是否正确", "连接检查", MessageBoxButtons.OK, MessageBoxIcon.Information); result = false; } } } if (slot.IsOutSlot && slot.SlotContainer is ConditionGraphElement) // 对条件结点连出的线要进行有效性检查 { CheckLineValid(dataManager, slot.SlotContainer); } break; } case ChartMode.AIChart: // 编辑AI图模式 { break; } } break; } case LogicType.Disconnect: // 解除连接操作 { object[] args = logicData as object[]; SlotGraphElement slot = args[0] as SlotGraphElement; ConnectorGraphElement connector = args[1] as ConnectorGraphElement; ConnectorContainer line = connector.Line; SlotContainer slotContainer = slot.SlotContainer; switch (flowChartManager.CurrentChartMode) { case ChartMode.FlowChart: // 编辑流程图模式 { List<GraphElement> list = new List<GraphElement>(); // 记录遍历的图元的链表 if (connector.IsHeadPoint) // 移出连接线的头结点 { ReBindEventNode(graphManager, list, slotContainer, null, false); // 重新绑定当前图元与其连出图元的事件结点 } else // 移出连接线的尾结点 { SlotContainer outSlotContainer = connector.Line.OutSlotContainer; if (outSlotContainer != null) { ReBindEventNode(graphManager, list, connector.Line, null, false); // 重新绑定当前图元与其连出图元的事件结点 } } if (slot.IsOutSlot && slotContainer is ConditionGraphElement) // 对条件结点连出的线要进行有效性检查 { CheckLineValid(dataManager, slotContainer); if (line.Text == "×") // 连接线无效 { line.Invalid = false; line.ShowText = false; } } break; } case ChartMode.AIChart: // 编辑AI图模式 { break; } } break; } case LogicType.BeforeDelete: // 删除之前的操作 { GraphElement graphElement = logicData as GraphElement; switch(flowChartManager.CurrentChartMode) { case ChartMode.FlowChart: // 编辑流程图模式 { if(graphElement is SlotContainer) // 当前图元是插槽容器 { SlotContainer slotContainer = graphElement as SlotContainer; if(slotContainer is ConditionGraphElement) // 对条件结点连出的线要进行有效性检查 { foreach(SlotGraphElement slot in slotContainer.GetOutSlotList()) { if(slot.Binded) { ConnectorContainer line = slot.BindingConnector.Line; if (line.Invalid) { line.Invalid = false; line.ShowText = false; } } } } } else if(graphElement is ConnectorContainer) // 当前图元是连接线 { ConnectorContainer line = graphElement as ConnectorContainer; if (line.InSlotContainer is ConditionGraphElement) // 对条件结点连出的线要进行有效性检查 { CheckLineValid(dataManager, line.InSlotContainer); } } break; } case ChartMode.AIChart: // 编辑AI图模式 { break; } } break; } case LogicType.AfterDelete: // 删除之后的操作 { List<GraphElement> graphElementList = logicData as List<GraphElement>; foreach(GraphElement graphElement in graphElementList) { List<GraphElement> list = new List<GraphElement>(); // 记录遍历过图元的链表 ReBindEventNode(graphManager, list, graphElement, null, false); // 重新设定事件结点及图元是否可用 } break; } case LogicType.Edit: // 编辑操作 { switch(flowChartManager.CurrentChartMode) { case ChartMode.FlowChart: // 流程图编辑模式 { GraphElement graphElement = logicData as GraphElement; if (graphElement is SlotContainer) { SlotContainer slotContainer = graphElement as SlotContainer; if (graphElement is ConditionGraphElement) { CheckLineValid(dataManager, slotContainer); } // 根据文本内容调整插槽容器的大小 slotContainer.AdjustElementSize(); } else if (graphElement is ConnectorContainer) { ConnectorContainer line = graphElement as ConnectorContainer; if (line.InSlotContainer != null && line.InSlotContainer is ConditionGraphElement) // 对条件结点的连接线要特殊检查 { CheckLineValid(dataManager, line.InSlotContainer); } } break; } case ChartMode.AIChart: // AI图编辑模式 { break; } } break; } case LogicType.CheckEditable: { GraphElement graphElement = logicData as GraphElement; switch(flowChartManager.CurrentChartMode) { case ChartMode.FlowChart: // 编辑流程图模式 { if (graphElement is ConnectorContainer) { ConnectorContainer line = graphElement as ConnectorContainer; if (line.InSlotContainer != null && !(line.InSlotContainer is ConditionGraphElement)) { result = false; } } break; } case ChartMode.AIChart: // 编辑AI图模式 { break; } } break; } case LogicType.CreateLine: // 创建连接线操作 { object[] args = logicData as object[]; int id = (int)args[0]; SlotGraphElement slot = args[1] as SlotGraphElement; Point p = (Point)args[2]; Helper helper = Helper.GetHelper(); switch(flowChartManager.CurrentChartMode) { case ChartMode.FlowChart: { LineGraphElement lineGraphElement = new LineGraphElement(slot.Location, p); lineGraphElement.ID = id; lineGraphElement.Name = "连接线"; lineGraphElement.TextFont = helper.TextFont; lineGraphElement.InvalidColor = Color.Brown; lineGraphElement.Init(); slot.Bind(lineGraphElement.GetConnectorList()[0]); lineGraphElement.Refresh(); graphManager.SelectedGraphElement = lineGraphElement; break; } case ChartMode.AIChart: { AILineGraphElement aiLineGraphElement = new AILineGraphElement(slot.Location, p); aiLineGraphElement.ID = id; aiLineGraphElement.Name = "AI连接线"; aiLineGraphElement.TextFont = helper.TextFont; aiLineGraphElement.InvalidColor = Color.Brown; aiLineGraphElement.Init(); slot.Bind(aiLineGraphElement.GetConnectorList()[0]); aiLineGraphElement.Refresh(); graphManager.SelectedGraphElement = aiLineGraphElement; break; } } break; } case LogicType.CreateAndConnectLine: // 创建并连接连接线 { Helper helper = Helper.GetHelper(); object[] args = logicData as object[]; int id = (int)args[0]; SlotGraphElement outSlot = args[1] as SlotGraphElement; SlotGraphElement inSlot = args[2] as SlotGraphElement; switch(flowChartManager.CurrentChartMode) { case ChartMode.FlowChart: // 流程图编辑模式 { LineGraphElement lineGraphElement = new LineGraphElement(outSlot.Location, inSlot.Location); lineGraphElement.ID = id; lineGraphElement.Name = "连接线"; lineGraphElement.TextFont = helper.TextFont; lineGraphElement.InvalidColor = Color.Brown; lineGraphElement.Init(); lineGraphElement.Refresh(); graphManager.SelectedGraphElement = lineGraphElement; break; } case ChartMode.AIChart: // AI图编辑模式 { AILineGraphElement aiLineGraphElement = new AILineGraphElement(outSlot.Location, inSlot.Location); aiLineGraphElement.ID = id; aiLineGraphElement.Name = "AI连接线"; aiLineGraphElement.TextFont = helper.TextFont; aiLineGraphElement.InvalidColor = Color.Brown; aiLineGraphElement.Init(); aiLineGraphElement.Refresh(); graphManager.SelectedGraphElement = aiLineGraphElement; break; } } break; } case LogicType.PopUpContextMenu: // 弹出右键菜单 { ButtonItem contextMenu = logicData as ButtonItem; switch(flowChartManager.CurrentChartMode) { case ChartMode.FlowChart: // 编辑流程图模式 { if (graphManager.SelectedGraphElement != null) // 有图元被选中 { contextMenu.SubItems["bAddConditionFlowChart"].Text = "创建并连接 条件结点 (<u>2</u>)"; contextMenu.SubItems["bAddActionFlowChart"].Text = "创建并连接 动作结点 (<u>3</u>)"; } else { contextMenu.SubItems["bCreateEventFlowChart"].Text = "创建事件结点 (<u>1</u>)"; } break; } case ChartMode.AIChart: // 编辑AI图模式 { if (graphManager.SelectedGraphElement != null) // 有图元被选中 { contextMenu.SubItems["bAddConditionFlowChart"].Text = "创建并连接 AI分支结点 (<u>2</u>)"; contextMenu.SubItems["bAddActionFlowChart"].Text = "创建并连接 AI动作结点 (<u>3</u>)"; } else { contextMenu.SubItems["bCreateEventFlowChart"].Text = "创建AI状态结点 (<u>1</u>)"; } break; } } break; } case LogicType.Create: // 右键菜单中创建图元 { GraphType graphType = (GraphType)logicData; DocumentManager documentManager = DocumentManager.GetDocumentManager(); switch(flowChartManager.CurrentChartMode) { case ChartMode.FlowChart: // 编辑流程图模式 { switch(graphType) { case GraphType.EventNode: // 创建事件结点 { flowChartManager.CurrentGraphManager.CreateAbbreviateGraphElement(GraphType.EventNode, false); documentManager.AddGraphType = GraphType.EventNode; documentManager.AddGraphElement = true; break; } case GraphType.ConditionNode: // 创建条件结点 { flowChartManager.CurrentGraphManager.CreateAbbreviateGraphElement(GraphType.ConditionNode, true); documentManager.AddGraphType = GraphType.ConditionNode; documentManager.AddGraphElement = true; break; } case GraphType.ActionNode: // 创建动作结点 { flowChartManager.CurrentGraphManager.CreateAbbreviateGraphElement(GraphType.ActionNode, true); documentManager.AddGraphType = GraphType.ActionNode; documentManager.AddGraphElement = true; break; } } break; } case ChartMode.AIChart: // 编辑AI图模式 { switch (graphType) { case GraphType.EventNode: // 创建AI状态结点 { if(flowChartManager.CurrentGraphManager.SelectedGraphElement != null) { flowChartManager.CurrentGraphManager.CreateAbbreviateGraphElement(GraphType.AIStateNode, true); } else { flowChartManager.CurrentGraphManager.CreateAbbreviateGraphElement(GraphType.AIStateNode, false); } documentManager.AddGraphType = GraphType.AIStateNode; documentManager.AddGraphElement = true; break; } case GraphType.ConditionNode: // 创建AI动作结点 { flowChartManager.CurrentGraphManager.CreateAbbreviateGraphElement(GraphType.AIActionNode, true); documentManager.AddGraphType = GraphType.AIActionNode; documentManager.AddGraphElement = true; break; } case GraphType.ActionNode: // 创建AI动作组结点 { flowChartManager.CurrentGraphManager.CreateAbbreviateGraphElement(GraphType.AIActionsNode, true); documentManager.AddGraphType = GraphType.AIActionsNode; documentManager.AddGraphElement = true; break; } } break; } } break; } case LogicType.CreateAtPoint: // 在指定点创建 { DocumentManager documentManager = DocumentManager.GetDocumentManager(); object[] args = logicData as object[]; int graphType = (int)args[0]; Point location = (Point)args[1]; switch(flowChartManager.CurrentChartMode) { case ChartMode.FlowChart: // 编辑流程图模式 { switch(graphType) { case 1: // 创建事件结点 { flowChartManager.CurrentGraphManager.CreateAbbreviateGraphElement(GraphType.EventNode, location, false); documentManager.AddGraphType = GraphType.EventNode; documentManager.AddGraphElement = true; break; } case 2: // 创建条件结点 { flowChartManager.CurrentGraphManager.CreateAbbreviateGraphElement(GraphType.ConditionNode, location, true); documentManager.AddGraphType = GraphType.ConditionNode; documentManager.AddGraphElement = true; break; } case 3: // 创建动作结点 { flowChartManager.CurrentGraphManager.CreateAbbreviateGraphElement(GraphType.ActionNode, location, true); documentManager.AddGraphType = GraphType.ActionNode; documentManager.AddGraphElement = true; break; } } break; } case ChartMode.AIChart: // 编辑AI图模式 { switch(graphType) { case 1: // 创建AI状态结点 { if(flowChartManager.CurrentGraphManager.SelectedGraphElement != null) { flowChartManager.CurrentGraphManager.CreateAbbreviateGraphElement(GraphType.AIStateNode, location, true); } else { flowChartManager.CurrentGraphManager.CreateAbbreviateGraphElement(GraphType.AIStateNode, location, false); } documentManager.AddGraphType = GraphType.AIStateNode; documentManager.AddGraphElement = true; break; } case 2: // 创建AI动作结点 { if(graphManager.SelectedGraphElement is SlotContainer) { flowChartManager.CurrentGraphManager.CreateAbbreviateGraphElement(GraphType.AIActionNode, location, true); documentManager.AddGraphType = GraphType.AIActionNode; documentManager.AddGraphElement = true; } break; } case 3: // 创建AI动作组结点 { if(graphManager.SelectedGraphElement is SlotContainer) { flowChartManager.CurrentGraphManager.CreateAbbreviateGraphElement(GraphType.AIActionsNode, location, true); documentManager.AddGraphType = GraphType.AIActionsNode; documentManager.AddGraphElement = true; } break; } } break; } } break; } case LogicType.ViewCode: // 查看代码 { DocumentManager documentManager = DocumentManager.GetDocumentManager(); Helper helper = Helper.GetHelper(); string relevatePath = logicData as string; switch(documentManager.CurrentChartMode) { case ChartMode.FlowChart: // 编辑流程图模式 { string path = Path.Combine(helper.OutputDir, "scripts\\Map"); path = Path.Combine(path, string.Format("{0}.lua", relevatePath)); FileInfo fi = new FileInfo(path); if(fi.Exists) // 文件存在 { try { System.Diagnostics.Process.Start(path); } catch (Exception ex) { MessageBox.Show("在查看代码文件时产生IO异常:" + ex.ToString()); } } else { MessageBox.Show(string.Format("文件{0}不存在!", path), "查看代码", MessageBoxButtons.OK, MessageBoxIcon.Information); } break; } case ChartMode.AIChart: // 编辑AI图模式 { break; } } break; } case LogicType.CompileCode: // 生成代码 { break; } case LogicType.CompileCodes: // 生成代码 { break; } case LogicType.CheckLogic: // 检查逻辑 { object[] args = logicData as object[]; dataManager = args[0] as DataManager; string name = args[1] as string; List<SlotContainer> slotContainerList = args[2] as List<SlotContainer>; List<ConnectorContainer> connectorContainerList = args[3] as List<ConnectorContainer>; TextBoxX logBox = args[4] as TextBoxX; bool showDetail = (bool)args[5]; switch(flowChartManager.CurrentChartMode) { case ChartMode.FlowChart: // 编辑流程图模式 { result = CheckFlowChartAvail(dataManager, name, slotContainerList, connectorContainerList, logBox, showDetail); break; } case ChartMode.AIChart: // 编辑AI图模式 { break; } } break; } case LogicType.ManageArguments: // 管理变量 { DocumentManager documentManager = DocumentManager.GetDocumentManager(); switch(documentManager.CurrentChartMode) { case ChartMode.FlowChart: // 编辑流程图模式 { VarManager.Program varManager = new VarManager.Program(); varManager.Show(dataBaseManager.GetJx3webConnection()); break; } case ChartMode.AIChart: // 编辑AI图模式 { flowChartManager = documentManager.CurrentFlowChartManager; if(flowChartManager == null) { MessageBox.Show("当前没有流程图被激活!", "变量管理", MessageBoxButtons.OK, MessageBoxIcon.Information); result = false; } else { } break; } } break; } case LogicType.SetCompileArgs: // 设置代码生成的参数 { FlowChartMetaDataManager flowChartMetaDataManager = logicData as FlowChartMetaDataManager; Helper helper = Helper.GetHelper(); switch(flowChartManager.CurrentChartMode) { case ChartMode.FlowChart: // 编辑流程图模式 { string fullPath = Path.Combine(helper.OutputDir, "scripts\\Map"); fullPath = Path.Combine(fullPath, flowChartManager.CurrentPath); string[] data = flowChartManager.CurrentPath.Split(new char[] { '\\' }); flowChartMetaDataManager.RootPath = helper.OutputDir; flowChartMetaDataManager.FlowChartFullPath = fullPath; flowChartMetaDataManager.FlowChartShortPath = flowChartManager.CurrentPath; flowChartMetaDataManager.FlowChartName = data[data.Length - 1]; flowChartMetaDataManager.MapName = data[0]; break; } case ChartMode.AIChart: // 编辑AI图模式 { string fullPath = Path.Combine(helper.OutputDir, "scripts\\ai"); fullPath = Path.Combine(fullPath, flowChartManager.CurrentPath); string[] data = flowChartManager.CurrentPath.Split(new char[] { '\\' }); flowChartMetaDataManager.RootPath = helper.OutputDir; flowChartMetaDataManager.FlowChartFullPath = fullPath; flowChartMetaDataManager.FlowChartShortPath = flowChartManager.CurrentPath; flowChartMetaDataManager.FlowChartName = data[data.Length - 1]; flowChartMetaDataManager.MapName = data[0]; break; } } break; } } return result; }