private IEnumerator SwapButtons(ObjectControl buttons, bool state)
    {
        yield return(new WaitForEndOfFrame());

        buttons.onButton.SetActive(!state);
        buttons.offButton.SetActive(state);
    }
    private void Awake()
    {
        Vector3 up = Vector3.up;

        Instance = this;
        forward1 = Vector3.zero;
    }
    // Start is called before the first frame update
    void Start()
    {
        _pivotPoint = GameObject.Find("PivotPoint");
        _control    = _pivotPoint.GetComponent <CameraControl>();

        _objectControl = GetComponent <ObjectControl>();
    }
示例#4
0
        public void GetAll()
        {
            ObjectControl[] newSpawned = new ObjectControl[this.transform.childCount];
            int             index      = 0;

            foreach (Transform child in this.transform)
            {
                if (newSpawned[index] == null)
                {
                    newSpawned[index++] = new ObjectControl(child.gameObject);
                    continue;
                }
                bool found = false;
                for (int i = 0; i < spawned.Length; i++)
                {
                    if (spawned[i].gameObject == child.gameObject)
                    {
                        newSpawned[index++] = spawned[i];
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    newSpawned[index++] = new ObjectControl(child.gameObject);
                }
            }
            spawned = newSpawned;
        }
示例#5
0
        private void InstantiateSingle()
        {
            if (objects.Length == 0)
            {
                return;
            }
            int index = 0;

            if (_iteration == Iteration.Ordered)
            {
                index = spawned.Length - Mathf.FloorToInt(spawned.Length / objects.Length) * objects.Length;
            }
            else
            {
                index = Random.Range(0, objects.Length);
            }
            if (objects[index] == null)
            {
                return;
            }

            ObjectControl[] newSpawned = new ObjectControl[spawned.Length + 1];
            spawned.CopyTo(newSpawned, 0);

            newSpawned[newSpawned.Length - 1] = new ObjectControl((GameObject)Instantiate(objects[index], this.transform.position, this.transform.rotation));
            newSpawned[newSpawned.Length - 1].transform.parent = this.transform;
            spawned = newSpawned;
        }
示例#6
0
    //time 시간동안 손패 내의 카드를 일정한 속도로 targetPos까지 이동시킨다.
    private void SortCard(float time, int index)
    {
        Vector3 start = cardList[index].transform.localPosition;

        cardList[index].targetPos = Curve.BezierCurve(cardList[index].handCurveRate, handP0.localPosition, handP1.localPosition, handP2.localPosition, handP3.localPosition);
        StartCoroutine(ObjectControl.MoveObjC(time, start, cardList[index].targetPos, cardList[index].gameObject));
    }
示例#7
0
    //Update grid based on movement
    public void UpdateGrid(ObjectControl tetromino)
    {
        for (int y = 0; y < gridCols; ++y)
        {
            for (int x = 0; x < gridRows; ++x)
            {
                if (grid[x, y] != null)
                {
                    if (grid[x, y].parent == tetromino.transform)
                    {
                        grid[x, y] = null;
                    }
                }
            }
        }

        foreach (Transform mino in tetromino.transform)
        {
            Vector3 pos       = RoundVectorToGridSpacing(mino.transform.position);
            int     posXIndex = (int)Mathf.Round(pos.x / gridSize);
            int     posYIndex = (int)Mathf.Round(pos.y / gridSize);

            if ((posYIndex < gridCols) && (posXIndex >= 0) && (posXIndex < gridRows))
            {
                grid[posXIndex, posYIndex] = mino;
            }
        }
    }
示例#8
0
    public static void Destroy(IControl control)
    {
        ObjectControl objControl = control as ObjectControl;

        objControl.Dispose();
        GameObject.Destroy(objControl.GameObject);
        list.Remove(objControl);
    }
示例#9
0
 public void CallFunctionWhenStar()
 {
     ResetCanvas();
     FadeText();
     obj      = GameObject.FindObjectOfType(typeof(ObjectControl)) as ObjectControl;
     listUser = LoadAllInfo.playerDictionary;
     //players = ObjectControl.playerList;
     //digimons = ObjectControl.digiList;
 }
示例#10
0
    //time 시간동안 card를 베지어 곡선을 따라 이동시킨다.
    //카드의 trail효과를 활성화시키고, 이동이 종료되면 card.init을 discardPile에 추가하며 객체를 Destroy한다.
    private IEnumerator DropCardC(float time, Card card, Vector3 start, Vector3 p1, Vector3 p2, Vector3 end)
    {
        card.isDraggable = false;
        StartCoroutine(card.SetActiveOfTrailC(0f, true));
        yield return(StartCoroutine(ObjectControl.CurveMoveObjC(time, start, p1, p2, end, card.gameObject)));

        discardPile.AddToPile(card.init);
        Destroy(card.gameObject, 0.5f);
    }
示例#11
0
 //마우스를 치웠을때 카드 회전, 축소
 void OnMouseExit()
 {
     if (!isOnDropZone && card.isDraggable && !mousePointFollow && HandingManager.Instance.endDraw && !HandingManager.Instance.dragCard && !avoidOverlap)
     {
         transform.SetSiblingIndex(GetComponent <Card>().order);
         ChangeTransform(ObjectControl.RotationAngle(gameObject, card.angle), HandingManager.Instance.cardMaxSize, card.targetPos);
         HandingManager.Instance.RollBackGapCards(card.order);
     }
     mouseOver = false;
 }
示例#12
0
 //cardList의 모든 카드를 각각의 targetPos로 이동시키고 angle만큼 회전시킨다.
 public void SortAllCard()
 {
     for (int i = 0; i < cardList.Count; i++)
     {
         SetAngleToCard(i);
         SetCurveRate(i);
         SortCard(0.3f, i);
         StartCoroutine(ObjectControl.RotationToC(0.1f, new Vector3(0f, 0f, ObjectControl.RotationAngle(cardList[i].gameObject, cardList[i].angle)), cardList[i].gameObject));
     }
 }
示例#13
0
 //마우스를 올렸을때 카드 회전, 확대
 void OnMouseOver()
 {
     if (!isOnDropZone && card.isDraggable && !mousePointFollow && HandingManager.Instance.endDraw && !HandingManager.Instance.dragCard && !mouseOver && !avoidOverlap)
     {
         mouseOver = true;
         transform.SetAsLastSibling();
         ChangeTransform(ObjectControl.RotationAngle(gameObject, 0f), HandingManager.Instance.cardMaxSize + 0.5f, new Vector3(transform.localPosition.x, yPos2BeExtended, -1f));
         HandingManager.Instance.ExpandGapSelectedCard(card.order);
     }
 }
        private void Remove()
        {
#if UNITY_EDITOR
#if UNITY_2018_3_OR_NEWER
            if (PrefabUtility.GetPrefabAssetType(gameObject) != PrefabAssetType.NotAPrefab)
            {
                return;
            }
#else
            if (PrefabUtility.GetPrefabType(gameObject) == PrefabType.Prefab)
            {
                return;
            }
#endif
#endif
            if (_spawnCount >= spawned.Length)
            {
                return;
            }
            for (int i = spawned.Length - 1; i >= _spawnCount; i--)
            {
                if (i >= spawned.Length)
                {
                    break;
                }
                if (spawned[i] == null)
                {
                    continue;
                }
                spawned[i].transform.localScale = spawned[i].baseScale;
                if (_objectMethod == ObjectMethod.GetChildren)
                {
                    spawned[i].gameObject.SetActive(false);
                }
                else
                {
                    if (Application.isEditor)
                    {
                        spawned[i].DestroyImmediate();
                    }
                    else
                    {
                        spawned[i].Destroy();
                    }
                }
            }
            ObjectControl[] newSpawned = new ObjectControl[_spawnCount];
            for (int i = 0; i < newSpawned.Length; i++)
            {
                newSpawned[i] = spawned[i];
            }
            spawned = newSpawned;
            Rebuild(false);
        }
        /// <summary>
        /// Occurs when the main form is loading
        /// </summary>
        private void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
        {
            if (!(DataContext is MainWindowViewModel viewModel))
                return;

            viewModel.InitViewModel(DialogCoordinator.Instance);
            ObjectControl.InitControl();
            ReplayControl.InitControl();

            viewModel.SelectionChanged += ViewModel_SelectionChanged;
            viewModel.SearchStarted += ViewModel_SearchStarted;
        }
示例#16
0
    //time 시간동안 Card를 베지어 곡선에 따라 이동하여, 뽑을 카드 더미에 card.init 데이터를 전달한 후, card.GameObject를 Destroy한다.
    private IEnumerator ReloadCardC(float time, Card card)
    {
        float   h    = Random.Range(-2, 3) * 80;
        float   addH = 3 * 80;
        float   x    = discardPile.transform.localPosition.x + (deck.transform.localPosition.x - discardPile.transform.localPosition.x) / 5;
        Vector3 r1   = new Vector3(x, discardPile.transform.localPosition.y + addH + h, 0f);
        Vector3 r2   = new Vector3(x, discardPile.transform.localPosition.y + addH, 0f);

        StartCoroutine(ObjectControl.RotationToC(time, new Vector3(0f, 0f, ObjectControl.RotationAngle(card.gameObject, 120f)), card.gameObject));
        yield return(StartCoroutine(ObjectControl.CurveMoveObjC(time, discardPile.transform.localPosition, r1, r2, deck.transform.localPosition, card.gameObject)));

        deck.AddToPile(card.init);
        Destroy(card.gameObject, 0.5f);
    }
    private void Start()
    {
        control = PlayerController.instance.control;

        components = new List <ItemComponent>();
        childCount = control.brokenObjs.Count;

        silCount         = Mathf.CeilToInt((silChance * childCount));
        totalBrokenCount = silCount;

        //GenerateSilhouetteObjects();

        GameManager.instance.OnRotationCompleted = OnObjectRotated;
        //MoveToPlacements();
    }
示例#18
0
    //생성된 카드를 베지어 곡선에 따라 이동시킨다.
    private IEnumerator DrawCardC(float time, int index)
    {
        StartCoroutine(ObjectControl.RotationToC(0.3f, new Vector3(0f, 0f, -180f), cardList[index].gameObject));
        SetCurveRate(index);
        cardList[index].targetPos = Curve.BezierCurve(cardList[index].handCurveRate, handP0.localPosition, handP1.localPosition, handP2.localPosition, handP3.localPosition);

        StartCoroutine(ObjectControl.ChangeSizeC(0.3f, new Vector3(cardMaxSize, cardMaxSize, 0.0f), cardList[index].gameObject));
        yield return(StartCoroutine(ObjectControl.CurveMoveObjC(time, deck.transform.localPosition, drawP1.localPosition, drawP2.localPosition, cardList[index].targetPos, cardList[index].gameObject)));

        StartCoroutine(cardList[index].SetActiveOfTrailC(0.3f, false));

        //손패 정렬 실행.
        SortAllCard();
        endDrawCount++;
    }
示例#19
0
 public void StopMoving()
 {
     foreach (KeyValuePair <string, Stack <GameObject> > pair in buffer)
     {
         Stack <GameObject> objectBuffer = pair.Value;
         foreach (GameObject i in objectBuffer)
         {
             ObjectControl ic = i.GetComponent <ObjectControl>();
             if (ic)
             {
                 ic.DisableMovement();
             }
         }
     }
 }
示例#20
0
 private void InstantiateSingle()
 {
     if (objects.Length != 0)
     {
         int num = 0;
         num = ((_iteration != 0) ? UnityEngine.Random.Range(0, objects.Length) : (spawned.Length - Mathf.FloorToInt(spawned.Length / objects.Length) * objects.Length));
         if (!(objects[num] == null))
         {
             ObjectControl[] array = new ObjectControl[spawned.Length + 1];
             spawned.CopyTo(array, 0);
             array[array.Length - 1] = new ObjectControl(UnityEngine.Object.Instantiate(objects[num], base.transform.position, base.transform.rotation));
             array[array.Length - 1].transform.parent = base.transform;
             spawned = array;
         }
     }
 }
示例#21
0
 //Check if tetromoni is above grid
 public bool CheckIsAboveGrid(ObjectControl tetromino)
 {
     //Debug.Log("Checking if above grid");
     for (int x = 0; x < gridRows; ++x)
     {
         foreach (Transform mino in tetromino.transform)
         {
             Vector3 pos = RoundVectorToGridSpacing(mino.transform.position);
             if (pos.y >= gridHeight)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
示例#22
0
    //손패의 모든 카드를 버리고 리스트를 비운 다음 드로우 루틴을 실행.
    private IEnumerator DropAllCardC()
    {
        float time = 0.7f;

        foreach (Card card in cardList)
        {
            StartCoroutine(ObjectControl.ChangeSizeC(time, new Vector3(cardMinSize, cardMinSize, 0f), card.gameObject));
            StartCoroutine(ObjectControl.RotationToC(time, new Vector3(0f, 0f, ObjectControl.RotationAngle(card.gameObject, -180f)), card.gameObject));
            StartCoroutine(DropCardC(time, card, card.transform.localPosition, dropP1.localPosition, dropP2.localPosition, discardPile.transform.localPosition));
        }
        if (cardList.Count > 0)
        {
            yield return(new WaitForSeconds(time + 0.5f));
        }
        cardList.Clear();
        StartCoroutine(DrawRoutineC());
    }
示例#23
0
 public void OnEndDrag(PointerEventData eventData)
 {
     if (HandingManager.Instance.endDraw && mousePointFollow)
     {
         mousePointFollow = false;
         transform.SetParent(handTf);
         transform.SetSiblingIndex(card.order);//히에라키에서 순서 변경.
         if (!isOnDropZone)
         {
             ChangeTransform(ObjectControl.RotationAngle(gameObject, card.angle), HandingManager.Instance.cardMaxSize, card.targetPos);
             HandingManager.Instance.RollBackGapCards(card.order);
             StartCoroutine(Timer(0.1f));
         }
         GetComponent <CanvasGroup>().blocksRaycasts = true;
         HandingManager.Instance.dragCard            = false;
     }
 }
        /// <summary>
        /// Occurs when the user selects another tab
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (!(DataContext is MainWindowViewModel viewModel))
                return;

            if (viewModel.SelectedTrack == null)
                return;

            if (TabControl.SelectedIndex == 2) // Replay tab
            {
                ReplayControl.LoadData(viewModel.SelectedTrack.TrackId);
            }
            else if (TabControl.SelectedIndex == 3) // Object tab
            {
                ObjectControl.LoadData(viewModel.SelectedTrack.TrackId);
            }
            
        }
示例#25
0
    // Mouse click selection
    // Copied from: http://answers.unity3d.com/questions/411793/selecting-a-game-object-with-a-mouse-click-on-it.html
    void LMBSelect()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Debug.Log("Mouse is down");

            RaycastHit hitInfo = new RaycastHit();
            bool       hit     = Physics.Raycast(MainCamera.ScreenPointToRay(Input.mousePosition), out hitInfo);
            if (hit)
            {
                ObjectControl.SetSelectedObject(hitInfo.transform.gameObject);
            }
            else
            {
                Debug.Log("No hit");
            }
        }
    }
示例#26
0
        public void GetAll()
        {
            ObjectControl[] array      = new ObjectControl[base.transform.childCount];
            int             num        = 0;
            IEnumerator     enumerator = base.transform.GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    Transform transform = (Transform)enumerator.Current;
                    if (array[num] == null)
                    {
                        array[num++] = new ObjectControl(transform.gameObject);
                    }
                    else
                    {
                        bool flag = false;
                        for (int i = 0; i < spawned.Length; i++)
                        {
                            if (spawned[i].gameObject == transform.gameObject)
                            {
                                array[num++] = spawned[i];
                                flag         = true;
                                break;
                            }
                        }
                        if (!flag)
                        {
                            array[num++] = new ObjectControl(transform.gameObject);
                        }
                    }
                }
            }
            finally
            {
                IDisposable disposable;
                if ((disposable = (enumerator as IDisposable)) != null)
                {
                    disposable.Dispose();
                }
            }
            spawned = array;
        }
