Beispiel #1
0
 public void TryMatch(TouchD t)
 {
     try
     {
         if (t.creature.Anim.runtimeAnimatorController.name == Customers[0].Want.Anim.runtimeAnimatorController.name && t.creature.Rend.material.name == Customers[0].Want.Rend.material.name)
         {
             Customers[0].Leave(true);
             t.creature.Leave();
             TestSpawner.instance.SpawnType(spawnable.creature);
         }
         else
         {
             t.creature.Drop(t);
             Customers[0].PatienceTimer *= falsePetMultiply;
             Customers[0].PatienceTimer += falsePetSubtract;
             if (MistakeEffectPrfab != null)
             {
                 Instantiate(MistakeEffectPrfab, Customers[0].distform.position, MistakeEffectPrfab.transform.localRotation);
                 AudioManager.instance.PlayAnimalGiveSound(false);
             }
         }
         InputController.instance.AbortTouch(t);
     }
     catch { Debug.Log("ERROR ! customermanager trymatch! " + Customers[0].CheckWantError(true)); }
 }
Beispiel #2
0
 public void Drop(TouchD t)
 {
     anim.SetBool(_anmDrag, false);
     GetComponent <CreatureBehaviour>().enabled = true;
     GetComponent <CreatureBehaviour>().AddHiddenForce(t);
     AudioManager.instance.PlayBlobSound();
 }
Beispiel #3
0
 public void CheckDistance(TouchD t, Transform trans)
 {
     if (Vector2.Distance(trans.position, Customers[0].distform.position) <= customerToCreatureDistance)
     {
         TryMatch(t);
     }
 }
    public float GrabMove(TouchD t)
    {
        /*  float half = Screen.width / 2f;
         * float temp = (touches[0].curPoint.x - touches[0].startPoint.x);
         * if(temp > half) { temp = half; }
         * temp /= half;*/
        float half = Screen.width / 2f;

        float temp = (touches[0].curPoint.x - touches[0].startPoint.x);

        if (temp < 0)
        {
            temp /= touches[0].startPoint.x;
        }
        else if (temp > 0)
        {
            temp /= (Screen.width - touches[0].startPoint.x);
        }
        else
        {
            temp = 0;
        }

        return(temp * grabMoveMultiplier);
    }
Beispiel #5
0
 public void AddHiddenForce(TouchD t)
 {
     hiddenForce = new Vector2(-((t.startPoint.x - t.curPoint.x) / Screen.width) / t.duration, -((t.startPoint.y - t.curPoint.y) / Screen.width) / t.duration);
     if (hiddenForce.y == 0)
     {
         hiddenForce.y = -1;
     }
 }
Beispiel #6
0
    public void Move(TouchD t)
    {
        anim.SetBool(_anmDrag, true);
        Vector2 point = Camera.main.ScreenToWorldPoint(new Vector3(t.curPoint.x, t.curPoint.y, pivoty.position.z));

        transform.position = new Vector3(point.x, point.y, transform.position.z);
        CustomerManager.instance.CheckDistance(t, pivoty);
    }
