public void ProvidePower(GridPos destinationGP, int power) { if (destinationGP.x >= 0 && destinationGP.x < MechaEditorInventory.InventoryItemMatrix.GetLength(0) && destinationGP.z >= 0 && destinationGP.z < MechaEditorInventory.InventoryItemMatrix.GetLength(1)) { InventoryItem item = MechaEditorInventory.InventoryItemMatrix[destinationGP.x, destinationGP.z]; if (item != null) { MechaComponentInfo mci = ((MechaComponentInfo)item.ItemContentInfo); mci.AccumulatedPowerInsideThisFrame += power; } } }
public void Damage(MechaComponentInfo attacker, int damage) { M_LeftLife -= damage; OnDamaged?.Invoke(attacker, damage); if (!IsDead && !CheckAlive()) { IsDead = true; Died(); OnDied?.Invoke(); } }
public void AddMechaComponentInfo(MechaComponentInfo mci, GridPosR gp_matrix) { if (IsBuilding) { _totalLife = 0; } mci.MechaInfo = this; mci.OnRemoveMechaComponentInfoSuc += RemoveMechaComponentInfo; MechaComponentInfoDict.Add(mci.GUID, mci); if (!string.IsNullOrEmpty(mci.Alias)) { if (MechaComponentInfoDict_Alias.ContainsKey(mci.Alias)) { MechaComponentInfo tempMCI = MechaComponentInfoDict_Alias[mci.Alias]; Debug.LogError($"机甲组件花名重复. " + $"机甲: {LogIdentityName}, 组件: {mci.LogIdentityName}, 花名: {mci.Alias}" + $"重复对象组件: {tempMCI.LogIdentityName}"); } else { MechaComponentInfoDict_Alias.Add(mci.Alias, mci); } } InventoryItem item = new InventoryItem(mci, MechaEditorInventory, gp_matrix); item.AmIRootItemInIsolationCalculationHandler = () => ((MechaComponentInfo)item.ItemContentInfo).MechaComponentType == MechaComponentType.Core; mci.SetInventoryItem(item); void instantiateMechaComponent() { item.Inventory = MechaEditorInventory; OnAddMechaComponentInfoSuc.Invoke(mci, gp_matrix); MechaEditorInventory.TryAddItem(item); MechaEditorInventory.RefreshConflictAndIsolation(); } if (MechaEditorInventory != null) { instantiateMechaComponent(); } else { OnInstantiated += instantiateMechaComponent; } }
private void RemoveMechaComponentInfo(MechaComponentInfo mci) { if (IsBuilding) { _totalLife = 0; } MechaEditorInventory.RemoveItem(mci.InventoryItem, false); MechaEditorInventory.RefreshConflictAndIsolation(out List <InventoryItem> _, out List <InventoryItem> isolatedItems); if (MechaCamp == MechaCamp.Enemy) { foreach (InventoryItem item in isolatedItems) { MechaComponentInfo _mci = (MechaComponentInfo)item.ItemContentInfo; //int ran = LevelManager.SRandom.Range(0, 100); //bool drop = ran < _mci.DropProbability; //if (drop) //{ // OnDropMechaComponent?.Invoke(_mci); //} } } MechaComponentInfoDict.Remove(mci.GUID); if (string.IsNullOrEmpty(mci.Alias)) { MechaComponentInfoDict_Alias.Remove(mci.Alias); } if (MechaComponentInfoDict.Count == 0) { Die(); } RefreshHUDPanelCoreLifeSliderCount?.Invoke(); mci.OnRemoveMechaComponentInfoSuc = null; mci.MechaInfo = null; }
public MechaComponentInfo Clone() { MechaComponentInfo mci = new MechaComponentInfo(MechaComponentConfig, Quality, Alias); return(mci); }