コード例 #1
0
 private void Update()
 {
     if (GameManager.AllowPlayerActions)
     {
         if (!onCooldown && Input.GetButton("PrimaryAction"))
         {
             onCooldown = true;
             StartCoroutine(SmoothTransformation <Vector3> .SmoothRotateAngleEuler(startEuler, endEuler, animLength / 2, v => transform.localEulerAngles = v, () =>
             {
                 StartCoroutine(SmoothTransformation <Vector3> .SmoothRotateAngleEuler(endEuler, startEuler, animLength / 2,
                                                                                       v => transform.localEulerAngles = v,
                                                                                       () =>
                 {
                     onCooldown = false;
                     repaired   = false;
                 }
                                                                                       ));
             }));
         }
     }
     if (!repaired && onCooldown)
     {
         RaycastHit hit;
         if (Physics.Raycast(rayCastPosition.position, rayCastPosition.forward, out hit, 0.55f))
         {
             Boat boat = hit.collider.gameObject.GetComponentInParent <Boat>();
             if (boat != null && boat.Mass > boat.startMass && inventory.RemoveItem(wood))
             {
                 boat.Mass = Mathf.Max(boat.startMass, boat.Mass - repairPower);
                 repaired  = true;
             }
         }
     }
 }
コード例 #2
0
ファイル: Digging.cs プロジェクト: flofe104/SpackJerrow
 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;
         }
                                                                     ));
     }));
 }
コード例 #3
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; }));
 }
コード例 #4
0
ファイル: Digging.cs プロジェクト: flofe104/SpackJerrow
 private void StartDigAnim()
 {
     StartCoroutine(SmoothTransformation <Vector3> .SmoothRotateAngleEuler(defaultEuler, digStartRotation, 0.0f, (v) => transform.localEulerAngles = v, () =>
     {
         StartCoroutine(SmoothTransformation <Vector3> .SmoothRotateAngleEuler(defaultPosition, endAnimPosition, 0.4f,
                                                                               v => transform.localPosition = v,
                                                                               () =>
         {
             StartCoroutine(SmoothTransformation <Vector3> .SmoothRotateAngleEuler(digStartRotation, endAnimEuler, 0.25f,
                                                                                   v => transform.localEulerAngles = v,
                                                                                   () => { transform.localPosition = defaultPosition; transform.localEulerAngles = defaultEuler; }));
         }
                                                                               ));
     }));
 }
コード例 #5
0
    private void AnimateStatusTransition()
    {
        if (transitionAnimation != null)
        {
            StopCoroutine(transitionAnimation);
        }
        transitionAnimation = SmoothTransformation <Vector3> .
                              SmoothRotateAngleEuler(
            rotatedObject.localEulerAngles,
            NextEuler,
            transitionSpeed,
            v => rotatedObject.localEulerAngles = v
            );

        StartCoroutine(transitionAnimation);
    }
コード例 #6
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;
    }
コード例 #7
0
 public void PlayTranslationAnim(List <VectorAnimation> vs, int i)
 {
     if (vs.Count > i)
     {
         m.StartCoroutine(SmoothTransformation <Vector3> .SmoothRotateEuler(vs[i].start, vs[i].end, vs[i].time,
                                                                            (v) => animatedTarget.localPosition = v,
                                                                            () =>
         {
             PlayTranslationAnim(vs, i + 1);
         }));
     }
     else
     {
         pFinish = true;
         CheckIfDone();
     }
 }
コード例 #8
0
    public void StartSequencePart(MonoBehaviour behaviour, Transform target, Action onFinish)
    {
        b = behaviour;
        Action callBack = null;

        if (moveToInTime > rotateInTime)
        {
            callBack = onFinish;
        }

        e = SmoothVectorTransformation.GetStoppable
            (
            () => new Vector3[] { target.position },
            (v) => target.position = v,
            endHere.position,
            moveToInTime,
            callBack
            );
        behaviour.StartCoroutine(e);


        if (rotateInTime != 0)
        {
            if (moveToInTime <= rotateInTime)
            {
                callBack = onFinish;
            }
            else
            {
                callBack = null;
            }

            t =
                SmoothTransformation <Vector3> .SmoothRotateAngleEuler(
                    target.localEulerAngles,
                    objectRotation,
                    rotateInTime,
                    v => target.localEulerAngles = v,
                    callBack);


            behaviour.StartCoroutine(t);
        }
    }
コード例 #9
0
    private void PlayNextPart(int index)
    {
        currentIndex = index;
        if (currentIndex < animations.Count)
        {
            SceneAnimationPart currentPart = animations[currentIndex];
            currentRotateAnim = SmoothTransformation <Vector3> .SmoothRotateAngleEuler(t.localEulerAngles, currentPart.localEuler, currentPart.timeNeeded, v => t.localEulerAngles = v, () =>
                                                                                       PlayNextPart(currentIndex + 1));

            currentMoveAnim = SmoothTransformation <Vector3> .SmoothRotateAngleEuler(t.localPosition, currentPart.localPosition, currentPart.timeNeeded, v => t.localPosition = v);

            b.StartCoroutine(currentRotateAnim);
            b.StartCoroutine(currentMoveAnim);
        }
        else
        {
            onFinish?.Invoke();
            currentIndex = 0;
        }
    }
