private void EndDrag(UICharacter uiCharacter)
    {
        if (TransformService.ContainPos(uiCharacterArea.transform as RectTransform, uiCharacter.transform.position))
        {
            isMovetoBattleArea = true;
        }
        else if (TransformService.ContainPos(uiPrepareArea.transform as RectTransform, uiCharacter.transform.position))
        {
            isMovetoBattleArea = false;
        }

        uiInGameCharacterInfo.OnHide();
        uiSellArea.OnHide();

        if (isSelling)
        {
            selledCharacterInfo = uiCharacter.DeleteCharacterBySell();
            uiSellArea.gameObject.GetComponent <Image>().color = Color.white;
        }

        //if(!IsNotChanged())
        //{
        //    if (IsPlaceableSpaceFull())
        //    {
        //        if (IsMoveFromPrepareAreaToEmptyBattleArea())
        //        {
        //            SwapCharacters(invisibleCharacter, swappedCharacter);
        //            SwapCharacters(invisibleCharacter, uiCharacter);
        //            isSwapped = false;
        //            return;
        //        }
        //    }
        //}

        //UpdateCurrentPlacedCharacters();
        //SwapCharacters(invisibleCharacter, uiCharacter);
        //UpdateSynergyService(uiCharacter);
        //SetCharacterImage(uiCharacter);


        if (IsPlaceableSpaceFull())
        {
            if (IsMoveFromPrepareAreaToEmptyBattleArea())
            {
                SwapCharacters(invisibleCharacter, swappedCharacter);
                SwapCharacters(invisibleCharacter, uiCharacter);
                isSwapped = false;

                Debug.Log("In!!");
                return;
            }
        }

        SwapCharacters(invisibleCharacter, uiCharacter);
        UpdateCurrentPlacedCharacters(uiCharacter);
        UpdateSynergyService(uiCharacter);
        SetCharacterImage(uiCharacter);

        isSwapped = false;
    }
 private void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         if (!TransformService.ContainPos(potionImage.transform as RectTransform, Input.mousePosition, cam))
         {
             if (uiPotionInfo.gameObject.activeSelf)
             {
                 uiPotionInfo.OnHide();
             }
         }
     }
 }
Exemple #3
0
    // 파라미터로 받은 캐릭터의 (드래그한)위치가 캐릭터리스트에 있는 캐릭터들 중 하나의 위치에 오면 그 위치에 있는 캐릭터를 반환
    public UICharacter GetCharacterByPosition(UICharacter draggedUICharacter)
    {
        UICharacter targetCharacter = null;

        for (int i = 0; i < uiCharacters.Count; ++i)
        {
            if (TransformService.ContainPos(uiCharacters[i].transform as RectTransform, draggedUICharacter.transform.position))
            {
                targetCharacter = uiCharacters[i];
                break;
            }
        }

        return(targetCharacter);
    }
    private void BeginDrag(UICharacter uiCharacter)
    {
        if (TransformService.ContainPos(uiCharacterArea.transform as RectTransform, uiCharacter.transform.position))
        {
            isMoveFromBattleArea = true;
        }
        else if (TransformService.ContainPos(uiPrepareArea.transform as RectTransform, uiCharacter.transform.position))
        {
            isMoveFromBattleArea = false;
        }

        parentWhenBeginDrag = uiCharacter.GetComponentInParent <UISlot>();
        SwapCharacters(invisibleCharacter, uiCharacter);
        uiCharacter.SetDefaultImage();
        originalSize = uiCharacter.character.GetSize();
        uiSellArea.UpdatePrice(uiCharacter.characterInfo);
        uiSellArea.OnShow();
    }
    // 캐릭터 이외의 곳을 클릭했을 때 캐릭터 정보를 꺼주는 Update문
    private void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            var characterAreaListWithCharacters = uiCharacterArea.GetUICharacterListWithCharacters();
            var prepareAreaListWithCharacters   = uiPrepareArea.GetUICharacterListWithCharacters();

            List <UICharacter> characterListWithCharacters = new List <UICharacter>();
            characterListWithCharacters.AddRange(characterAreaListWithCharacters);
            characterListWithCharacters.AddRange(prepareAreaListWithCharacters);

            var uiCharacter = characterListWithCharacters.Find(t => TransformService.ContainPos(t.transform as RectTransform, Input.mousePosition, cam));
            if (uiCharacter == null)
            {
                if (uiInGameCharacterInfo.gameObject.activeSelf)
                {
                    uiInGameCharacterInfo.OnHide();
                }
            }
        }
    }
    private void Drag(UICharacter uiCharacter)
    {
        Arranger whichArrangersCharacter;

        whichArrangersCharacter = arrangers.Find(t => TransformService.ContainPos(t.transform as RectTransform, uiCharacter.transform.position));

        if (whichArrangersCharacter != null)
        {
            UICharacter targetCharacter = whichArrangersCharacter.GetCharacterByPosition(uiCharacter);

            if (targetCharacter != null)
            {
                if (!isSwapped)
                {
                    // 첫 번째로 다른 자리로 드래그했으면
                    if (targetCharacter != invisibleCharacter)
                    {
                        SwapCharacters(invisibleCharacter, targetCharacter);
                        SetCharacterImage(targetCharacter);
                        swappedCharacter = targetCharacter;
                        isSwapped        = true;
                    }
                }
                else
                {
                    // 드래그하다가 원래 자리로
                    if (targetCharacter == swappedCharacter)
                    {
                        SwapCharacters(invisibleCharacter, targetCharacter);
                        SetCharacterImage(targetCharacter);
                        isSwapped = false;
                    }
                    // 다른 자리로 드래그 후 또 다른 자리로 갔을 경우
                    else if (targetCharacter != invisibleCharacter)
                    {
                        SwapCharacters(invisibleCharacter, swappedCharacter);
                        SetCharacterImage(swappedCharacter);
                        SwapCharacters(invisibleCharacter, targetCharacter);
                        SetCharacterImage(targetCharacter);
                        swappedCharacter = targetCharacter;
                    }
                }

                // 캐릭터 크기 조정
                if (TransformService.ContainPos(uiCharacterArea.transform as RectTransform, uiCharacter.transform.position))
                {
                    uiCharacter.character.SetSize(CharacterService.SIZE_IN_BATTLE_AREA);
                }
                else if (TransformService.ContainPos(uiPrepareArea.transform as RectTransform, uiCharacter.transform.position))
                {
                    uiCharacter.character.SetSize(CharacterService.SIZE_IN_PREPARE_AREA);
                }
            }
        }
        else
        {
            // 드래그 중에 CharacterArea 또는 PrepareArea 이외의 공간에 있는 경우
            if (isSwapped)
            {
                uiCharacter.character.SetSize(originalSize);
                SwapCharacters(swappedCharacter, invisibleCharacter);
                SetCharacterImage(swappedCharacter);
                isSwapped = false;
            }
        }

        // Sell에 드래그했을 때
        if (TransformService.ContainPos(uiSellArea.transform as RectTransform, uiCharacter.transform.position))
        {
            isSelling = true;
            uiSellArea.gameObject.GetComponent <Image>().color = Color.red;
        }
        else
        {
            isSelling = false;
            uiSellArea.gameObject.GetComponent <Image>().color = Color.white;
        }
    }