public static MechaComponent BaseInitialize_Editor(MechaComponentInfo mechaComponentInfo, Mecha parentMecha)
        {
            MechaComponent mc = GameObjectPoolManager.Instance.MechaComponentPoolDict[mechaComponentInfo.MechaComponentConfig.MechaComponentKey]
                                .AllocateGameObject <MechaComponent>(parentMecha ? parentMecha.transform : null);

            return(mc);
        }
示例#2
0
        private void RemoveMechaComponent(MechaComponent mc)
        {
            mc.OnRemoveMechaComponentSuc = null;

            if (MechaComponentDict.ContainsKey(mc.MechaComponentInfo.GUID))
            {
                MechaComponentDict.Remove(mc.MechaComponentInfo.GUID);
            }
        }
示例#3
0
 public AttackData(MechaComponentInfo attackerMCI, MechaComponent hitterMcb, int decHp, BattleTipType battleTipType, int elementType, int elementHp)
 {
     AttackerMCI   = attackerMCI;
     HitterMCB     = hitterMcb;
     DecHp         = decHp;
     BattleTipType = battleTipType;
     ElementType   = elementType;
     ElementHP     = elementHp;
 }
示例#4
0
 void Awake()
 {
     mechaComponentGrids = GetComponentsInChildren <MechaComponentGrid>().ToList();
     MechaComponent      = GetComponentInParent <MechaComponent>();
     HitBoxes            = GetComponentsInChildren <MechaComponentHitBox>().ToList();
     foreach (MechaComponentHitBox hitBox in HitBoxes)
     {
         hitBox.LocalGridPos = GridPos.GetGridPosByLocalTransXZ(hitBox.transform, ConfigManager.GridSize);
     }
 }
示例#5
0
        public void EmitProjectile(ProjectileInfo projectileInfo)
        {
            MechaComponent mc = ClientBattleManager.Instance.FindMechaComponent(projectileInfo.ParentExecuteInfo.MechaComponentInfo.GUID);

            if (mc != null && !mc.MechaInfo.IsDead)
            {
                Transform dummyPos = mc.DummyPosDict[projectileInfo.ProjectileConfig.DummyPos];
                ShootProjectile(projectileInfo, dummyPos.position, dummyPos.forward, dummyPos);
            }
        }
