void OnStorageEventHandler(int event_id, CSEntity entity, object arg) { switch (event_id) { case CSConst.eetStorage_HistoryEnqueue: { HistoryStruct hs = arg as HistoryStruct; CSUI_SubStorageHistory ssh = _addHistoryItem(hs); if (ssh != null) { ssh.AddHistory(hs.m_Value); } } break; case CSConst.eetStorage_HistoryDequeue: { // HistoryStruct hs = arg as HistoryStruct; if (m_SubHistorys.Count != 0) { m_SubHistorys[0].PopImmediate(); if (m_SubHistorys[0].IsEmpty) { Destroy(m_SubHistorys[0].gameObject); m_SubHistorys.RemoveAt(0); } } } break; case CSConst.eetStorage_PackageRemoveItem: { StorageMainUI.RestItems(); } break; } }
public void DeleteSeedResult(CSEntity entity, int objId, int index) { if (m_Entity == entity) { for (int i = 0; i < m_SeedsGrids.Count; i++) { if (m_SeedsGrids[i].m_Grid.ItemObj != null && m_ToolsGrids[i].m_Grid.ItemObj.instanceId == objId) { m_SeedsGrids[i].m_Grid.SetItem(null); } } //// Event ItemAsset.ItemObject io = m_Farm.GetPlantSeed(index); if (io != null) { io.DecreaseStackCount(1); if (io.GetCount() <= 0) { m_Farm.ExcuteEvent(CSConst.eetFarm_OnPlant, index); } } m_Farm.SetPlantSeed(index, null); } }
void Start() { // Create colony object if has Dictionary <int, CSDefaultData> objRecords = m_DataInst.GetObjectRecords(); foreach (CSDefaultData defData in objRecords.Values) { CSObjectData objData = defData as CSObjectData; if (objData != null) { if (!objData.m_Alive) { continue; } CSEntityAttr attr = new CSEntityAttr(); attr.m_InstanceId = objData.ID; attr.m_Type = objData.dType; attr.m_Pos = objData.m_Position; attr.m_protoId = objData.ItemID; CSEntity cse = null; CreateEntity(attr, out cse); } } }
public CSProperty(string rawContent, CSEntity parent) : base(rawContent, parent) { string[] splitContent = rawContent.Split(' ', '='); int hasVisibilityKey = 0; for (int i = 0; i < splitContent.Length; i++) { if (CSParsingTool.IsVisibilityKeyword(splitContent[i])) { hasVisibilityKey = 1; this.visibility = splitContent[i]; } } if (hasVisibilityKey == 0) { this.visibility = "public"; } this.type = splitContent[hasVisibilityKey]; this.name = splitContent[hasVisibilityKey + 1].Replace(";", ""); int equalIndex = rawContent.IndexOf('='); if (equalIndex != -1) { string rawInitializer = rawContent.Substring(equalIndex + 1); this.initializer = rawInitializer.Trim(); } }
public void SetEntity(CSEntity enti) { if (enti == null) { Debug.LogWarning("Reference Entity is null."); return; } if (m_Assembly != null) { m_Assembly.RemoveEventListener(AssemblyEventHandler); } m_Assembly = enti as CSAssembly; m_Assembly.AddEventListener(AssemblyEventHandler); if (m_Assembly == null) { Debug.LogWarning("Reference Entity is not a Assembly Entity."); return; } m_Entity = enti; UpdateUpgradeMat(); UpdateBuildingNum(); m_HideShieldCB.isChecked = !m_Assembly.bShowShield; }
public void SetEntity(CSEntity enti) { if (enti == null) { Debug.LogWarning("Reference Entity is null."); return; } m_PPCoal = enti as CSPPCoal; if (m_PPCoal == null) { Debug.LogWarning("Reference Entity is not a PowerPlant Entity."); return; } m_Entity = enti; CSUI_MainWndCtrl.Instance.mSelectedEnntity = enti; SetFuelMaterial(); SetSupplies(); foreach (CSUI_ChargingGrid cg in m_ChargingGrids) { cg.SetItem(m_PPCoal.GetChargingItem(cg.m_Index)); } m_HideElectricLine.isChecked = !m_PPCoal.bShowElectric; }
public static CSEntity CreateEntity(string rawContent, CSEntity parent) { if (rawContent.Contains("class ")) { return(new CSClass(rawContent, parent)); } else if (rawContent.Contains("using ")) { return(new CSUsing(rawContent, parent)); } else if (parent is CSClass) { if (rawContent.IndexOfAny(CSEntityFactory.propertyChars) == -1) { return(new CSProperty(rawContent, parent)); } else { return(new CSMethod(rawContent, parent)); } } else { return(new CSEntity(rawContent, parent)); } }
public CSClass(string rawContent, CSEntity parent) : base(rawContent, parent) { string[] splitContent = rawContent.Split(' '); for (int i = 0; i < splitContent.Length; i++) { if (splitContent[i] == "class") { if (i + 1 < splitContent.Length) { this.name = splitContent[i + 1]; } } else if (CSParsingTool.IsVisibilityKeyword(splitContent[i])) { this.visibility = splitContent[i]; } else if (splitContent[i] == ":") { if (i + 1 < splitContent.Length) { this.baseName = splitContent[i + 1]; } } } }
public void InitInMultiMode(CSEntity m_Entity, int ownerId) { m_Type = GetMTypeFromProtoId(itemDrag.itemObj.protoId); this.m_Entity = m_Entity; m_Entity.gameLogic = gameObject; _peEntity = gameObject.GetComponent <PeEntity>(); _peTrans = gameObject.GetComponent <PeTrans>(); _skEntity = gameObject.GetComponent <PESkEntity>(); _skEntity.m_Attrs = new PESkEntity.Attr[5]; _skEntity.m_Attrs[0] = new PESkEntity.Attr(); _skEntity.m_Attrs[1] = new PESkEntity.Attr(); _skEntity.m_Attrs[2] = new PESkEntity.Attr(); _skEntity.m_Attrs[3] = new PESkEntity.Attr(); _skEntity.m_Attrs[4] = new PESkEntity.Attr(); _skEntity.m_Attrs[0].m_Type = AttribType.HpMax; _skEntity.m_Attrs[1].m_Type = AttribType.Hp; _skEntity.m_Attrs[2].m_Type = AttribType.CampID; _skEntity.m_Attrs[3].m_Type = AttribType.DefaultPlayerID; _skEntity.m_Attrs[4].m_Type = AttribType.DamageID; _skEntity.m_Attrs[0].m_Value = m_Entity.MaxDurability; _skEntity.m_Attrs[1].m_Value = m_Entity.CurrentDurability; _skEntity.m_Attrs[2].m_Value = 1; _skEntity.m_Attrs[3].m_Value = ownerId; PeEntity ownerEntity = EntityMgr.Instance.Get(ownerId); if (ownerEntity != null) { _skEntity.m_Attrs[2].m_Value = ownerEntity.GetAttribute(AttribType.CampID); _skEntity.m_Attrs[4].m_Value = ownerEntity.GetAttribute(AttribType.DamageID); } _skEntity.onHpChange += OnHpChange; if (m_Type == CSConst.ObjectType.Assembly) { _skEntity.onHpChange += SendHpChangeMessage; } _skEntity.deathEvent += OnDeathEvent; _skEntity.InitEntity(); OnHpChange(_skEntity, 0); EntityMgr.Instance.InitEntity(InstanceId, _peEntity.gameObject); //if(m_Type == CSConst.ObjectType.Processing) //{ // network.InitResultPos(m_ResultTrans); //} m_Entity.m_MgCreator.AddLogic(id, this); if (CSMain.s_MgCreator == m_Entity.m_MgCreator && m_Entity as CSAssembly != null) { //Vector3 travelPos = gameObject.transform.position + new Vector3(0, 2, 0); if (travelTrans != null) { //travelPos = travelTrans.position; } } StartCoroutine(SetFirstConstruct()); }
public void ExecuteEvent(int event_type, CSEntity entity) { if (m_EventListenser != null) { m_EventListenser(event_type, entity); } }
void AssemblyEventHandler(int event_id, CSEntity enti, object arg) { if (event_id == CSConst.eetAssembly_Upgraded) { UpdateBuildingNum(); UpdateUpgradeMat(); } }
public CSEntity Parse(string script) { CSEntity output = new CSRoot(); this.current = output; this.Read(script); return(output); }
public CSEntity(string rawContent, CSEntity parent) { Debug.Log("Create new CSEntity"); this.rawContent = rawContent; if (parent != null) { parent.AppendChild(this); } }
// Dwellings change state call back void OnDwellingsChangeState(int event_type, CSEntity entiy, object arg) { if (event_type == CSConst.eetDwellings_ChangeState) { bool state = (bool)arg; if (state) // Add { CSAssembly assem = Dwellings.Assembly; // if (m_WorkMode == CSConst.pwtPatrol) // { // Dwellings.Assembly.AddSoldier(this); // List<CSCommon> commons = Dwellings.Assembly.GetBelongCommons(); // // foreach (CSCommon common in commons) // common.AddSoldier(this); // } // else if (m_WorkMode == CSConst.pwtGuard) // { // if ( CSUtils.SphereContainsAndIntersectBound(m_GuardTrigger.Pos, m_GuardTrigger.Radius, assem.Bound)) // assem.AddSoldier(this); // // List<CSCommon> commons = assem.GetBelongCommons(); // foreach (CSCommon common in commons) // { // if (CSUtils.SphereContainsAndIntersectBound(m_GuardTrigger.Pos, m_GuardTrigger.Radius, common.Bound)) // common.AddSoldier(this); // } // } assem.AddEventListener(OnAssemblyEventHandler); m_Assembly = assem; } else // Remove { // if (m_WorkMode == CSConst.pwtPatrol || m_WorkMode == CSConst.pwtGuard) // { // CSMgCreator mgCreator = m_Creator as CSMgCreator; // if (mgCreator != null) // { // mgCreator.Assembly.RemoveSoldier(this); // Dictionary<int, CSCommon> commons = mgCreator.GetCommonEntities(); // // foreach (KeyValuePair<int, CSCommon> kvp in commons) // kvp.Value.RemoveSoldier(this); // } // } if (m_Assembly != null) { m_Assembly.RemoveEventListener(OnAssemblyEventHandler); m_Assembly = null; } } m_Running = state; } }
public void SetEnity(CSEntity enity) { if (enity == null) { Debug.LogWarning("Reference Entity is null."); return; } CSUI_MainWndCtrl.Instance.mSelectedEnntity = enity; }
public void SetSequentialActiveResult(bool active, CSEntity entity) { if (m_Entity == entity) { m_SequentialPlantingCB.isChecked = m_Farm.Data.m_SequentialPlanting; if (active) { CSUI_MainWndCtrl.ShowStatusBar(UIMsgBoxInfo.mPlantSequence.GetString()); } } }
public void Read(string script) { if (this.index >= script.Length) { return; } char c = script[this.index++]; if (c == '/') { if (this.index < script.Length) { char next = script[this.index]; if (next == '/') { this.ReadSlashComment(script); return; } } } if (c == ';') { CSEntityFactory.CreateEntity(this.buffer + ";", this.current); this.buffer = ""; this.Read(script); return; } else if (c == '{') { CSEntity entity = CSEntityFactory.CreateEntity(this.buffer, this.current); this.current = entity; this.buffer = ""; this.Read(script); return; } else if (c == '}') { this.current = this.current.parent; this.buffer = ""; this.Read(script); return; } else { if ("\n\r\t".IndexOf(c) == -1) { this.buffer += c; } this.Read(script); return; } }
virtual public string writeAsDebug() { CSEntity parent = this.parent; string output = this.getPrefix() + " "; while (parent != null && !(parent is CSRoot)) { output += "--- "; parent = parent.parent; } output += this.rawContent + "\n"; return(output); }
public void DeleteToolResult(CSEntity entity, int objId) { if (m_Entity == entity) { for (int i = 0; i < m_ToolsGrids.Count; i++) { if (m_ToolsGrids[i].m_Grid.ItemObj != null && m_ToolsGrids[i].m_Grid.ItemObj.instanceId == objId) { m_ToolsGrids[i].m_Grid.SetItem(null); } } } }
public void SetEntityList(List <CSEntity> entityList, CSEntity selectEntity) { //lz-2016.10.13 错误 #4045 空对象 if (null == entityList || null == mUIPPCoalIcoList) { return; } for (int i = 0; i < mUIPPCoalIcoList.Count; i++) { if (i < entityList.Count) { mUIPPCoalIcoList[i].gameObject.SetActive(true); mUIPPCoalIcoList[i].Common = entityList[i] as CSCommon; } else { mUIPPCoalIcoList[i].gameObject.SetActive(false); mUIPPCoalIcoList[i].Common = null; } } CSEntity curSelectEntity = null; //lz-2016.09.13 需要选中的 if (null != selectEntity) { curSelectEntity = selectEntity; } //lz-2016.09.13 上次选中的 else if (null != m_Entity) { curSelectEntity = m_Entity; } //lz - 2016.09.13 上面两个不满足就选第一个 if (null == curSelectEntity || !entityList.Contains(curSelectEntity)) { curSelectEntity = entityList[0]; } CSUI_CommonIcon icon = mUIPPCoalIcoList.Find(a => a.Common == selectEntity); if (null != icon) { SetEntity(curSelectEntity); icon.mCheckBox.isChecked = true; } mIcoGrid.repositionNow = true; }
public void SetEntity(CSCommon entity) { if (entity != null && entity.m_Type != CSConst.etEnhance && entity.m_Type != CSConst.etRepair && entity.m_Type != CSConst.etRecyle) { Debug.Log("The giving Entity is not allowed!"); return; } m_Type = entity.m_Type; m_Entity = entity; CSUI_MainWndCtrl.Instance.mSelectedEnntity = m_Entity; if (m_Type == CSConst.etEnhance) { CSEnhance cse = m_Entity as CSEnhance; if (cse.m_Item == null) { SetItem(null); } else { SetItem(cse.m_Item.itemObj); } } else if (m_Type == CSConst.etRepair) { CSRepair csr = m_Entity as CSRepair; if (csr.m_Item == null) { SetItem(null); } else { SetItem(csr.m_Item.itemObj); } } else if (m_Type == CSConst.etRecyle) { CSRecycle csr = m_Entity as CSRecycle; if (csr.m_Item == null) { SetItem(null); } else { SetItem(csr.m_Item.itemObj); } } }
void OnEntityEventListener(int event_id, CSEntity entity, object arg) { if (event_id == CSConst.eetDestroy) { lvl = 0; lastHour = 0.0f; nextHour = 0.0f; if (m_Beacon != null) { m_Beacon.Delete(); } } }
override public string writeAsDebug() { CSEntity parent = this.parent; string output = "# [Class " + this.name + "] [Visibility " + this.visibility + "] [Base " + this.baseName + "] #\n"; output += this.getPrefix() + " "; while (parent != null && !(parent is CSRoot)) { output += "--- "; parent = parent.parent; } output += this.rawContent + "\n"; return(output); }
// Farm Event handler void OnEntityEvent(int event_type, CSEntity cse, object arg) { if (event_type == CSConst.eetFarm_OnPlant) { int index = (int)arg; if (m_SeedsGrids[index].m_Grid.Item != null) { if (m_SeedsGrids[index].m_Grid.Item.GetCount() <= 0) { m_SeedsGrids[index].m_Grid.SetItem(null); } } } }
override public string writeAsDebug() { CSEntity parent = this.parent; string output = "# [Property '" + this.name + "'] [Visibility " + this.visibility + "] [Type " + this.type + "] [Initialize '" + this.initializer + "'] #\n"; output += this.getPrefix() + " "; while (parent != null && !(parent is CSRoot)) { output += "--- "; parent = parent.parent; } output += this.rawContent + "\n"; return(output); }
public void SetEntity(CSEntity enti) { if (enti == null) { Debug.LogWarning("Reference Entity is null."); return; } m_Factory = enti as CSFactory; if (m_Factory == null) { Debug.LogWarning("Reference Entity is not a Assembly Entity."); return; } m_Entity = enti; CSUI_MainWndCtrl.Instance.mSelectedEnntity = m_Entity; }
public void SetPlantSeedResult(bool success, int objId, int index, CSEntity entity) { if (success) { if (m_Entity == entity) { ItemObject item = ItemMgr.Instance.Get(objId); ItemObject oldItem = m_SeedsGrids[index].m_Grid.ItemObj; CSUI_Grid UIgrid = m_SeedsGrids[index]; UIgrid.m_Grid.SetItem(item); if (UIgrid.OnItemChanged != null) { UIgrid.OnItemChanged(item, oldItem, UIgrid.m_Index); } } } }
public void RefleshMechine(int csConstType, List <CSEntity> csEntities, CSEntity selectEnity) { m_hospitalEnties = csEntities; if (selectEnity != null) { m_CheckedPartType = selectEnity.m_Type; CSUI_MainWndCtrl.Instance.mSelectedEnntity = selectEnity; return; } int index = GetMechineIndex(csConstType); if (index >= 0) { m_CheckedPartType = csConstType; CSUI_MainWndCtrl.Instance.mSelectedEnntity = m_hospitalEnties[index]; } }
public void FetchToolResult(bool success, int index, CSEntity entity) { if (success) { if (m_Entity == entity) { ItemObject item = null; ItemObject oldItem = m_ToolsGrids[index].m_Grid.ItemObj; CSUI_Grid UIgrid = m_ToolsGrids[index]; GameUI.Instance.mItemPackageCtrl.ResetItem(); UIgrid.m_Grid.SetItem(item); if (UIgrid.OnItemChanged != null) { UIgrid.OnItemChanged(item, oldItem, UIgrid.m_Index); } } } }
public CSMethod(string rawContent, CSEntity parent) : base(rawContent, parent) { string[] splitContent = rawContent.Split(' '); int hasVisibilityKey = 0; for (int i = 0; i < splitContent.Length; i++) { if (CSParsingTool.IsVisibilityKeyword(splitContent[i])) { hasVisibilityKey = 1; this.visibility = splitContent[i]; } } if (hasVisibilityKey == 0) { this.visibility = "public"; } this.returnType = splitContent[hasVisibilityKey]; this.name = splitContent[hasVisibilityKey + 1].Replace("(", ""); int startParametersIndex = rawContent.IndexOf('('); int endParametersIndex = rawContent.LastIndexOf(')'); int lengthParameters = endParametersIndex - startParametersIndex + 1; string rawParameters = rawContent.Substring(startParametersIndex, lengthParameters); rawParameters = rawParameters.Replace("(", ""); rawParameters = rawParameters.Replace(")", ""); string[] splitParameters = rawParameters.Split(','); for (int i = 0; i < splitParameters.Length; i++) { splitParameters[i] = splitParameters[i].Trim(); string[] splitParameter = splitParameters[i].Split(' '); if (splitParameter.Length >= 2) { this.parameters.Add( new CSParameter( splitParameter[0], splitParameter[splitParameter.Length - 1] ) ); } } }