// Use this for initialization void Start() { SignalFactory.GetInstance <WarBuildChangeLegion>().AddListener(changeLegion); Vector3 v11 = new Vector3(0f, 6f, -6f); Vector3 v21 = new Vector3(-1f, 6f, -6f); Vector3 v22 = new Vector3(1f, 6f, -6f); Vector3 v31 = new Vector3(-1f, 8.5f, -6f); Vector3 v32 = new Vector3(1f, 8.5f, -6f); Vector3 v33 = new Vector3(-1f, 5.5f, -6f); Vector3 v41 = new Vector3(-1f, 8.5f, -6f); Vector3 v42 = new Vector3(1f, 8.5f, -6f); Vector3 v43 = new Vector3(-1f, 5.5f, -6f); Vector3 v44 = new Vector3(1f, 5.5f, -6f); buffPosDic[11] = v11; buffPosDic[21] = v21; buffPosDic[22] = v22; buffPosDic[31] = v31; buffPosDic[32] = v32; buffPosDic[33] = v33; buffPosDic[41] = v41; buffPosDic[42] = v42; buffPosDic[43] = v43; buffPosDic[44] = v44; }
private List <IDatablockModel> GetFakeDatablockModels() { var output = new List <IDatablockModel>(); for (int i = 0; i < 10; i++) { var signalModels = new List <SignalModel>(); for (int j = 0; j < 10; j++) { var ctx = new SignalModelContext { Index = j, DbIndex = i, CpuIndex = 0, Name = $"Signal {i}-{j}", DbNumber = 4000 + i, DataTypeStr = "Real" }; var signal = SignalFactory.Create(ctx); signalModels.Add(signal); } IDatablockModel datablockModel = new DatablockModel { }; output.Add(datablockModel); } return(output); }
private void tvSignalList_DoubleClick(object sender, EventArgs e) { string selStr = tvSignalList.SelectedNode.Text; SignalProp prop = SignalFactory.getSigPropByName(selStr, sigList); timerGetCurSig.Enabled = false; if (null != prop) { tlog(prop.ToString()); curSignal = SignalFactory.buildController(prop); tlog(prop.ToString()); showMap(prop.SignalID); showSigInfo(prop); rbManSpec.Checked = true; if (curSignal.connect()) { timerGetCurSig.Enabled = true; } else { lblSignalName.Text = "信号机:" + prop.SignalName + " 连接失败"; } } else { lblSignalName.Text = "未选中信号机"; } }
void OnEnable() { if (state == StarState.Doing) { SignalFactory.GetInstance <WarBuildChangeLegion>().AddListener(OnBuildChangeTeam); } }
/** 兵营改变势力 */ public void OnBuildChangeTeam(UnitData buildUnitData, int preTeam, int targetTeam) { if (buildUnitData.initLegionId == War.ownLegionData.legionId && buildUnitData.heroData != null) { state = StarState.Fail; SignalFactory.GetInstance <WarBuildChangeLegion>().RemoveListener(OnBuildChangeTeam); } }
public void OnButtonClick() { SignalFactory.GetInstance <GMSignal>().Dispatch(vo, meInput.text); // C_GM_GameCommand_0x40 msg = new C_GM_GameCommand_0x40(); // msg.content = vo.enPart + " " + meInput.label.text; // Debugger.Log("GM : " + msg.content); // packetManager.SendMessage<C_GM_GameCommand_0x40>(msg); }
private void InitSignals() { _signals = SignalFactory.CreateAllSignals(); foreach (var signal in _signals) { SetupSignal(signal); } }
private void Awake() { _instance = this; _signalDictionary = new Dictionary <SignalKey, SignalData>(); foreach (var signalData in _signals) { _signalDictionary.Add(signalData.Key, signalData); } }
protected override void OnAwake() { base.OnAwake(); Init(); // 初始化更新器 InitUpdateHandle(); // 监听--建筑归属改变 SignalFactory.GetInstance <WarBuildChangeLegion>().AddListener(OnBuildChangeLegion); }
private void showState(SignalProp prop) { if (null == prop || prop.SignalID.Equals("")) { return; } String signal = prop.SignalID; if (null == curSignal || !signal.Equals(curSignal.Prop.SignalID.ToUpper())) { showMap(signal); } prop = SignalFactory.getSigProp(signal, sigList); int idx = 0; Trace.WriteLine(" showState: " + prop.ToString()); try { // 东/南/西/北 for (int i = 0; i < 4; i++) { //直/左/右/人 for (int j = 0; j < 4; j++) { idx = i * 4 + j + 1; string str = "pb" + idx; PictureBox pb = (PictureBox)getCtrlByName(str); //if (pb == null) // continue; if (pb != null) { if (idx > prop.State.Length) { continue; } string c = prop.State.Substring(idx - 1, 1); byte s = byte.Parse(c); Point p = prop.Pos[idx - 1]; // Trace.WriteLine(" point: " + p.ToString() + " ang: " + prop.Angle[i]); showAState(pb, p, prop.Angle[i], idx, s); } } } } catch (Exception ex) { Trace.TraceError("showstate error: " + ex.StackTrace); } }
public void Flatten_MismatchedContext_Throws() { // Arrange var signal1 = new SignalFactory().CreateSignal <int>(); var signal2 = new SignalFactory().CreateSignal(signal1); // Act Action action = () => signal2.Flatten(); // Assert Assert.Throws <InvalidOperationException>(action); }
public void AnyChange_MismatchedContext_Throws() { // Arrange var signal1 = new SignalFactory().CreateSignal <int>(); var signal2 = new SignalFactory().CreateSignal <int>(); // Act Action action = () => new[] { signal1, signal2 }.AnyChange(); // Assert Assert.Throws <InvalidOperationException>(action); }
protected override void OnDestroy() { Debug.LogFormat("<color=wihte> war scene destorey</color>"); //Coo.plotTalkManager.cleanTipsInfo(); base.OnDestroy(); StopAllCoroutines(); CearPathCache(); SignalFactory.GetInstance <WarBuildChangeLegion>().RemoveListener(OnBuildChangeLegion); if (War.scene == this) { War.scene = null; } }
private void SetupSignal(int index, SignalKey key) { var signal = SignalFactory.CreateSignal(key); Signals[index] = signal; signal.transform.SetParent(_signalHolders[index].transform, false); signal.OnSignalClicked += OnSignalClicked; if (OnSignalChange != null) { OnSignalChange(); } }
public void BuildChangeLegion(int legionId) { RevokeBuildSpotConfig(); if (buildLevelConfig != null) { RemoveBuildModule(buildLevelConfig.basepropConfig); RemoveBuildModule(buildLevelConfig.produceConfig); RemoveBuildModule(buildLevelConfig.turretConfig); RemoveBuildModule(buildLevelConfig.spotConfig); } int preLegionId = this.legionId; float hp = this.hp; this.legionId = legionId; this.RevokeAll(); SignalFactory.GetInstance <WarBuildChangeLegion>().Dispatch(this, preLegionId, this.legionId); this.changeTeaming = true; if (this.level > 1) { this.level -= 1; } build_addMaxLevel = 0; avatarConfig = buildLevelConfig.avatarConfig; // 势力--战前属性 this.AppProps(legionData.buildInitAttachPropData); // 势力--附加建筑属性 legionData.buildPropContainer.UnitApp(this); AppBuildModules(); AddBuildModule(buildLevelConfig.basepropConfig); AddBuildModule(buildLevelConfig.produceConfig); AddBuildModule(buildLevelConfig.turretConfig); AddBuildModule(buildLevelConfig.spotConfig); // 建筑初始属性 InitHP this.AppProps(War.sceneData.GetBuildInitProps(id), true); this.hp = hp; if (float.IsNaN(hp)) { Debug.Log(string.Format("<color=red>hp={0}</color>", hp)); } sos = false; }
private void initSigListByDB() { Trace.WriteLine("init sig list by db"); sigList = signalDao.getSignalList(); // position SignalFactory.parseSigPosList(signalDao.getPosList(), sigList); // angle SignalFactory.parseSigAngList(signalDao.getAngleList(), sigList); Trace.WriteLine("all signals are: "); foreach (SignalProp p in sigList) { Trace.WriteLine(p.ToString()); } Trace.WriteLine("...init sig list"); }
void OnEnable() { Set(War.darkScreenVisible); SignalFactory.GetInstance <WarDarkScreenVisible>().AddListener(Set); }
/// <summary> /// 定时获取当前信号机状态,并展示在界面上 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void timer1_Tick(object sender, EventArgs e) { if (specPoly == 1) {// 自动特勤,从数据库中取当前信号机 if (signalDao.getState() == ConnectionState.Open) { FProp = signalDao.getCurSigProp(); String state = FProp.State; FProp = SignalFactory.getSigProp(FProp.SignalID, sigList); FProp.State = state; if (null == FProp) { return; } if (null == curSignal || !FProp.SignalID.Equals(curSignal.Prop.SignalID)) { curSignal = SignalFactory.buildController(FProp); } curSignal.Prop = FProp; } else { timerGetCurSig.Enabled = false; showPBs(false); lblSignalName.Text = "数据库未连接!"; return; } } else {//手动特勤,从左侧列表中取当前双击的信号机 if (null == curSignal) { timerGetCurSig.Enabled = false; showPBs(false); return; } if (curSignal.updateState()) { FProp = curSignal.Prop; showSigInfo(FProp); // lblBaseState.Text = FProp.State; } else { // 如果更新状态失败,则说明信号机状态异常,则停掉定时器,避免程序挂死 timerGetCurSig.Enabled = false; lblSignalName.Text = "获取信号机状态失败"; showPBs(false); return; } //listBox1.Items.Insert(0, null==curSignal.Prop.State?"get state error": curSignal.Prop.State); } // 处理显示 showPBs(true); showSigInfo(FProp); dealWithSigProp(FProp); }
void OnTweenHideComplete() { Alhpa = 0F; UpdateView(); SignalFactory.GetInstance <MsgScrollCompleteSignal>().Dispatch(); }
void OnDisable() { SignalFactory.GetInstance <WarBuildChangeLegion>().RemoveListener(OnBuildChangeTeam); }
void OnDestroy() { SignalFactory.GetInstance <WarBuildChangeLegion>().RemoveListener(changeLegion); }
public void SetFail() { state = StarState.Fail; SignalFactory.GetInstance <WarBuildChangeLegion>().RemoveListener(OnBuildChangeTeam); }
public override void SetSuccess() { base.SetSuccess(); SignalFactory.GetInstance <WarBuildChangeLegion>().RemoveListener(OnBuildChangeTeam); }
void Awake() { SignalFactory.GetInstance <GMSignal>().AddListener(OnGM); }
public List <PlcService> LoadConfigs(string path = "") { log.Info($"LoadConfigs - path {path}"); var plcServiceList = new List <PlcService>(); int totalFilesToLoadCount = 0; List <ICpuConfigFile> cpuConfigFiles = _configParser.LoadConfigFiles(path); foreach (var jsonConfig in cpuConfigFiles) { totalFilesToLoadCount += jsonConfig.SignalLists.Count; } var configsProgressEventArgs = new ConfigsProgressEventArgs(); configsProgressEventArgs.ProgressTotal = totalFilesToLoadCount; ConfigsLoadingProgressChanged?.Invoke(this, configsProgressEventArgs); foreach (var config in cpuConfigFiles) { ICpuConfig cpuConfig = new CpuConfig(config); List <IDatablockModel> datablocks = new List <IDatablockModel>(); foreach (var dbNumberDbNameString in config.SignalLists) { DatablockModel datablock = new DatablockModel(); // signal should contain db number and db name, format : "number:name" e.g "3201:DbName" List <string> dbNumberDbName = dbNumberDbNameString.Split(':').ToList(); int dbNumber = 0; bool isParsable = false; if (dbNumberDbName.Count > 0) { isParsable = Int32.TryParse(dbNumberDbName.First(), out dbNumber); } if (dbNumberDbName.Count != 2 || !isParsable) { string errorStr = "Invalid file format in Json config!SignalsList must use : as separator between db number and name."; log.Error(errorStr); throw new FormatException(errorStr); } var signals = new List <SignalModel>(); string filePath = AppDomain.CurrentDomain.BaseDirectory + Constants.BaseDirectorySubDirs + dbNumberDbName.Last(); try { var fileLines = _dbParser.ReadS7DbFile(filePath); var signalContextList = _dbParser.ParseDb(fileLines, config.DiscardKeywords); for (int i = 0; i < signalContextList.Count; i++) { signalContextList[i].CpuIndex = plcServiceList.Count; signalContextList[i].DbIndex = datablocks.Count; signalContextList[i].Index = i; signalContextList[i].DbNumber = dbNumber; signals.Add(SignalFactory.Create(signalContextList[i])); } } catch (Exception) { // TODO - Handle throw; } if (signals?.Count > 0) { datablock.CpuIndex = plcServiceList.Count; datablock.Index = datablocks.Count; datablock.Signals = signals; datablock.Name = dbNumberDbName.Last(); datablock.Number = dbNumber; datablock.FirstByte = signals.First().DbByteIndex(); datablock.ByteCount = signals.Last().DbByteIndex() - datablock.FirstByte; datablocks.Add(datablock); } configsProgressEventArgs.ProgressInput += 1; ConfigsLoadingProgressChanged?.Invoke(this, configsProgressEventArgs); Thread.Sleep(250); } PlcService plcService = PlcServiceFactory.Create(plcServiceList.Count, cpuConfig, datablocks); plcServiceList.Add(plcService); } Thread.Sleep(2500); ConfigsLoaded?.Invoke(this, new EventArgs()); return(plcServiceList); }
void OnDisable() { SignalFactory.GetInstance <WarDarkScreenVisible>().RemoveListener(Set); }