示例#6
0
        private void InitBackpack()
        {
            Backpack myBackPack = new Backpack(
                DragAreaDefines.BattleInventory.DragAreaName,
                DragAreaDefines.BattleInventory,
                ConfigManager.BackpackGridSize,
                10,
                8,
                false,
                true,
                true,
                65,
                () => ControlManager.Instance.Common_Tab.Down,
                () => ControlManager.Instance.Building_RotateItem.Down,
                (parent) => GameObjectPoolManager.Instance.PoolDict[GameObjectPoolManager.PrefabNames.BackpackGrid].AllocateGameObject <BackpackGrid>(parent),
                (parent) => GameObjectPoolManager.Instance.PoolDict[GameObjectPoolManager.PrefabNames.BackpackItem].AllocateGameObject <BackpackItem>(parent),
                (parent) => GameObjectPoolManager.Instance.PoolDict[GameObjectPoolManager.PrefabNames.BackpackItemGrid].AllocateGameObject <BackpackItemGrid>(parent),
                (parent) => GameObjectPoolManager.Instance.PoolDict[GameObjectPoolManager.PrefabNames.BackpackVirtualOccupationQuad].AllocateGameObject <BackpackVirtualOccupationQuad>(parent)
                );

            myBackPack.ToggleDebugKeyDownHandler   = () => ControlManager.Instance.Common_Debug.Down;
            myBackPack.ToggleBackpackCallback      = ToggleBattleInventory;
            myBackPack.ToggleDebugCallback         = null;
            myBackPack.DragItemOutBackpackCallback = (backpackItem) =>
            {
                switch (backpackItem.InventoryItem.ItemContentInfo)
                {
                case MechaComponentInfo mechaComponentInfo:
                {
                    Ray                ray       = CameraManager.Instance.MainCamera.ScreenPointToRay(ControlManager.Instance.Building_MousePosition);
                    GridPos            gp        = GridUtils.GetGridPosByMousePos(ClientBattleManager.Instance.PlayerMecha.transform, ray, Vector3.up, ConfigManager.GridSize);
                    GridPosR           gp_matrix = ClientBattleManager.Instance.PlayerMecha.MechaInfo.MechaEditorInventory.CoordinateTransformationHandler_FromPosToMatrixIndex(gp);
                    MechaComponentInfo mci       = mechaComponentInfo.Clone();
                    ClientBattleManager.Instance.PlayerMecha.MechaInfo.AddMechaComponentInfo(mci, gp_matrix);
                    MechaComponent mc = ClientBattleManager.Instance.PlayerMecha.MechaComponentDict[mci.GUID];
                    mci.InventoryItem.SetGridPosition(gp_matrix);
                    DragManager.Instance.CurrentDrag = mc.Draggable;
                    mc.Draggable.SetOnDrag(true, null, DragManager.Instance.GetDragProcessor <MechaComponent>());
                    return(true);
                }
                }

                return(false);
            };

            BackpackPanel backpackPanel = Instantiate(PrefabManager.Instance.GetPrefab("BattleInventoryPanel"), UIManager.Instance.UINormalRoot).GetComponent <BackpackPanel>();

            backpackPanel.Init(myBackPack,
                               delegate(BackpackItem bi) { UIManager.Instance.ShowUIForms <BackpackItemInfoPanel>().Initialize(bi.InventoryItem.ItemContentInfo, backpackPanel); },
                               delegate(BackpackItem bi) { UIManager.Instance.CloseUIForm <BackpackItemInfoPanel>(); });
            backpackPanel.gameObject.SetActive(false);
            BackpackManager.AddBackPack(myBackPack);
        }
        public static void SerializeMechaComponentOccupiedPositions()
        {
            PrefabManager.Instance.LoadPrefabs();
            Dictionary <string, MechaComponentOriginalOccupiedGridInfo> dict = new Dictionary <string, MechaComponentOriginalOccupiedGridInfo>();
            List <MechaComponent> mcs = new List <MechaComponent>();

            ConfigManager.LoadAllConfigs();
            try
            {
                foreach (KeyValuePair <string, MechaComponentConfig> kv in ConfigManager.MechaComponentConfigDict)
                {
                    GameObject prefab = PrefabManager.Instance.GetPrefab(kv.Key);
                    if (prefab != null)
                    {
                        Debug.Log($"模组占位序列化成功: <color=\"#00ADFF\">{kv.Key}</color>");
                        MechaComponent mc = Instantiate(prefab).GetComponent <MechaComponent>();
                        mcs.Add(mc);
                        MechaComponentOriginalOccupiedGridInfo info = new MechaComponentOriginalOccupiedGridInfo();
                        info.MechaComponentOccupiedGridPositionList  = mc.MechaComponentGridRoot.GetOccupiedPositions();
                        info.MechaComponentAllSlotLocalPositionsList = mc.MechaComponentGridRoot.GetAllSlotPositions_Local();
                        dict.Add(kv.Key, info);
                    }
                }

                if (!Directory.Exists(ConfigManager.MechaComponentOriginalOccupiedGridInfoJsonFileFolder))
                {
                    Directory.CreateDirectory(ConfigManager.MechaComponentOriginalOccupiedGridInfoJsonFileFolder);
                }

                string       json = JsonConvert.SerializeObject(dict, Formatting.Indented);
                StreamWriter sw   = new StreamWriter(ConfigManager.MechaComponentOriginalOccupiedGridInfoJsonFilePath);
                sw.Write(json);
                sw.Close();
            }
            catch (Exception e)
            {
                Debug.LogError(e.ToString());
            }
            finally
            {
                foreach (MechaComponent mc in mcs)
                {
                    DestroyImmediate(mc.gameObject);
                }
            }
        }
