Exemple #1
0
 private void StartWrongTerrainDigAnim()
 {
     StartCoroutine(SmoothTransformation <Vector3> .GetStoppable(defaultEuler, digStartRotation, 0.0f, (v) => transform.localEulerAngles = v, (s, t, p) => s + (t - s) * p, () =>
     {
         StartCoroutine(SmoothTransformation <Vector3> .GetStoppable(defaultPosition, endAnimPosition, 0.05f,
                                                                     (v) => transform.localPosition = v,
                                                                     (s, t, p) => s + (t - s) * p,
                                                                     () =>
         {
             transform.localPosition = defaultPosition; transform.localEulerAngles = defaultEuler;
         }
                                                                     ));
     }));
 }
Exemple #2
0
 protected override void ReachedDestination()
 {
     canEnterBoat = false;
     StartCoroutine(
         SmoothTransformation <Vector3> .GetStoppable(transform.position, leaveBoatPos.v, 0.8f
                                                      , (v) => transform.position = v,
                                                      (s, t, p) =>
     {
         Vector3 newPos = s + (t - s) * p;
         newPos.y      += Mathf.Sin(p * Mathf.PI) * jumpHeight;
         return(newPos);
     }
                                                      , delegate { GetComponent <DialogTrigger>().enabled = true; }));
 }
Exemple #3
0
    public void JumpInWater()
    {
        StartCoroutine(
            SmoothTransformation <Vector3> .GetStoppable(transform.position, target.v, 0.8f
                                                         , (v) => transform.position = v,
                                                         (s, t, p) =>
        {
            Vector3 newPos = s + (t - s) * p;
            newPos.y      += Mathf.Sin(p * Mathf.PI) * jumpHeight;
            return(newPos);
        }
                                                         , delegate { GetComponent <DialogTrigger>().enabled = true; }));
        Rigidbody r = gameObject.GetOrAddComponent <Rigidbody>();

        r.isKinematic = false;
        r.useGravity  = true;
    }
Exemple #4
0
    public static IEnumerator DisplayContainer(ItemContainer item, AudioClip sound, MonoBehaviour animatedBy, Vector3 spawnPosition)
    {
        int   displayCount         = 0;
        float delayTimeForEachItem = 0.2f;
        float displayCountDown     = 0;
        float itemFloatHeight      = 3.33f;
        float itemLifeTime         = 1.25f;

        while (displayCount < item.itemCount)
        {
            if (displayCountDown <= 0)
            {
                displayCountDown += delayTimeForEachItem;
                GameObject i          = Object.Instantiate(item.item.RuntimeRef.gameObject);
                Vector3    startScale = i.transform.localScale;
                PlayerGlobalSounds.PlayClip(sound);
                Object.Destroy(i.GetComponent <SaveablePrefabRoot>());
                foreach (ItemBehaviour b in i.GetComponents <ItemBehaviour>())
                {
                    b.enabled = false;
                }
                animatedBy.StartCoroutine(SmoothTransformation <Vector3> .GetStoppable(spawnPosition, spawnPosition + Vector3.up * itemFloatHeight, itemLifeTime,
                                                                                       p => { i.transform.localPosition = p; },
                                                                                       (s, e, p) =>
                {
                    i.transform.localScale = startScale * Mathf.Cos((p / 2) * Mathf.PI);
                    return(Vector3.Lerp(s, e, p));
                },
                                                                                       () => Object.Destroy(i)
                                                                                       ));
                displayCount++;
            }
            yield return(new WaitForFixedUpdate());

            displayCountDown -= Time.deltaTime;
        }
    }
 public static IEnumerator SmoothRotateEuler(Vector3 start, Vector3 toRotation, float finishedInTime, Action <Vector3> set, Action onFinish = null)
 {
     return(SmoothTransformation <Vector3> .GetStoppable(start, toRotation, finishedInTime, set, (s, t, p) => new Vector3(Mathf.Lerp(s.x, t.x, p), Mathf.Lerp(s.y, t.y, p), Mathf.Lerp(s.z, t.z, p)), onFinish));
 }