示例#27
0
        private void InstantiateSingle()
        {
            if (objects.Length == 0)
            {
                return;
            }
            int index = 0;

            if (_iteration == Iteration.Ordered)
            {
                index = spawned.Length - Mathf.FloorToInt(spawned.Length / objects.Length) * objects.Length;
            }
            else
            {
                index = Random.Range(0, objects.Length);
            }
            if (objects[index] == null)
            {
                return;
            }

            ObjectControl[] newSpawned = new ObjectControl[spawned.Length + 1];
            spawned.CopyTo(newSpawned, 0);
#if UNITY_EDITOR
            if (!Application.isPlaying && retainPrefabInstancesInEditor)
            {
                GameObject go = (GameObject)UnityEditor.PrefabUtility.InstantiatePrefab(objects[index]);
                go.transform.position             = transform.position;
                go.transform.rotation             = transform.rotation;
                newSpawned[newSpawned.Length - 1] = new ObjectControl(go);
            }
            else
            {
                newSpawned[newSpawned.Length - 1] = new ObjectControl((GameObject)Instantiate(objects[index], transform.position, transform.rotation));
            }
#else
            newSpawned[newSpawned.Length - 1] = new ObjectControl((GameObject)Instantiate(objects[index], transform.position, transform.rotation));
#endif
            newSpawned[newSpawned.Length - 1].transform.parent = transform;
            spawned = newSpawned;
        }