示例#8
0
        void OnCollisionEnter(Collision collision)
        {
            if (!IsRecycled)
            {
                ContactPoint contact = collision.contacts[0];
                FlyRealtimeData.HitCollider = collision.collider;
                MechaComponent mc = collision.collider.GetComponentInParent <MechaComponent>();
                if (mc)
                {
                    FlyRealtimeData.HitMechaComponentInfo = mc.MechaComponentInfo;
                }

                bool recycle = false;
                if (Override_CanReflect)
                {
                    Vector3 reflectDir = FlyRealtimeData.Velocity_Global.normalized - 2 * Vector3.Dot(FlyRealtimeData.Velocity_Global.normalized, contact.normal) * contact.normal;
                    FlyRealtimeData.Velocity_Global = reflectDir * FlyRealtimeData.Velocity_Global.magnitude;
                    transform.forward              = FlyRealtimeData.Velocity_Global.normalized;
                    Rigidbody.velocity             = FlyRealtimeData.Velocity_Global;
                    FlyRealtimeData.Velocity_Local = transform.InverseTransformVector(FlyRealtimeData.Velocity_Global);

                    if (FlyRealtimeData.RemainCollideTimes <= 0)
                    {
                        recycle = true;
                    }
                    else
                    {
                        FlyRealtimeData.RemainCollideTimes--;
                    }
                }
                else
                {
                    recycle = true;
                }

                PlayHitEffect(contact.point, contact.normal);
                ClientGameManager.Instance.BattleMessenger.Broadcast((uint)ENUM_AbilityEvent.OnProjectileHitUnit, ProjectileInfo.ParentExecuteInfo, FlyRealtimeData);
                ClientGameManager.Instance.BattleMessenger.Broadcast((uint)ENUM_AbilityEvent.OnProjectileHitAndFinish, ProjectileInfo.ParentExecuteInfo, FlyRealtimeData);

                if (recycle)
                {
                    PoolRecycle();
                }
            }
        }
示例#9
0
        private MechaComponent AddMechaComponent(MechaComponentInfo mci)
        {
            MechaComponent mc = MechaComponent.BaseInitialize(mci, this);

            mc.OnRemoveMechaComponentSuc = RemoveMechaComponent;
            MechaComponentDict.Add(mci.GUID, mc);

            if (IsPlayer && mc.MechaComponentInfo.MechaComponentType == MechaComponentType.Core)
            {
                MechaInfo.RefreshHUDPanelCoreLifeSliderCount?.Invoke();
            }

            mc.transform.SetParent(MechaComponentContainer);
            mc.MechaComponentGridRoot.SetGridShown(GridShown);
            mc.MechaComponentGridRoot.SetSlotLightsShown(SlotLightsShown);
            mc.MechaComponentGridRoot.ResetAllGridConflict();
            mc.MechaComponentGridRoot.SetIsolatedIndicatorShown(false);
            return(mc);
        }
        private void HandleCommonTip(uint mcGUID, BattleTipType battleTipType)
        {
            if (!EnableUIBattleTip)
            {
                return;
            }
            if ((int)battleTipType >= (int)BattleTipType.FollowDummySeparate)
            {
                return;
            }

            AttackerType attackerType = AttackerType.None;

            MechaComponent mc_owner = ClientBattleManager.Instance.FindMechaComponent(mcGUID);

            if (ClientBattleManager.Instance.PlayerMecha != null && mc_owner != null)
            {
                attackerType = GetAttackerType(mc_owner.Mecha.MechaInfo, ClientBattleManager.Instance.PlayerMecha.MechaInfo, battleTipType);
            }

            if (attackerType == AttackerType.NoTip)
            {
                return;
            }

            UIBattleTipInfo info = new UIBattleTipInfo(
                0,
                battleTipType,
                attackerType,
                0,
                0,
                0.13f,
                0,
                "",
                mc_owner.transform.position + Vector3.up * 1f,
                Vector2.zero,
                Vector2.one,
                0.5f);

            CreateTip(info);
        }