コード例 #10
0
ファイル: Events.cs プロジェクト: flofe104/SpackJerrow
    //private static void LookAt(CameraDirector director)
    //{
    //    director.AnimateCamera(GameManager.PlayerMainCamera.transform);
    //}

    public static void LookAtMainIsland()
    {
        Vector3 observationPosition = new Vector3(-134.2f, 45.1f, 78.3f);
        Vector3 observationEuler    = new Vector3(30.4f, -18.32f, 0);

        Transform     cam    = Camera.main.transform;
        Vector3       euler  = cam.localEulerAngles;
        Vector3       pos    = cam.localPosition;
        MonoBehaviour source = GameManager.GetPlayerComponent <MonoBehaviour>();

        source.StartCoroutine(SmoothTransformation <Vector3> .SmoothRotateAngleEuler(cam.eulerAngles, observationEuler, 2.5f, v => cam.eulerAngles = v));
        source.StartCoroutine(
            SmoothTransformation <Vector3> .SmoothRotateEuler(cam.position, observationPosition, 2.5f, v => cam.position = v, () =>
        {
            source.StartCoroutine(SmoothTransformation <Vector3> .SmoothRotateAngleEuler(observationPosition, observationPosition, 1.5f, v => { }, () =>
            {
                cam.localEulerAngles = euler;
                cam.localPosition    = pos;
            }));
        })
            );
    }
コード例 #11
0
ファイル: Events.cs プロジェクト: flofe104/SpackJerrow
    public static void EndGame()
    {
        GameObject          player = GameManager.Player;
        InterfaceController interfaceController = player.GetComponent <InterfaceController>();
        GameObject          admiral             = FindGameObjectWithTag("Admiral");

        admiral.GetComponent <DialogTrigger>().DisableInteraction();
        player.transform.parent.GetComponent <EndGameMusic>().PlayMusic();
        Transform cam = Camera.main.transform;

        interfaceController.Clear();
        GameManager.FreezePlayer();
        MonoBehaviour m = player.GetComponent <MonoBehaviour>();

        m.DoDelayed(0.25f, delegate
        {
            Vector3 observationPosition = new Vector3(23.68f, 27.49f, -27.52f);
            Vector3 observationEuler    = new Vector3(90.00001f, 0, 38.817f);

            m.StartCoroutine(SmoothTransformation <Vector3> .SmoothRotateAngleEuler(cam.eulerAngles, observationEuler, 4f, v => cam.eulerAngles = v));
            m.StartCoroutine(
                SmoothTransformation <Vector3> .SmoothRotateEuler(cam.position, observationPosition, 4f, v => cam.position = v, () =>
            {
                interfaceController.DoDelayed(5f, delegate
                {
                    admiral.GetComponent <IntroAdmiral>().JumpInWater();
                });
                Vector3 observationPosition2 = new Vector3(95, 255.7f, -116.1f);
                Vector3 observationEuler2    = new Vector3(51.937f, -38.817f, 0);
                m.StartCoroutine(SmoothTransformation <Vector3> .SmoothRotateAngleEuler(cam.eulerAngles, observationEuler2, 16f, v => cam.eulerAngles = v));
                m.StartCoroutine(
                    SmoothTransformation <Vector3> .SmoothRotateEuler(cam.position, observationPosition2, 17.8f, v => cam.position = v, delegate
                {
                    SceneSwitcher.EnterScene("MenueScene", false, false);
                }));
            })
                );
        });
    }
コード例 #12
0
ファイル: Events.cs プロジェクト: flofe104/SpackJerrow
    private static void LookAtTriangle()
    {
        Vector3 observationPosition = new Vector3(-182.81f, 65.13f, 41.95f);
        Vector3 observationEuler    = new Vector3(27.237f, -149.538f, 0);

        Transform     cam    = Camera.main.transform;
        Vector3       euler  = cam.localEulerAngles;
        Vector3       pos    = cam.localPosition;
        MonoBehaviour source = GameManager.GetPlayerComponent <MonoBehaviour>();

        source.StartCoroutine(SmoothTransformation <Vector3> .SmoothRotateAngleEuler(cam.eulerAngles, observationEuler, 2.5f, v => cam.eulerAngles = v));
        source.StartCoroutine(
            SmoothTransformation <Vector3> .SmoothRotateEuler(cam.position, observationPosition, 2.5f, v => cam.position = v, () =>
        {
            source.StartCoroutine(SmoothTransformation <Vector3> .SmoothRotateAngleEuler(observationPosition, observationPosition, 2f, v => { }, () =>
            {
                cam.localEulerAngles = euler;
                cam.localPosition    = pos;
            }));
        })
            );
    }
コード例 #13
0
ファイル: AnimateItem.cs プロジェクト: flofe104/SpackJerrow
    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;
        }
    }
コード例 #14
0
ファイル: Events.cs プロジェクト: flofe104/SpackJerrow
    public static void LookAtPortal()
    {
        Vector3 observationPosition = new Vector3(-253.2f, 35.7f, 119.1f);
        Vector3 observationEuler    = new Vector3(22.306f, -90f, 0);



        Transform     cam    = Camera.main.transform;
        Vector3       pos    = cam.localPosition;
        Vector3       euler  = cam.localEulerAngles;
        MonoBehaviour source = GameManager.GetPlayerComponent <MonoBehaviour>();

        source.StartCoroutine(SmoothTransformation <Vector3> .SmoothRotateAngleEuler(cam.eulerAngles, observationEuler, 2.5f, v => cam.eulerAngles = v));
        source.StartCoroutine(
            SmoothTransformation <Vector3> .SmoothRotateEuler(cam.position, observationPosition, 2.5f, v => cam.position = v, () =>
        {
            source.StartCoroutine(SmoothTransformation <Vector3> .SmoothRotateAngleEuler(observationPosition, observationPosition, 1.5f, v => { }, () =>
            {
                cam.localEulerAngles = euler;
                cam.localPosition    = pos;
            }));
        })
            );
    }
コード例 #15
0
 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));
 }