private void StartGame() { Backpack myBackPack = BackpackManager.Instance.GetBackPack(DragAreaDefines.BattleInventory.DragAreaName); InventoryInfo inventoryInfo = new InventoryInfo(); MechaComponentGroupConfig mcg_config = ConfigManager.Instance.GetMechaComponentGroupConfig("EntryPlayerBattleInventory"); foreach (MechaComponentGroupConfig.Config config in mcg_config.MechaComponentList) { MechaComponentInfo mci = new MechaComponentInfo(ConfigManager.Instance.GetMechaComponentConfig(config.MechaComponentKey), config.Quality); inventoryInfo.InventoryItems.Add(new InventoryItem(mci, myBackPack, new GridPosR(0, 0, GridPosR.Orientation.Up))); } myBackPack.LoadInventoryInfo(inventoryInfo); MechaInfo playerMechaInfo = new MechaInfo("Solar 0", MechaCamp.Player, null); playerMechaInfo.AddMechaComponentInfo(new MechaComponentInfo(ConfigManager.Instance.GetMechaComponentConfig("MC_BasicCore"), Quality.Common), new GridPosR(9, 9)); BattleInfo battleInfo = new BattleInfo(playerMechaInfo); ClientBattleManager.Instance.StartBattle(battleInfo); UIBattleTipManager.Init(); ClientLevelManager.Instance.StartLevel(); }
private void Initialize_Building(MechaInfo mechaInfo) { MechaEditArea.gameObject.SetActive(mechaInfo.MechaType == MechaType.Self); MechaEditArea.Hide(); GridShown = false; SlotLightsShown = false; }
public void AddEnemy() { MechaConfig mechaConfig = ConfigManager.Instance.GetRandomMechaConfig(); MechaInfo mechaInfo = mechaConfig.GetMechaInfo(MechaCamp.Enemy); BattleManager.Instance.AddEnemyMecha(mechaInfo); ClientBattleManager.Instance.MechaDict[mechaInfo.GUID].transform.position = new Vector3(Random.Range(0, 20), 0, Random.Range(0, 20)); }
public void Init(MechaInfo mechaInfo) { DragProcessor = DragManager.Instance.GetDragProcessor <MechaComponent>(); Clear(); SetShown(false); DragArea.DragAreaName = mechaInfo.MechaEditorInventory.DragArea.DragAreaName; MechaEditorAreaGridRoot.Init(); }
public static MechaInfo GetMechaInfo(this MechaConfig mechaConfig, MechaCamp mechaCamp) { MechaInfo mechaInfo = new MechaInfo(mechaConfig.MechaConfigName, mechaCamp, mechaConfig.Clone()); foreach (MechaConfig.Config config in mechaConfig.MechaComponentList) { MechaComponentConfig mcc = ConfigManager.Instance.GetMechaComponentConfig(config.MechaComponentKey); MechaComponentInfo mci = new MechaComponentInfo(mcc, config.MechaComponentQuality, config.MechaComponentAlias); GridPosR finalGPR = config.GridPosR + ConfigManager.EDIT_AREA_HALF_SIZE * GridPosR.One; mechaInfo.AddMechaComponentInfo(mci, finalGPR); } return(mechaInfo); }
public void Initialize(MechaInfo mechaInfo) { mechaComponentMatrix = new MechaComponentBase[ConfigManager.EDIT_AREA_SIZE * 2 + 1, ConfigManager.EDIT_AREA_SIZE * 2 + 1]; MechaInfo = mechaInfo; RefreshMechaMatrix(); foreach (MechaComponentInfo mci in mechaInfo.MechaComponentInfos) { AddMechaComponent(mci); } Initialize_Building(mechaInfo); Initialize_Fighting(mechaInfo); M_TotalLife = 0; M_LeftLife = 1; }
private AttackerType GetAttackerType(MechaInfo attacker, MechaInfo hitter, BattleTipType battleTipType) { //不走攻击类型判定 if ((int)battleTipType > (int)BattleTipType.NoAttackSeparate) { return(AttackerType.None); } if (attacker != null) { //主角 if (attacker.IsPlayer) { if (hitter.IsPlayer) { return(AttackerType.LocalPlayerSelfDamage); } else { return(AttackerType.LocalPlayer); } } //同个阵营 if (hitter != null && attacker.IsFriend(hitter)) { return(AttackerType.NoTip); } //队友 if (attacker.IsMainPlayerFriend()) { return(AttackerType.Team); } //敌人 if (hitter != null && attacker.IsOpponent(hitter)) { return(AttackerType.Enemy); } } return(AttackerType.None); }
void Update_Fighting() { foreach (KeyValuePair <uint, MechaComponent> kv in MechaComponentDict) { if (!kv.Value.IsRecycled) { kv.Value.PreUpdate_Fighting(); } } MechaInfo.Update_Fighting(); if (MechaInfo.MechaCamp == MechaCamp.Player) { if (!MechaInfo.AbilityForbidMovement) { Vector2 speed = Time.deltaTime * Speed * ControlManager.Instance.Battle_Move.normalized; speed = Quaternion.Euler(0f, 0f, 45f) * speed; transform.position += new Vector3(speed.x, 0, speed.y); } RotateToMouseDirection(); } }
public void Initialize(MechaInfo mechaInfo) { Clean(); MechaInfo = mechaInfo; if (!IsPlayer) { MechaBaseAIAgent = new MechaBaseAIAgent(this); } // AI if (mechaInfo.MechaConfig != null) { string aiConfigKey = mechaInfo.MechaConfig.MechaAIConfigKey; if (!string.IsNullOrEmpty(aiConfigKey)) { BehaviourTree bt = ConfigManager.Instance.GetEnemyAIConfig(aiConfigKey); BehaviourTreeOwner.behaviour = bt; BehaviourTreeOwner.updateMode = Graph.UpdateMode.NormalUpdate; BehaviourTreeOwner.StartBehaviour(); AIManager.Instance.AddBehaviourTreeOwner(BehaviourTreeOwner); } } MechaInfo.OnAddMechaComponentInfoSuc = (mci, gp_matrix) => AddMechaComponent(mci); MechaInfo.OnRemoveMechaInfoSuc += (mi) => { OnRemoveMechaSuc?.Invoke(this); PoolRecycle(); }; MechaInfo.OnDropMechaComponent = (mci) => { MechaComponentDropSprite mcds = GameObjectPoolManager.Instance.PoolDict[GameObjectPoolManager.PrefabNames.MechaComponentDropSprite] .AllocateGameObject <MechaComponentDropSprite>(ClientBattleManager.Instance.MechaComponentDropSpriteContainerRoot); mcds.Initialize(mci, MechaComponentDict[mci.GUID].transform.position); }; MechaInfo.MechaEditorInventory = new MechaEditorInventory( DragAreaDefines.MechaEditorArea.ToString(), DragAreaDefines.MechaEditorArea, ConfigManager.GridSize, ConfigManager.EDIT_AREA_FULL_SIZE, ConfigManager.EDIT_AREA_FULL_SIZE, false, false, false, 0, () => ControlManager.Instance.Building_RotateItem.Down); MechaInfo.MechaEditorInventory.OnRemoveItemSucAction = (item) => { ((MechaComponentInfo)item.ItemContentInfo).RemoveMechaComponentInfo(); }; MechaInfo.MechaEditorInventory.RefreshInventoryGrids(); MechaInfo.OnInstantiated?.Invoke(); // 将已经积攒的未实例化的组件实例化 MechaInfo.OnInstantiated = null; MechaInfo.MechaEditorInventory.RefreshConflictAndIsolation(); // MechaEditorArea if (mechaInfo.MechaCamp == MechaCamp.Player) { GameObject mea = PrefabManager.Instance.GetPrefab(nameof(MechaEditArea)); GameObject meaGO = Instantiate(mea); meaGO.transform.parent = transform; meaGO.transform.localPosition = new Vector3(0, -0.5f, 0); MechaEditArea = meaGO.GetComponent <MechaEditArea>(); MechaEditArea.Init(mechaInfo); } foreach (KeyValuePair <uint, MechaComponentInfo> kv in mechaInfo.MechaComponentInfoDict) // 将其它的组件实例化 { if (MechaComponentDict.ContainsKey(kv.Key)) { continue; } AddMechaComponent(kv.Value); } GridShown = false; SlotLightsShown = false; Initialize_Fighting(mechaInfo); }
private void Initialize_Fighting(MechaInfo mechaInfo) { }
void FixedUpdate_Fighting() { MechaInfo.FixedUpdate_Fighting(); }
void LateUpdate_Fighting() { MechaInfo.LateUpdate_Fighting(); }
public ExecuteInfo(Ability ability, MechaInfo mechaInfo, MechaComponentInfo mechaComponentInfo) { Ability = ability; MechaInfo = mechaInfo; MechaComponentInfo = mechaComponentInfo; }