public void OnBeginDrag(PointerEventData eventData) { GameShape gameShape = GetSlotShape(); ShapeData shapeData = gameShape?.GetShapeData(); if (canInteract && canSelect && shapeData != null) { if (!selected) { GameSlot selectedSlot = GameManager.manager.GetSelectedSlot(); if (selectedSlot != null && selectedSlot != this) { GameManager.manager.DeselectSlot(); } GameManager.manager.SelectSlot(this); themeElement.SetElementToHighlighted(); } Color baseColor = gameShape.GetComponent <Image>().color; gameShape.GetComponent <Image>().color = new Color(baseColor.r, baseColor.g, baseColor.b, baseColor.a / 2f); DragInputManager.dragInputManager.BeginDrag(shapeData, this, gameShape?.GetComponent <Transform>().localScale ?? Vector3.one); beganDrag = true; } }
public void playOnSlot(Object o) { GameSlot gs = o as GameSlot; currentProfileSlot = gs.index; if (saveGameDescription[currentProfileSlot].empty || saveGameDescription[currentProfileSlot].corrupt) { #if UNITY_ANDROID Muneris.CloseAds(); Muneris.LogEvent("BTN_NEW_SLOT"); #endif DataGame.newSaveGame(currentProfileSlot); Game.game.saveGameSlot = currentProfileSlot; startGame(); } else { #if UNITY_ANDROID Muneris.CloseAds(); #endif Game.game.resetData(); Game.game.saveGameSlot = currentProfileSlot; DataGame.loadSaveGame(currentProfileSlot); } }
private static void GenerateShapes(Transform boardParent, GeneratorShapePrefs genPrefs) { // check for invalid input if (genPrefs == null || boardParent == null) { return; } // Generate list of available slots List <int> availableSlots = new List <int>(); for (int s = 0; s < boardParent.childCount; s++) { if (boardParent.GetChild(s).GetComponent <GameSlot>() != null) { availableSlots.Add(s); } } // Generating the shapes List <ShapeData> shapesToCreate = genPrefs.GetShapeDataList(); GameSlot targetGameSlot = null; int targetSlotIndex; foreach (ShapeData shapeData in shapesToCreate) { targetSlotIndex = Random.Range(0, availableSlots.Count - 1); targetGameSlot = boardParent.GetChild(availableSlots[targetSlotIndex]).GetComponent <GameSlot>(); GameSlotTools.CreateSlotShape(targetGameSlot.transform, shapeData.shapeType, shapeData.shapeColor, genPrefs.targetShapeScale); EditorUtility.SetDirty(targetGameSlot); availableSlots.RemoveAt(targetSlotIndex); } }
public bool SelectSlot(GameSlot targetSlot) { // Check for two shapes switching around if (!switching) { // Checking for which reference if (slot1 == null) { slot1 = targetSlot; boardManager.SelectGameSlots(); return(true); } else if (slot2 == null) { // Two Slots Selected, switch the shapes slot2 = targetSlot; boardManager.DeselectGameSlots(); processedBoardData = new BoardData(gameBoardParent, new Vector2Int(boardManager.GetBoardWidth(), boardManager.GetBoardHeight())); //undoManager.ProcessGameBoard(gameBoardParent); StartCoroutine(boardManager.MoveShapes(slot1, slot2)); return(true); } } // Returning the default case return(false); }
private void DrawGameSlotTools() { EditorGUILayout.Separator(); GameObject[] selectedObjects = Selection.gameObjects; if (selectedObjects != null) { if (selectedObjects.Length > 1) { EditorGUILayout.LabelField("Muli Select Editing isn't supported", EditorStyles.helpBox); } else if (selectedObjects.Length == 1) { GameSlot currentSelectSlot = selectedObjects[0].GetComponent <GameSlot>(); if (currentSelectSlot == null) { EditorGUILayout.LabelField("Please Select a GameSlot object to begin editing", EditorStyles.helpBox); } else { DrawGameShapeOptions(currentSelectSlot); } } else { EditorGUILayout.LabelField("Please Select a GameSlot object to begin editing", EditorStyles.helpBox); } } }
public void DeselectSlot() { if (!switching && slot1 != null) { boardManager.DeselectGameSlots(); slot1 = null; } }
private void Awake() { gameSlot = transform.parent.GetComponent <GameSlot>(); gameSlot.GetComponent <DynamicGameThemeElement>().SetElementToTertiary(); SetLockStateMachine(lockData.lockType); ActivateLock(); }
public void MarkSwitchingAsComplete() { undoManager.PushBoardData(processedBoardData); processedBoardData = null; switching = false; slot1 = null; slot2 = null; }
public bool SetSecondarySlot(GameSlot newSlot) { if (newSlot != null && newSlot != startingSlot) { highlightedSecondarySlot = newSlot; return(true); } return(false); }
public float GetBonusFromNGP() { GameSlot currentGameSlot = GameManager.Instance.currentGameSlot; if (currentGameSlot.gameType != GameSlot.GameType.NewGamePlus) { return(0f); } string floatName = currentGameSlot.wasDlcCompleted ? "ngpPotionsHealFactor" : "ngpPostDLCPotionsHealFactor"; return(Constants.GetFloat(floatName)); }
public void BeginDrag(ShapeData newShape, GameSlot slot, Vector3 scale) { rendererTransform.localScale = scale; rendererTransform.position = Input.mousePosition; shapeRenderer.SetActive(true); gameShape.ConfigureShape(newShape.shapeType, newShape.shapeColor); dragging = true; startingSlot = slot; boardManager.SelectGameSlots(); }
private void LoadSlotNames() { slot = SaveManager.Instance.GameSlots[slotNumber - 1]; if (slot != null) { SaveName.text = slot.SaveName; PlayerLevel.text = slot.PlayerData.Stats.Level.ToString(); } else { SaveName.text = "New Game"; PlayerLevel.text = "Level 1"; } }
public void loadGame(Object o) { GameSlot gs = o as GameSlot; currentProfileSlot = gs.index; Game game = Game.game; game.resetData(); Game.game.saveGameSlot = currentProfileSlot; DataGame.loadSaveGame(currentProfileSlot); }
private Selectable CreateButton(GameSlot slot) { var loadItem = GameObject.Instantiate <GameObject>(this.LoadItemTemplate, this.Root.transform); loadItem.GetComponent <LoadItemView>().SlotName = slot.Name; var selectable = loadItem.GetComponent <Selectable>(); var navigation = selectable.navigation; navigation.selectOnRight = this.VerticalBar; selectable.navigation = navigation; return(selectable); }
public void SwitchSolutionShapes(GameSlot s1, int s1Index, GameSlot s2, int s2Index) { // Setting the parents GameShape s = s1.GetSlotShape(); s.transform.SetParent(s2.transform); s.transform.localPosition = new Vector3(0.5f, -0.5f); s = s2.GetSlotShape(); s.transform.SetParent(s1.transform); s.transform.localPosition = new Vector3(0.5f, -0.5f); // Triggering Shape Destruction(s) TriggerShapeDestruction(s1Index, solutionBoardParent); TriggerShapeDestruction(s2Index, solutionBoardParent); }
public void FinishDrag() { boardManager.DeselectGameSlots(); if (startingSlot != null && highlightedSecondarySlot != null) { gameManager.SelectSlot(highlightedSecondarySlot); } else { gameManager.DeselectSlot(); } StopDisplayingDraggedShape(); dragging = false; startingSlot = null; }
public IEnumerator SwitchShapes(GameSlot slot1, GameSlot slot2) { // Setting the parents Transform shape1 = slot1.GetSlotShapeTransform(); Transform shape2 = slot2.GetSlotShapeTransform(); shape1.SetParent(slot2.transform); shape2.SetParent(slot1.transform); slot1.SetSlotShapeReference(shape2); slot2.SetSlotShapeReference(shape1); onShapeSwap?.Invoke(); while (locksAnimating > 0) { yield return(null); } // Triggering Shape Destruction(s) int destroyedShapes = 0; destroyedShapes += TriggerShapeDestruction(slot1.GetSlotIndex(), gameBoardParent); destroyedShapes += TriggerShapeDestruction(slot2.GetSlotIndex(), gameBoardParent); while (shapesBeingDestroyed > 0) { yield return(null); } onShapeDestroy?.Invoke(destroyedShapes); while (locksAnimating > 0) { yield return(null); } // Reset each slot slot1.ResetSlotState(); slot2.ResetSlotState(); if (shapesBeingDestroyed == 0) { gameManager.CheckGameState(); } gameManager.MarkSwitchingAsComplete(); }
private void GenerateBoardSlots(BoardData boardData, GridLayoutGroup group, GameObject slotPrefab, GameObject transformerPrefab, Transform boardParent, int width, int height) { RectTransform boardTransform = boardParent.GetComponent <RectTransform>(); float baseBoardSize = Mathf.Min(boardTransform.rect.width, boardTransform.rect.height); float cellGap = 64f * (3f / (float)width); float cellWidth = (baseBoardSize - ((width - 1) * cellGap)) / width; float cellHeight = (baseBoardSize - ((height - 1) * cellGap)) / height; group.cellSize = new Vector2(cellWidth, cellHeight); group.spacing = new Vector2(cellGap, cellGap); for (int i = 0; i < width * height; i++) { if (boardData.transformers[i] == null || boardData.transformers[i].transformerType == ShapeTransformer.TransformerType.None) { GameSlot slot = Instantiate(slotPrefab, boardParent).GetComponent <GameSlot>(); if (Application.isPlaying) { slot.transform.localScale = Vector3.zero; } slot.SetSlotIndex(i); } else { ShapeTransformer newTransformer = Instantiate(transformerPrefab, boardParent).GetComponent <ShapeTransformer>(); newTransformer.SetTransformerData(boardData.transformers[i]); if (Application.isPlaying) { newTransformer.transform.localScale = Vector3.zero; } float childSize = (cellWidth / 384f); Vector3 newScale = new Vector3(childSize, childSize); for (int j = 0; j < newTransformer.transform.childCount; j++) { newTransformer.transform.GetChild(j).localScale = new Vector3(childSize, childSize); } } } boardManager.SetBoardSize(width, height); }
public static void CreateSlotShape(Transform slot, GameShape.ShapeType shapeType, GameShape.ColorType shapeColor, float shapeSize) { GameObject shapePrefab = Resources.Load <GameObject>("Prefabs/GameShape"); GameObject newShape = PrefabUtility.InstantiatePrefab(shapePrefab, slot) as GameObject; newShape.transform.localPosition = Vector3.zero; newShape.transform.localScale = new Vector3(shapeSize, shapeSize); GameShape shapeRef = newShape.GetComponent <GameShape>(); shapeRef.ConfigureShape(shapeType, shapeColor); GameSlot slotRef = slot.GetComponent <GameSlot>(); slotRef.SetSlotShapeReference(newShape.transform); EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); }
public virtual void Release() { Vector2 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); Collider2D collider2D = Physics2D.OverlapPoint(mousePos, slotLayer); if (collider2D) { if (collider2D.GetComponent <GameSlot>()) { GameSlot gameSlot = collider2D.GetComponent <GameSlot>(); if (!gameSlot.IsInUse) { OnGameSlot?.Invoke(gameSlot); } else { //transform.SetParent(itemSlot.transform); Undo(); } } else if (collider2D.GetComponent <InventorySlot>()) { InventorySlot inventorySlot = collider2D.GetComponent <InventorySlot>(); if (!inventorySlot.IsInUse) { OnInventorySlot?.Invoke(inventorySlot); } else { // transform.SetParent(itemSlot.transform); Undo(); } } } else { // transform.SetParent(itemSlot.transform); Undo(); } EndDrag(); }
public ShapeData GetBoardShapeData(int slotIndex, Transform boardParent) { GameSlot slot = GetGameSlot(slotIndex, boardParent); if (slot.CheckCanInteract()) { GameShape shape = slot.GetSlotShape(); if (shape != null) { return(shape.GetShapeData() ?? null); } else { return(null); } } else { return(null); } }
public void Spawn(string userId, GameCube gameCube, GameSlot gameSlot) { anim.Stop(); ownerId = userId; this.gameCube = gameCube; this.gameSlot = gameSlot; state = State.Idle; cubeData = XmlKey.CubeData.Find <CubeDataXml.Data>(x => x.CubeId == gameSlot.CubeId); var color = new Color(cubeData.Color[0], cubeData.Color[1], cubeData.Color[2], 1f); render.material.color = color; render.transform.localRotation = Quaternion.identity; range.material.color = new Color(color.r, color.g, color.b, 0.1f); range.transform.localScale = new Vector3(gameCube.CombineLv * 2f, gameCube.CombineLv * 2f, range.transform.localScale.z); combineLv_text.text = gameCube.CombineLv.ToString(); base.Spawn(); StartShot(); }
public IEnumerator MoveShapes(GameSlot slot1, GameSlot slot2) { // Declaring temporary storeage variables Transform shape1P = slot1.GetSlotShapeTransform(), shape2P = slot2.GetSlotShapeTransform(); Vector3 shape1StartPosition = shape1P.position, shape2StartPosition = shape2P.position; float mult = 1f / (10f / 24f); float progress = 0; while (progress < 1f) { // Incrementing the progress progress += Mathf.Clamp(Time.deltaTime * mult, 0f, 1f); // Moving the shapes shape1P.position = Vector3.Lerp(shape1StartPosition, shape2StartPosition, progress); shape2P.position = Vector3.Lerp(shape2StartPosition, shape1StartPosition, progress); // Frame delay yield return(null); } StartCoroutine(SwitchShapes(slot1, slot2)); }
public bool CheckForVictory(Transform gameBoardParent, Transform solutionBoardParent) { // Setting the storage vars GameSlot slot1 = null, slot2 = null; GameShape shape1 = null, shape2 = null; // Check each square for (int i = 0; i < gameBoardParent.childCount; i++) { // Getting each slot reference slot1 = gameBoardParent.GetChild(i).GetComponent <GameSlot>(); slot2 = solutionBoardParent.GetChild(i).GetComponent <GameSlot>(); // Getting Shape References shape1 = slot1 != null?slot1.GetSlotShape() : null; shape2 = slot2 != null?slot2.GetSlotShape() : null; // Comparing the two shapes from each slot, return false if shapes aren't equal if ((shape1 == null && shape2 != null) || (shape1 != null && shape2 == null)) { return(false); } else if (shape1 != null && shape2 != null) { if (!slot1.GetSlotShape().Equals(slot2.GetSlotShape())) { return(false); } } } // All the slots evaluate as true, trigger Complete Level CompleteLevel(); return(true); }
public override StoryLine CreateNewStory(Account account, GameSlot slot) { throw new NotImplementedException(); }
public void LoadGameSlot(GameSlot slot) { gameSlot = slot; }
/* A D D G A M E */ /*---------------------------------------------------------------------------- %%Function: AddGame %%Qualified: ArbWeb.GameData.GameSlots.AddGame %%Contact: rlittle ----------------------------------------------------------------------------*/ public void AddGame(GameSlot gms) { string sTeamSport = gms.Team + "#-#" + gms.Sport; m_plgmsSorted.Add(String.Format("{0}_{1}_{2}", gms.Name, gms.Dttm.ToString("yyyyMMdd:HH:mm"), m_plgmsSorted.Count), gms); m_plgmsSortedGameNum.Add(String.Format("{0}_{1}_{2}_{3}_{4}_{5}", gms.Dttm.ToString("yyyyMMdd:HH:mm"), gms.Site, gms.Sport, gms.Level, gms.GameNum, m_plgmsSortedGameNum.Count), gms); if (!m_mpnumgm.ContainsKey(gms.GameNum)) { Game gm; m_mpnumgm.Add(gms.GameNum, gm = new Game()); m_plgmSorted.Add(String.Format("{0}-{1}", gms.Dttm.ToString("yyyymmdd-HH:MM"), gms.GameNum), gm); } m_mpnumgm[gms.GameNum].AddGameSlot(gms); if (gms.Team != null && gms.Team.Length > 0) { if (m_mpTeamCount.ContainsKey(gms.Team)) m_mpTeamCount[gms.Team]++; else m_mpTeamCount.Add(gms.Team, 1); if (m_mpTeamCount.ContainsKey(sTeamSport)) m_mpTeamCount[sTeamSport]++; else m_mpTeamCount.Add(sTeamSport, 1); EnsureSportLevelPos(gms.Sport, gms.Level, gms.Pos); } }
public void AddGameSlot(GameSlot gms) { m_plgms.Add(gms); m_cSlots++; if (gms.Open) m_cOpen++; }
protected abstract void GameSlotCollision(GameSlot gameSlot);
public void ResetSecondarySlot() { highlightedSecondarySlot = null; }
private void DrawGameShapeOptions(GameSlot slot) { GameShape shapeData = slot.GetSlotShape(); if (shapeData != null) { EditorGUILayout.LabelField($"Shape Info", EditorStyles.boldLabel); EditorGUILayout.LabelField($"Shape Color: {shapeData.colorType}"); EditorGUILayout.LabelField($"Shape Type: {shapeData.GetShapeType()}"); } else { EditorGUILayout.LabelField("Shape Info: No Shape Available"); } EditorGUILayout.Separator(); EditorGUILayout.LabelField("Lock Options", EditorStyles.boldLabel); desiredLockType = (SlotLock.LockType)EditorGUILayout.EnumPopup("Lock Type", desiredLockType); desiredLockTimer = EditorGUILayout.IntField("Lock Timer", desiredLockTimer); desiredLockSize = EditorGUILayout.FloatField("Lock Size", desiredLockSize); EditorGUILayout.BeginHorizontal(); if (slot.GetSlotLock() != null) { if (GUILayout.Button("Edit Lock", GUILayout.MaxWidth(150f))) { GameSlotTools.EditSlotLock(slot.transform, desiredLockType, desiredLockTimer, desiredLockSize); EditorUtility.SetDirty(slot.GetComponent <GameSlot>().GetSlotLock()); EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); } } else { if (GUILayout.Button("Create Lock", GUILayout.MaxWidth(150f))) { GameSlotTools.CreateSlotLock(slot.transform, desiredLockType, desiredLockTimer, desiredLockSize); EditorUtility.SetDirty(slot.GetComponent <GameSlot>().GetSlotLock()); EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); } } SlotLock slotLock = slot.GetSlotLock(); if (slotLock != null && GUILayout.Button("Destroy Lock", GUILayout.Width(150f))) { DestroyImmediate(slotLock.gameObject); EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); EditorGUILayout.LabelField("Shape Options", EditorStyles.boldLabel); desiredShapeType = (GameShape.ShapeType)EditorGUILayout.EnumPopup("Shape Type", desiredShapeType); desiredShapeColor = (GameShape.ColorType)EditorGUILayout.EnumPopup("Shape Color", desiredShapeColor); desiredShapeSize = EditorGUILayout.FloatField("Shape Scale", desiredShapeSize); EditorGUILayout.BeginHorizontal(); if (slot.GetSlotShape() != null) { if (GUILayout.Button("Edit Shape", GUILayout.MaxWidth(150f))) { GameSlotTools.EditSlotShape(slot.transform, desiredShapeType, desiredShapeColor, desiredShapeSize); EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); } } else { if (GUILayout.Button("Create Shape", GUILayout.MaxWidth(150f))) { GameSlotTools.CreateSlotShape(slot.transform, desiredShapeType, desiredShapeColor, desiredShapeSize); EditorUtility.SetDirty(slot.GetComponent <GameSlot>()); EditorUtility.SetDirty(slot.GetComponent <GameSlot>().GetSlotShape()); EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); } } if (shapeData != null && GUILayout.Button("Destroy Shape", GUILayout.Width(150f))) { DestroyImmediate(shapeData.gameObject); EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); }
public SpecificGameslotRule(Team team, GameSlot slot, int weekIndex) { this.targetTeam = team; this.targetSlot = slot; this.targetWeekIndex = weekIndex; }
/* A D D G A M E */ /*---------------------------------------------------------------------------- %%Function: AddGame %%Qualified: ArbWeb.CountsData:GameData:Games.AddGame %%Contact: rlittle Add a game This handles ensuring the the sport/level/pos information has been added to the legend, so we can build the detail lines later ----------------------------------------------------------------------------*/ private void AddGame(DateTime dttm, string sSite, string sName, string sTeam, string sEmail, string sGameNum, string sHome, string sAway, string sLevel, string sSport, string sPos, string sStatus, bool fCancelled, List<string> plsMisc) { GameSlot gm = new GameSlot(dttm, sSite, sName, sTeam, sEmail, sGameNum, sHome, sAway, sLevel, sSport, sPos, sStatus, fCancelled, plsMisc); AddGame(gm); #if old string sTeamSport = sTeam + "#-#" + sSport; m_plgmSorted.Add(String.Format("{0}_{1}_{2}", sName, dttm.ToString("yyyyMMdd:HH:mm"), m_plgmSorted.Count), gm); m_plgmSortedGameNum.Add(String.Format("{0}_{1}_{2}_{3}_{4}_{5}", dttm.ToString("yyyyMMdd:HH:mm"), sSite, sSport, sLevel, sGameNum, m_plgmSortedGameNum.Count), gm); if (sTeam != null && sTeam.Length > 0) { if (m_mpTeamCount.ContainsKey(sTeam)) m_mpTeamCount[sTeam]++; else m_mpTeamCount.Add(sTeam, 1); if (m_mpTeamCount.ContainsKey(sTeamSport)) m_mpTeamCount[sTeamSport]++; else m_mpTeamCount.Add(sTeamSport, 1); EnsureSportLevelPos(sSport, sLevel, sPos); } #endif }