Пример #1
0
 void Update()
 {
     if (MPTKeepShapeAnimation.GetAnimationsCount() != 0)
     {
         return;
     }
     if (MPTInteractiveTutoManager.Instance.currentTuto != null)
     {
         return;
     }
     if (isDirty)
     {
         QuickSave();
         isDirty = false;
     }
 }
Пример #2
0
 public void SetNextShape(MPTShape shapeToKeep)
 {
     shapeToKeep.draggable.enabled = true;
     for (int spawnId = 0; spawnId < spawnedShapes.Length; ++spawnId)
     {
         if (spawnedShapes[spawnId] == null)
         {
             shapeToKeep.gameObject.transform.SetParent(spawnPoints[spawnId].transform);
             MPTKeepShapeAnimation anim = shapeToKeep.gameObject.AddComponent <MPTKeepShapeAnimation>();
             anim.animationTime  = 1.0f;
             anim.targetPosition = shapeToKeep.gameObject.transform.parent.position;
             anim.targetScale    = shapeToKeep.initialScale / 2.0f;
             //shapeToKeep.gameObject.transform.localPosition = new Vector3(0.0f, 0.0f, 0.0f);
             shapeToKeep.gameObject.GetComponent <MPTShape>().Init();
             shapeToKeep.draggable.additionalColliders.Clear();
             shapeToKeep.draggable.additionalColliders.Add(spawnPoints[spawnId].GetComponent <Collider2D>());
             shapeToKeep.draggable.initialPos = shapeToKeep.gameObject.transform.parent.position;
             spawnedShapes[spawnId]           = shapeToKeep.gameObject;
             return;
         }
     }
 }
Пример #3
0
    void Update()
    {
        if (MPTKeepShapeAnimation.GetAnimationsCount() != 0)
        {
            return;
        }
        if (MPTGameManager.Instance != null && MPTGameManager.Instance.isPaused)
        {
            if (currentlyDragged)
            {
                if (beenDropped != null)
                {
                    beenDropped();
                }
            }
            currentlyDragged = false;
            return;
        }
        Vector2 initPosition = new Vector2(float.MinValue, float.MinValue);
        Vector2 position     = initPosition;
        bool    justClicked  = false;

#if UNITY_EDITOR
        if (Input.GetMouseButtonDown(0))
        {
            justClicked = true;
            position    = Input.mousePosition;
        }
        else if (Input.GetMouseButton(0))
        {
            position = Input.mousePosition;
        }
#endif
        if (Input.touchCount == 1)
        {
            if (Input.touches[0].phase == TouchPhase.Began)
            {
                justClicked = true;
            }
            position = Input.touches[0].position;
        }

        if (position == initPosition)
        {
            if (currentlyDragged)
            {
                if (beenDropped != null)
                {
                    beenDropped();
                }
            }
            currentlyDragged = false;
            return;
        }

        position = MPTUtils.ScreenToWorld(position);

        if (coll.OverlapPoint(position))
        {
            if (justClicked)
            {
                currentlyDragged = true;
            }
        }

        foreach (Collider2D currColl in additionalColliders)
        {
            if (currColl.OverlapPoint(position))
            {
                if (justClicked)
                {
                    currentlyDragged = true;
                }
            }
        }

        if (MPTInteractiveTutoManager.Instance.BlockadeDragPiece(gameObject.GetComponent <MPTShape>()) == false)
        {
            currentlyDragged = false;
        }

        if (currentlyDragged)
        {
            transform.position = new Vector3(position.x, position.y + 2.0f, 0.0f);
        }

        if (currentlyDragged && beenDragged != null)
        {
            beenDragged();
        }
    }