Пример #1
0
    public NearByInfo GetNearByInfo()
    {
        NearByInfo Info = new NearByInfo();

        Vector2Int Coordinate = ConnectedSlotInfo.Pos;

        if (Coordinate.x < ConnectedMap.Count - 1 && ConnectedMap[Coordinate.x + 1][Coordinate.y] != null && ConnectedMap[Coordinate.x + 1][Coordinate.y].InsideBubbleType != BubbleType.Null)
        {
            Info.RightBubble = ConnectedMap[Coordinate.x + 1][Coordinate.y].ConnectedBubble;
        }

        if (Coordinate.x > 0 && ConnectedMap[Coordinate.x - 1][Coordinate.y] != null && ConnectedMap[Coordinate.x - 1][Coordinate.y].InsideBubbleType != BubbleType.Null)
        {
            Info.LeftBubble = ConnectedMap[Coordinate.x - 1][Coordinate.y].ConnectedBubble;
        }

        if (Coordinate.y < ConnectedMap[Coordinate.x].Count - 1 && ConnectedMap[Coordinate.x][Coordinate.y + 1] != null && ConnectedMap[Coordinate.x][Coordinate.y + 1].InsideBubbleType != BubbleType.Null)
        {
            Info.TopBubble = ConnectedMap[Coordinate.x][Coordinate.y + 1].ConnectedBubble;
        }

        if (Coordinate.y > 0 && ConnectedMap[Coordinate.x][Coordinate.y - 1] != null && ConnectedMap[Coordinate.x][Coordinate.y - 1].InsideBubbleType != BubbleType.Null)
        {
            Info.DownBubble = ConnectedMap[Coordinate.x][Coordinate.y - 1].ConnectedBubble;
        }

        return(Info);
    }
Пример #2
0
    private void ResetNearByBubble(NearByInfo PreviousNearByInfo)
    {
        if (PreviousNearByInfo != null) //Reset previous near by bubbles
        {
            if (PreviousNearByInfo.RightBubble != null)
            {
                PreviousNearByInfo.RightBubble.GetComponent <NormalBubble>().IntendMoveDir = Direction.Null;
            }

            if (PreviousNearByInfo.LeftBubble != null)
            {
                PreviousNearByInfo.LeftBubble.GetComponent <NormalBubble>().IntendMoveDir = Direction.Null;
            }

            if (PreviousNearByInfo.TopBubble != null)
            {
                PreviousNearByInfo.TopBubble.GetComponent <NormalBubble>().IntendMoveDir = Direction.Null;
            }

            if (PreviousNearByInfo.DownBubble != null)
            {
                PreviousNearByInfo.DownBubble.GetComponent <NormalBubble>().IntendMoveDir = Direction.Null;
            }
        }
    }
Пример #3
0
    private void CheckSelected()
    {
        bool PressDown = Input.touchCount > 0 && SystemInfo.deviceType == DeviceType.Handheld || Input.GetMouseButtonDown(0) && SystemInfo.deviceType == DeviceType.Desktop;
        bool Release   = Input.touchCount == 0 && SystemInfo.deviceType == DeviceType.Handheld || Input.GetMouseButtonUp(0) && SystemInfo.deviceType == DeviceType.Desktop;

        if (!Selected && GameManager.cursorState == CursorState.Release && PressDown && CursorInside())
        {
            GameManager.HeldBubbleType = Type;
            GameManager.cursorState    = CursorState.Holding;

            Selected = true;
            ActivatedEffect.GetComponent <ParticleSystem>().Play();
        }

        if (Selected && Release)
        {
            GameManager.cursorState = CursorState.Release;

            Selected = false;

            if (SelectedSlot != null)
            {
                ResetNearByBubble(CurrentNearByInfo);
                CurrentNearByInfo = null;

                ResetOffsetInfo();
                SelectedSlot.GetComponent <SlotObject>().Selected = false;
                EventManager.instance.Fire(new Place(gameObject, SelectedSlot.GetComponent <SlotObject>().ConnectedSlotInfo.Pos, GameManager.HeldBubbleType));
                transform.position    = OriPos;
                transform.localScale  = Vector3.one * DefaultSize;
                CurrentOffset         = 0;
                CurrentSize           = DefaultSize;
                ColorRecoverTimeCount = ColorRecoverTime;
                GetComponent <SpriteRenderer>().color = Utility.ColorWithAlpha(GetComponent <SpriteRenderer>().color, 0);

                GameManager.HeldBubbleType = BubbleType.Null;

                ActivatedEffect.GetComponent <ParticleSystem>().Stop();

                gameObject.SetActive(false);
            }
            else
            {
                GameObject Temp = GameObject.Instantiate(TempActivatedEffectPrefab, transform.position, Quaternion.Euler(0, 0, 0));
                Temp.GetComponent <ParticleSystem>().Stop();

                transform.position   = OriPos;
                transform.localScale = Vector3.one * DefaultSize;
                CurrentSize          = DefaultSize;
                CurrentOffset        = 0;
                GetComponent <SpriteRenderer>().color = new Color(color.r, color.g, color.b, 0);
                ColorRecoverTimeCount = 0;

                ActivatedEffect.GetComponent <ParticleSystem>().Stop();
                ActivatedEffect.GetComponent <ParticleSystem>().Clear();
            }
        }
    }