示例#28
0
    /// <summary>
    /// time 시간동안 cardList의 index에 해당하는 카드를 현재 위치에서 discardPile의 위치로 베지어 곡선을 따라 이동시킨다.
    /// </summary>
    public void DropCard(float time, int index)
    {
        Card card = cardList[index];

        cardList.RemoveAt(index);

        for (int i = card.order; i < cardList.Count; i++)
        {
            cardList[i].order--;
        }

        float y = 100f;
        float x = (discardPile.transform.localPosition.x - card.transform.localPosition.x) / 3;

        Vector3 p1 = new Vector3(card.transform.localPosition.x + x, card.transform.localPosition.y + y, 0f);
        Vector3 p2 = new Vector3(card.transform.localPosition.x + x * 2, card.transform.localPosition.y + y, 0f);

        StartCoroutine(ObjectControl.ChangeSizeC(time, new Vector3(cardMinSize, cardMinSize, 0f), card.gameObject));
        StartCoroutine(ObjectControl.RotationToC(time, new Vector3(0f, 0f, ObjectControl.RotationAngle(card.gameObject, -180f)), card.gameObject));
        StartCoroutine(DropCardC(time, card, card.transform.localPosition, p1, p2, discardPile.transform.localPosition));
    }
        /// <summary>
        /// Occurs when the user selects another track
        /// </summary>
        private void ViewModel_SelectionChanged()
        {
            if (!(DataContext is MainWindowViewModel viewModel))
                return;

            if (viewModel.SelectedTrack == null)
                return;

            if (TabControl.SelectedIndex == 2)
            {
                if (viewModel.SelectedTrack.ReplayCount == 0)
                    TabControl.SelectedIndex = 0;
                else
                    ReplayControl.LoadData(viewModel.SelectedTrack.TrackId);
            }
            else if (TabControl.SelectedIndex == 3)
            {
                if (viewModel.SelectedTrack.EmbeddedObjectsCount == 0)
                    TabControl.SelectedIndex = 0;
                else
                    ObjectControl.LoadData(viewModel.SelectedTrack.TrackId);
            }
        }
示例#30
0
        private void Remove()
        {
            if (_spawnCount >= spawned.Length)
            {
                return;
            }
            int num = spawned.Length - 1;

            while (num >= _spawnCount && num < spawned.Length)
            {
                if (spawned[num] != null)
                {
                    spawned[num].transform.localScale = spawned[num].baseScale;
                    if (_objectMethod == ObjectMethod.GetChildren)
                    {
                        spawned[num].gameObject.SetActive(value: false);
                    }
                    else if (Application.isEditor)
                    {
                        spawned[num].DestroyImmediate();
                    }
                    else
                    {
                        spawned[num].Destroy();
                    }
                }
                num--;
            }
            ObjectControl[] array = new ObjectControl[_spawnCount];
            for (int i = 0; i < array.Length; i++)
            {
                array[i] = spawned[i];
            }
            spawned = array;
            Rebuild(sampleComputer: false);
        }