public void DelComponent(int nIndex) { ListComponent.RemoveAt(nIndex); }
/// 计算结果,传入的Dictionary中必须包含所有信息// public float GetData(NumericComponent comp, NumericComponent other) { ListComponent <int> priorityList = ListComponent <int> .Create(); ListComponent <FormulaNode> tempList = ListComponent <FormulaNode> .Create(); for (int i = 0; i < formulaNodeList.Count; i++) { FormulaNode node = new FormulaNode(formulaNodeList[i].Key, formulaNodeList[i].Value, formulaNodeList[i].IsSelf); tempList.Add(node); } for (int i = 0; i < tempList.Count; i++) { if (!float.TryParse(tempList[i].Value, out _)) { if (NumericType.Map.TryGetValue(tempList[i].Value, out int type)) { if (tempList[i].IsSelf) { tempList[i].Value = comp.GetAsFloat(type).ToString(); } else if (other != null) { tempList[i].Value = other.GetAsFloat(type).ToString(); } else { tempList[i].Value = "0"; Log.Error("计算伤害未传入目标"); } } } if (tempList[i].Key != 0 && !priorityList.Contains(tempList[i].Key)) { priorityList.Add(tempList[i].Key); } } priorityList.Sort(); while (priorityList.Count > 0) { int currentpri = priorityList[priorityList.Count - 1]; bool hasfind = false; do { hasfind = false; for (int i = 0; i < tempList.Count && tempList.Count >= 3; i++) { if (tempList[i].Key == currentpri && GetPriority(tempList[i].Value) != 0) { float final = GetOperactorFinal(tempList[i - 1].Value, tempList[i].Value, tempList[i + 1].Value); var newformula = new FormulaNode(tempList[i - 1].Key, final.ToString()); tempList.RemoveRange(i - 1, 3); tempList.Insert(i - 1, newformula); hasfind = true; break; } } } while (hasfind); priorityList.RemoveAt(priorityList.Count - 1); priorityList.Sort(); } if (tempList.Count == 0) { #if UNITY_EDITOR // UnityEngine.Debug.LogError("FormulaString is Error string = "+ lastFormatString); #endif return(0); } string outstring = tempList[0].Value;// + formulaNodeList.Count.ToString(); float finalnum = 0; if (!float.TryParse(outstring, out finalnum)) { #if UNITY_EDITOR // UnityEngine.Debug.Log(outstring); #endif finalnum = 0; } priorityList.Dispose(); tempList.Dispose(); return(finalnum); }
public static async ETTask Transfer(Unit unit, long sceneInstanceId, string sceneName) { // 通知客户端开始切场景 M2C_StartSceneChange m2CStartSceneChange = new M2C_StartSceneChange() { SceneInstanceId = sceneInstanceId, SceneName = sceneName }; MessageHelper.SendToClient(unit, m2CStartSceneChange); M2M_UnitTransferRequest request = new M2M_UnitTransferRequest(); ListComponent <int> Stack = ListComponent <int> .Create(); request.Unit = unit; Entity curEntity = unit; Stack.Add(-1); while (Stack.Count > 0) { var index = Stack[Stack.Count - 1]; if (index != -1) { curEntity = request.Entitys[index]; } Stack.RemoveAt(Stack.Count - 1); foreach (Entity entity in curEntity.Components.Values) { if (entity is ITransfer) { var childIndex = request.Entitys.Count; request.Entitys.Add(entity); Stack.Add(childIndex); request.Map.Add(new RecursiveEntitys { ChildIndex = childIndex, ParentIndex = index, IsChild = 0 }); } } foreach (Entity entity in curEntity.Children.Values) { if (entity is ITransfer) { var childIndex = request.Entitys.Count; request.Entitys.Add(entity); Stack.Add(childIndex); request.Map.Add(new RecursiveEntitys { ChildIndex = childIndex, ParentIndex = index, IsChild = 1 }); } } } Stack.Dispose(); // 删除Mailbox,让发给Unit的ActorLocation消息重发 unit.RemoveComponent <MailBoxComponent>(); // location加锁 long oldInstanceId = unit.InstanceId; await LocationProxyComponent.Instance.Lock(unit.Id, unit.InstanceId); M2M_UnitTransferResponse response = await ActorMessageSenderComponent.Instance.Call(sceneInstanceId, request) as M2M_UnitTransferResponse; await LocationProxyComponent.Instance.UnLock(unit.Id, oldInstanceId, response.NewInstanceId); unit.Dispose(); }