Beispiel #7
0
    public void Grab(TouchD t)
    {
        anim.SetBool(_anmDrag, true);
        GetComponent <CreatureBehaviour>().enabled = false;
        Vector2 point = Camera.main.ScreenToWorldPoint(new Vector3(t.curPoint.x, t.curPoint.y, pivoty.position.z));

        transform.position = new Vector3(point.x, point.y, transform.position.z);
        AudioManager.instance.PlayBlobSound();
        AudioManager.instance.PlayCreatureSound(anim.runtimeAnimatorController.name);
    }
 public void EndTouch(TouchD t)
 {
     if (t.creature == null)
     {
         // if (Mathf.Abs(t.startPoint.x - t.curPoint.x) / Screen.width <= Screen.width / 7f) { return; }
         extraVelocity    = ((t.startPoint.x - t.curPoint.x) / Screen.width) / t.duration;
         extraVelocityDir = extraVelocity / Mathf.Abs(extraVelocity);
         extraVelocity    = Mathf.Abs(extraVelocity);
     }
     else
     {
         t.creature.Drop(t);
     }
 }
    private void UpdateInput()
    {
        velocity = 0f;


        foreach (Touch t in Input.touches)
        {
            switch (t.phase)
            {
            case TouchPhase.Began:
                if (TouchEffectPrfab != null)
                {
                    Instantiate(TouchEffectPrfab, Camera.main.ScreenToWorldPoint(new Vector3(t.position.x, t.position.y, 10)), TouchEffectPrfab.transform.localRotation);
                }
                TouchD newTouch = new TouchD();
                newTouch.fingerId   = t.fingerId;
                newTouch.startPoint = t.position;
                newTouch.prevPoint  = t.position;
                newTouch.curPoint   = t.position;
                newTouch.duration   = 0;
                newTouch.creature   = TryRay(t.position);
                if (newTouch.creature == null)
                {
                    extraVelocity = 0;
                }
                else
                {
                    newTouch.creature.Grab(newTouch);
                }
                touches.Add(newTouch);
                break;

            case TouchPhase.Stationary:
            case TouchPhase.Moved:
                for (int i = 0; i < touches.Count; i++)
                {
                    if (touches[i].fingerId == t.fingerId)
                    {
                        touches[i].prevPoint = touches[i].curPoint;
                        touches[i].curPoint  = t.position;
                        touches[i].duration += Time.deltaTime;
                        if (touches[i].creature == null)
                        {
                            velocity = ((touches[i].prevPoint.x - touches[i].curPoint.x) / ((float)Screen.width / 3)) * TurningMultiplier;
                            TurnCamera(velocity);
                        }
                        else
                        {
                            velocity = GrabMove(touches[i]);
                            touches[i].creature.Move(touches[i]);
                        }
                        break;
                    }
                }
                break;

            case TouchPhase.Canceled:
            case TouchPhase.Ended:
                for (int i = touches.Count - 1; i >= 0; i--)
                {
                    if (touches[i].fingerId == t.fingerId)
                    {
                        touches[i].prevPoint = touches[i].curPoint;
                        touches[i].curPoint  = t.position;
                        touches[i].duration += Time.deltaTime;
                        EndTouch(touches[0]);
                        touches.RemoveAt(i);
                        break;
                    }
                }
                break;
            }
        }

        if (!isMobile && (touches.Count == 0 || touches[0].fingerId == -1))
        {
            if (Input.GetMouseButtonDown(0))
            {
                if (TouchEffectPrfab != null)
                {
                    Instantiate(TouchEffectPrfab, Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 10)), TouchEffectPrfab.transform.localRotation);
                }
                TouchD newTouch = new TouchD();
                newTouch.fingerId   = -1;
                newTouch.startPoint = Input.mousePosition;
                newTouch.prevPoint  = Input.mousePosition;
                newTouch.curPoint   = Input.mousePosition;
                newTouch.duration   = 0;
                newTouch.creature   = TryRay(Input.mousePosition);
                if (newTouch.creature == null)
                {
                    extraVelocity = 0;
                }
                else
                {
                    newTouch.creature.Grab(newTouch);
                }
                touches.Add(newTouch);
            }
            if (Input.GetMouseButton(0) && touches.Count > 0)
            {
                touches[0].prevPoint = touches[0].curPoint;
                touches[0].curPoint  = Input.mousePosition;
                touches[0].duration += Time.deltaTime;
                if (touches[0].creature == null)
                {
                    velocity = ((touches[0].prevPoint.x - touches[0].curPoint.x) / ((float)Screen.width / 3)) * TurningMultiplier;
                }
                else
                {
                    velocity = GrabMove(touches[0]);
                    touches[0].creature.Move(touches[0]);
                }
            }
            if (Input.GetMouseButtonUp(0) && touches.Count > 0)
            {
                touches[0].prevPoint = touches[0].curPoint;
                touches[0].curPoint  = Input.mousePosition;
                touches[0].duration += Time.deltaTime;

                EndTouch(touches[0]);

                touches.RemoveAt(0);
            }
        }
        TurnCamera(velocity);
    }
 public void AbortTouch(TouchD t)
 {
     touches.Remove(t);
 }