public void RemoveMechaComponent(MechaComponentBase mcb)
    {
        if (mechaComponents.Contains(mcb))
        {
            mechaComponents.Remove(mcb);
            if (MechaInfo.MechaType == MechaType.Self && mcb.MechaComponentInfo.MechaComponentType == MechaComponentType.Core)
            {
                RefreshHUDPanelCoreLifeSliderCount?.Invoke();
            }

            RefreshMechaMatrix(out List <MechaComponentBase> _, out List <MechaComponentBase> isolatedComponents);
            if (MechaInfo.MechaType == MechaType.Enemy)
            {
                foreach (MechaComponentBase m in isolatedComponents)
                {
                    int  ran  = Random.Range(0, 100);
                    bool drop = ran < m.MechaComponentInfo.DropProbability;
                    if (drop)
                    {
                        MechaComponentDropSprite mcds = GameObjectPoolManager.Instance.PoolDict[GameObjectPoolManager.PrefabNames.MechaComponentDropSprite].AllocateGameObject <MechaComponentDropSprite>(BattleManager.Instance.MechaComponentDropSpriteContainer);
                        mcds.Initialize(m.MechaComponentInfo, m.transform.position);
                    }

                    mechaComponents.Remove(m);
                    mcb.MechaComponentGrids.SetIsolatedIndicatorShown(true);
                    m.PoolRecycle(1f);
                }
            }

            if (mechaComponents.Count == 0)
            {
                Die();
            }
        }
    }
    public void AddMechaComponent(MechaComponentBase mcb)
    {
        mechaComponents.Add(mcb);
        if (MechaInfo.MechaType == MechaType.Self && mcb.MechaComponentInfo.MechaComponentType == MechaComponentType.Core)
        {
            RefreshHUDPanelCoreLifeSliderCount?.Invoke();
        }

        mcb.transform.SetParent(MechaComponentContainer);
        mcb.MechaComponentGrids.SetGridShown(GridShown);
        mcb.MechaComponentGrids.SetSlotLightsShown(SlotLightsShown);
        mcb.MechaComponentGrids.TurnOffAllForbidIndicator();
        mcb.MechaComponentGrids.SetIsolatedIndicatorShown(false);
        RefreshMechaMatrix();
    }
Exemple #3
0
        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;
        }