Example #1
0
    public override void OnWork(CuboController user)
    {
        PlayerCommands.Get().OnCuboDestroyed();
        user.GetComponentInChildren <Selectable>().enabled = false;

        GameObject model = user.model;

        model.transform.DOPunchScale(new Vector3(1.025f, 0.8f, 1.025f), 0.25f, 0, 2f);

        Sequence seq = DOTween.Sequence();

        seq.Append(model.transform.DOLocalMoveY(5f, sacrificeTime).SetEase(Ease.InQuad));
        seq.Join(model.transform.DOScale(0f, sacrificeTime - 0.4f).SetEase(Ease.InQuad).SetDelay(0.4f));
        seq.Play();

        Camera.main.GetComponent <AudioSource>().PlayOneShot(sacrificeNoise);

        Timing.CallDelayed(sacrificeTime + 0.1f, delegate
        {
            Instantiate(workFxObj, transform.position + Vector3.up * 17f, Quaternion.LookRotation(Vector3.up, Vector3.left));
            power++;
            UIStatic.SetInt(UIStatic.CUR_SACRIFICE, power);
            Destroy(user.gameObject);

            if (power >= goalPower)
            {
                PlayerCommands.Get().Win();
            }
        });
    }