public static MechaComponentBase BaseInitialize(MechaComponentInfo mechaComponentInfo, Mecha parentMecha) { MechaComponentBase mcb = GameObjectPoolManager.Instance.MechaComponentPoolDict[mechaComponentInfo.MechaComponentType].AllocateGameObject <MechaComponentBase>(parentMecha ? parentMecha.transform : null); mcb.Initialize(mechaComponentInfo, parentMecha); return(mcb); }
public MechaComponentInfo Clone() { MechaComponentInfo mci = new MechaComponentInfo(MechaComponentType, GridPos, TotalLife, DropProbability); mci.OccupiedGridPositions = CloneVariantUtils.List(OccupiedGridPositions); return(mci); }
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); }
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(); }
public void AddEnemy() { Mecha EnemyMecha = GameObjectPoolManager.Instance.PoolDict[GameObjectPoolManager.PrefabNames.Mecha].AllocateGameObject <Mecha>(MechaContainer); List <MechaComponentInfo> enemyComponentInfos = new List <MechaComponentInfo>(); for (int i = -4; i <= 4; i++) { for (int j = -6; j <= 6; j++) { MechaComponentInfo mci; if (i == 0 && j == 0) { mci = new MechaComponentInfo(MechaComponentType.Core, new GridPos(i, j, GridPos.Orientation.Up), 500, 0); } else { mci = new MechaComponentInfo((MechaComponentType)Random.Range(1, Enum.GetNames(typeof(MechaComponentType)).Length), new GridPos(i, j, GridPos.Orientation.Up), 50, 5); } enemyComponentInfos.Add(mci); } } EnemyMecha.Initialize(new MechaInfo("Junk Mecha", MechaType.Enemy, enemyComponentInfos)); EnemyMecha.transform.position = new Vector3(10, 0, 10); EnemyMechas.Add(EnemyMecha); }
private void OnDamaged(MechaComponentInfo attacker, int damage) { ClientGameManager.Instance.BattleMessenger.Broadcast <AttackData>((uint)ENUM_BattleEvent.Battle_MechaComponentAttackTip, new AttackData(attacker, this, damage, BattleTipType.Attack, 0, 0)); MechaComponentModelRoot.OnDamage((float)MechaComponentInfo.M_LeftLife / MechaComponentInfo.M_TotalLife); MechaComponentModelRoot.SetAnimTrigger("OnHit"); }
private void AddCoreLifeSlider(MechaComponentInfo mci) { HUDSlider hudSlider = GameObjectPoolManager.Instance.PoolDict[GameObjectPoolManager.PrefabNames.HUDSlider].AllocateGameObject <HUDSlider>(CoreLifeSliderContainer); hudSlider.Initialize(1f, CoreLifeSliderColor, out mci.OnLifeChange); hudSlider.SetValue(mci.M_LeftLife, mci.M_TotalLife); Core_HUDSliders.Add(hudSlider); }
public void Initialize(MechaComponentInfo mechaComponentInfo, Vector3 position) { MechaComponentInfo = mechaComponentInfo.Clone(); Sprite sprite = BagManager.Instance.MechaComponentSpriteDict[mechaComponentInfo.MechaComponentType]; SpriteRenderer.sprite = sprite; transform.position = position; }
public void Initialize(MechaComponentInfo mechaComponentInfo, Vector3 position) { MechaComponentInfo = mechaComponentInfo.Clone(); Sprite sprite = BackpackManager.Instance.GetBackpackItemSprite(mechaComponentInfo.ItemSpriteKey); SpriteRenderer.sprite = sprite; transform.position = position; }
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; }
public bool AddMechaComponentToBag(MechaComponentInfo mci, GridPos.Orientation orientation, List <GridPos> realGridPoses, out BagItem bagItem) { bool suc = BagPanel.TryAddItem(mci, orientation, realGridPoses, out bagItem); if (suc) { mechaComponentInfosInBag.Add(mci); } return(suc); }
public bool AddMechaComponentToBag(MechaComponentInfo mci, out BagItem bagItem) { bool suc = BagPanel.TryAddItem(mci, out bagItem); if (suc) { mechaComponentInfosInBag.Add(mci); } return(suc); }
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 override void PoolRecycle() { UnregisterAbilityEvents(); MechaComponentGridRoot.SetIsolatedIndicatorShown(true); MechaComponentGridRoot.SetInBattle(false); MechaComponentModelRoot.ResetColor(); MechaComponentInfo?.Reset(); MechaComponentInfo = null; Mecha = null; isReturningToBackpack = false; OnRemoveMechaComponentSuc = null; base.PoolRecycle(); }
private void Initialize(MechaComponentInfo mechaComponentInfo, Mecha parentMecha) { IsDead = false; UnlinkAllBuffs(); MechaComponentInfo = mechaComponentInfo; GridPos.ApplyGridPosToLocalTrans(mechaComponentInfo.GridPos, transform, GameManager.GridSize); RefreshOccupiedGridPositions(); ParentMecha = parentMecha; M_TotalLife = mechaComponentInfo.TotalLife; M_LeftLife = mechaComponentInfo.TotalLife; MechaHitBoxRoot.SetInBattle(true); Child_Initialize(); }
private void AddItem(MechaComponentInfo mci, GridPos.Orientation orientation, List <GridPos> realOccupiedGPs, out BagItem bagItem) { IntRect realSpace = GetSizeFromGridPositions(realOccupiedGPs); GridPos GridPos = new GridPos(realSpace.x, realSpace.z, orientation); bagItem = GameObjectPoolManager.Instance.PoolDict[GameObjectPoolManager.PrefabNames.BagItem].AllocateGameObject <BagItem>(ItemContainer); bagItem.Initialize(mci, realSpace.width, realSpace.height, GridPos, realOccupiedGPs, false); bagItems.Add(bagItem); foreach (GridPos gp in realOccupiedGPs) { bagGridMatrix[gp.x, gp.z].State = BagGrid.States.Unavailable; } }
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); }
static IEnumerator Co_Render() { ClientLevelManager.Instance.CurrentClientLevel.gameObject.SetActive(false); ClientBattleManager.Instance.MechaContainerRoot.gameObject.SetActive(false); Camera camera = CameraManager.Instance.MainCamera; Quaternion oriRot = camera.transform.rotation; Quaternion topDownViewRot = Quaternion.Euler(90, 0, 0); float ori_FieldOfView = camera.fieldOfView; camera.fieldOfView = 6f; CameraFollow.NeedLerp = false; foreach (KeyValuePair <string, MechaComponentConfig> kv in ConfigManager.MechaComponentConfigDict) { string filename = Application.dataPath + "/../../Arts/MechaComponentScreenShots/" + kv.Key + ".png"; MechaComponentInfo mci = new MechaComponentInfo(kv.Value, Quality.Common); GridRect boundingRect = mci.IInventoryItemContentInfo_OriginalOccupiedGridPositions.GetBoundingRectFromListGridPos(); if (boundingRect.size.x != boundingRect.size.z) { camera.transform.rotation = topDownViewRot; } else { camera.transform.rotation = oriRot; } if (boundingRect.size.x == 1 && boundingRect.size.z == 1) { camera.fieldOfView = 6f; } else { camera.fieldOfView = 10f; } yield return(new WaitForSeconds(0.1f)); MechaComponent mc = MechaComponent.BaseInitialize_Editor(mci, null); mc.transform.rotation = Quaternion.Euler(0, mc.ScreenShotAngle, 0); CaptureScreenShot.CaptureTransparentScreenShot(camera, 800, 800, filename); DestroyImmediate(mc.gameObject); yield return(new WaitForSeconds(0.1f)); } camera.transform.rotation = oriRot; camera.fieldOfView = ori_FieldOfView; CameraFollow.NeedLerp = true; ClientLevelManager.Instance.CurrentClientLevel.gameObject.SetActive(true); ClientBattleManager.Instance.MechaContainerRoot.gameObject.SetActive(true); }
public bool TryAddItem(MechaComponentInfo mci, out BagItem bagItem) { bool placeFound = FindSpaceToPutItem(mci, out GridPos.Orientation orientation, out List <GridPos> realOccupiedGPs); if (placeFound) { AddItem(mci, orientation, realOccupiedGPs, out bagItem); return(true); } else { bagItem = null; return(false); } }
public bool TryAddItem(MechaComponentInfo mci, GridPos.Orientation orientation, List <GridPos> realGridPoses, out BagItem bagItem) { bool placeFound = CheckSpaceAvailable(realGridPoses); if (placeFound) { AddItem(mci, orientation, realGridPoses, out bagItem); return(true); } else { bagItem = null; return(false); } }
private bool FindSpaceToPutItem(MechaComponentInfo mci, out GridPos.Orientation orientation, out List <GridPos> realOccupiedGPs) { realOccupiedGPs = new List <GridPos>(); orientation = GridPos.Orientation.Up; foreach (string s in Enum.GetNames(typeof(GridPos.Orientation))) { orientation = (GridPos.Orientation)Enum.Parse(typeof(GridPos.Orientation), s); if (FindSpaceToPutRotatedItem(mci, orientation, realOccupiedGPs)) { return(true); } } return(false); }
private bool FindSpaceToPutRotatedItem(MechaComponentInfo mci, GridPos.Orientation orientation, List <GridPos> realOccupiedGPs) { List <GridPos> occupiedGridPositions = BagManager.Instance.MechaComponentOccupiedGridPosDict[mci.MechaComponentType]; IntRect space = GetSizeFromGridPositions(occupiedGridPositions); bool heightWidthSwap = orientation == GridPos.Orientation.Right || orientation == GridPos.Orientation.Left; GridPos temp = new GridPos(space.x, space.z); GridPos temp_rot = GridPos.RotateGridPos(temp, orientation); int xStart_temp = temp_rot.x; int zStart_temp = temp_rot.z; for (int i = 0 - zStart_temp; i <= 10 - (heightWidthSwap ? space.width : space.height) - zStart_temp; i++) { for (int j = 0 - xStart_temp; j <= 10 - (heightWidthSwap ? space.height : space.width) - xStart_temp; j++) { bool canHold = true; foreach (GridPos gp in occupiedGridPositions) { GridPos rot_gp = GridPos.RotateGridPos(gp, orientation); int col = j + rot_gp.x; int row = i + rot_gp.z; if (col < 0 || col >= 10 || row < 0 || col >= 10) { canHold = false; break; } if (!bagGridMatrix[col, row].Available) { canHold = false; break; } realOccupiedGPs.Add(new GridPos(col, row, GridPos.Orientation.Up)); } if (canHold) { return(true); } realOccupiedGPs.Clear(); } } return(false); }
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 Initialize(MechaComponentInfo mechaComponentInfo, Mecha parentMecha) { SetLayer(LayerManager.Instance.GetLayerByMechaCamp(mechaComponentInfo.MechaInfo.MechaCamp)); mechaComponentInfo.OnRemoveMechaComponentInfoSuc += (mci) => { OnRemoveMechaComponentSuc?.Invoke(this); PoolRecycle(); }; mechaComponentInfo.OnHighLightColorChange += HighLightColorChange; HighLightColorChange(QualityManager.GetQuality(mechaComponentInfo.Quality).Color, mechaComponentInfo.CurrentPowerUpgradeData.HighLightColorIntensity); { mechaComponentInfo.InventoryItem.OnSetGridPosHandler = (gridPos_World) => { GridPosR.ApplyGridPosToLocalTrans(gridPos_World, transform, ConfigManager.GridSize); MechaInfo.MechaEditorInventory.RefreshConflictAndIsolation(); }; mechaComponentInfo.InventoryItem.OnIsolatedHandler = (shown) => { if (shown) { MechaComponentModelRoot.SetBuildingBasicEmissionColor(CommonUtils.HTMLColorToColor("#E42835")); } else { MechaComponentModelRoot.ResetBuildingBasicEmissionColor(); } MechaComponentGridRoot.SetIsolatedIndicatorShown(shown); }; mechaComponentInfo.InventoryItem.OnConflictedHandler = MechaComponentGridRoot.SetGridConflicted; mechaComponentInfo.InventoryItem.OnResetConflictHandler = MechaComponentGridRoot.ResetAllGridConflict; } MechaComponentInfo = mechaComponentInfo; GridPos.ApplyGridPosToLocalTransXZ(MechaComponentInfo.InventoryItem.GridPos_World, transform, ConfigManager.GridSize); Mecha = parentMecha; MechaComponentGridRoot.SetInBattle(true); Initialize_Fighting(); }
public void Initialize(MechaComponentInfo mci, int width, int height, GridPos myPos, List <GridPos> realPositionsInBagPanel, bool moving) { MechaComponentInfo = mci; Image.sprite = BagManager.Instance.MechaComponentSpriteDict[mci.MechaComponentType]; Width = width; Height = height; GridPos = myPos; if (!moving) { GridPos_BeforeMove = myPos; } // Resize and rotate to fit the grid Vector2 size = new Vector2(Width * BagManager.Instance.BagItemGridSize, Height * BagManager.Instance.BagItemGridSize); Vector2 size_rev = new Vector2(Height * BagManager.Instance.BagItemGridSize, Width * BagManager.Instance.BagItemGridSize); bool isRotated = GridPos.orientation == GridPos.Orientation.Right || GridPos.orientation == GridPos.Orientation.Left; if (isRotated) { ((RectTransform)transform).sizeDelta = size; BagItemGridHitBoxes.Initialize(realPositionsInBagPanel, myPos); Image.rectTransform.sizeDelta = size_rev; Image.transform.rotation = Quaternion.Euler(0, 0, 90f); } else { ((RectTransform)transform).sizeDelta = size; BagItemGridHitBoxes.Initialize(realPositionsInBagPanel, myPos); Image.rectTransform.sizeDelta = size; Image.transform.rotation = Quaternion.Euler(0, 0, 0f); } ((RectTransform)transform).anchoredPosition = new Vector2(GridPos.x * BagManager.Instance.BagItemGridSize, -GridPos.z * BagManager.Instance.BagItemGridSize); RealPositionsInBagPanel = realPositionsInBagPanel; if (!moving) { RealPositionsInBagPanel_BeforeMove = CloneVariantUtils.List(RealPositionsInBagPanel); } }
public void Init() { DragProcessor <BackpackItem> dragProcessor_BackpackItem = new DragProcessor <BackpackItem>(); dragProcessor_BackpackItem.Init( UIManager.Instance.UICamera, LayerManager.Instance.LayerMask_BackpackItemGrid, (out Vector2 mouseScreenPos) => { if (ControlManager.Instance.BuildingInputActionEnabled) { mouseScreenPos = ControlManager.Instance.Building_MousePosition; return(true); } else { mouseScreenPos = Vector2.zero; return(false); } }, ScreenMousePositionToWorld_BackpackDragArea, delegate(BackpackItem bi, Collider collider, DragProcessor dragProcessor) { }, delegate(BackpackItem bi, Collider collider, DragProcessor dragProcessor) { } ); DragProcessor <MechaComponentDropSprite> dragProcessor_MechaComponentDropSprite = new DragProcessor <MechaComponentDropSprite>(); dragProcessor_MechaComponentDropSprite.Init( CameraManager.Instance.MainCamera, LayerManager.Instance.LayerMask_ItemDropped, (out Vector2 mouseScreenPos) => { if (ControlManager.Instance.BuildingInputActionEnabled) { mouseScreenPos = ControlManager.Instance.Building_MousePosition; return(true); } else { mouseScreenPos = Vector2.zero; return(false); } }, ScreenMousePositionToWorld_MechaEditorInventory, delegate(MechaComponentDropSprite mcds, Collider collider, DragProcessor dragProcessor) { Ray ray = CameraManager.Instance.MainCamera.ScreenPointToRay(ControlManager.Instance.Building_MousePosition); MechaComponentInfo mci = mcds.MechaComponentInfo.Clone(); ClientBattleManager.Instance.PlayerMecha.MechaInfo.AddMechaComponentInfo(mci, GridPosR.Zero); MechaComponent mc = ClientBattleManager.Instance.PlayerMecha.MechaComponentDict[mci.GUID]; GridPos gp = GridUtils.GetGridPosByMousePos(ClientBattleManager.Instance.PlayerMecha.transform, ray, Vector3.up, ConfigManager.GridSize); mci.InventoryItem.SetGridPosition(gp); DragManager.Instance.CurrentDrag = mc.GetComponent <Draggable>(); DragManager.Instance.CurrentDrag.SetOnDrag(true, collider, dragProcessor); mcds.PoolRecycle(); }, delegate(MechaComponentDropSprite mcds, Collider collider, DragProcessor dragProcessor) { } ); DragManager.Instance.Init( () => ControlManager.Instance.Building_MouseLeft.Down, () => ControlManager.Instance.Building_MouseLeft.Up, Debug.LogError, LayerManager.Instance.LayerMask_DragAreas); DragProcessor <MechaComponent> dragProcessor_MechaComponent = new DragProcessor <MechaComponent>(); dragProcessor_MechaComponent.Init( CameraManager.Instance.MainCamera, LayerManager.Instance.LayerMask_ComponentHitBox_Player, (out Vector2 mouseScreenPos) => { if (ControlManager.Instance.BuildingInputActionEnabled) { mouseScreenPos = ControlManager.Instance.Building_MousePosition; return(true); } else { mouseScreenPos = Vector2.zero; return(false); } } , ScreenMousePositionToWorld_MechaEditorInventory, delegate(MechaComponent mc, Collider collider, DragProcessor dragProcessor) { }, delegate(MechaComponent mc, Collider collider, DragProcessor dragProcessor) { } ); }
public ExecuteInfo(Ability ability, MechaInfo mechaInfo, MechaComponentInfo mechaComponentInfo) { Ability = ability; MechaInfo = mechaInfo; MechaComponentInfo = mechaComponentInfo; }
public void AddMechaComponent(MechaComponentInfo mci) { MechaComponentBase mcb = MechaComponentBase.BaseInitialize(mci, this); AddMechaComponent(mcb); }