Пример #4
0
    private void CheckSlotSelection()
    {
        if (GameManager.gameState == GameState.Level)
        {
            if (Selected)//Hold
            {
                foreach (Transform child in AllSlot.transform)
                {
                    if (child.GetComponent <SlotObject>().Inside(transform.position))
                    {
                        NearByInfo PreviousNearByInfo = CurrentNearByInfo;

                        CurrentNearByInfo = child.GetComponent <SlotObject>().GetNearByInfo();
                        if (CurrentNearByInfo.Available())
                        {
                            if (child.gameObject != SelectedSlot) //Select a new available slot
                            {
                                if (GameManager.CurrentConfig.Vibration)
                                {
                                    Taptic.Light();
                                }

                                ResetNearByBubble(PreviousNearByInfo);

                                if (SelectedSlot != null)
                                {
                                    SelectedSlot.GetComponent <SlotObject>().Selected = false;
                                    ResetOffsetInfo();
                                }
                                child.GetComponent <SlotObject>().Selected = true;
                                SelectedSlot = child.gameObject;


                                if (SelectedSlot.GetComponent <SlotObject>().Type != SlotType.Teleport || !GameManager.ActivatedLevel.GetComponent <LevelManager>().TeleportAvailable(SelectedSlot.GetComponent <SlotObject>().ConnectedSlotInfo))
                                {
                                    ActivatedEffect.GetComponent <ParticleSystem>().Stop();
                                    if (CurrentNearByInfo.RightBubble)
                                    {
                                        CurrentNearByInfo.RightBubble.GetComponent <NormalBubble>().IntendMoveDir = Direction.Right;
                                        ReleaseEffect.transform.Find("Right").GetComponent <ParticleSystem>().Play();
                                    }
                                    else
                                    {
                                        ReleaseEffect.transform.Find("Right").GetComponent <ParticleSystem>().Stop();
                                    }
                                    if (CurrentNearByInfo.LeftBubble)
                                    {
                                        CurrentNearByInfo.LeftBubble.GetComponent <NormalBubble>().IntendMoveDir = Direction.Left;
                                        ReleaseEffect.transform.Find("Left").GetComponent <ParticleSystem>().Play();
                                    }
                                    else
                                    {
                                        ReleaseEffect.transform.Find("Left").GetComponent <ParticleSystem>().Stop();
                                    }
                                    if (CurrentNearByInfo.TopBubble)
                                    {
                                        CurrentNearByInfo.TopBubble.GetComponent <NormalBubble>().IntendMoveDir = Direction.Up;
                                        ReleaseEffect.transform.Find("Up").GetComponent <ParticleSystem>().Play();
                                    }
                                    else
                                    {
                                        ReleaseEffect.transform.Find("Up").GetComponent <ParticleSystem>().Stop();
                                    }
                                    if (CurrentNearByInfo.DownBubble)
                                    {
                                        CurrentNearByInfo.DownBubble.GetComponent <NormalBubble>().IntendMoveDir = Direction.Down;
                                        ReleaseEffect.transform.Find("Down").GetComponent <ParticleSystem>().Play();
                                    }
                                    else
                                    {
                                        ReleaseEffect.transform.Find("Down").GetComponent <ParticleSystem>().Stop();
                                    }
                                }
                                else
                                {
                                    ResetNearByBubble(CurrentNearByInfo);
                                }
                            }
                            return;
                        }
                    }
                }
                if (SelectedSlot != null) // Not in available slot
                {
                    SelectedSlot.GetComponent <SlotObject>().Selected = false;
                    SelectedSlot = null;
                    ResetOffsetInfo();

                    ActivatedEffect.GetComponent <ParticleSystem>().Play();
                    foreach (Transform Effect in ReleaseEffect.transform)
                    {
                        Effect.GetComponent <ParticleSystem>().Stop();
                    }

                    ResetNearByBubble(CurrentNearByInfo);
                    CurrentNearByInfo = null;
                }
            }
            else
            {
                if (SelectedSlot != null)//Release
                {
                    SelectedSlot.GetComponent <SlotObject>().Selected = false;
                    SelectedSlot = null;
                    ResetOffsetInfo();

                    foreach (Transform Effect in ReleaseEffect.transform)
                    {
                        Effect.GetComponent <ParticleSystem>().Stop();
                    }

                    ResetNearByBubble(CurrentNearByInfo);
                    CurrentNearByInfo = null;
                }
            }
        }
    }