Example #1
0
    public void TriggerScar(Collider2D collider, bool isCut, ColliderTool tool = null)
    {
        if (!collider)
        {
            return;
        }
        RectTransform scar = collider.GetComponent <RectTransform>();

        if (true == isCut && false == _toolScraper.GetColliderTriggerState(collider))
        {
            _toolBandage.SetColliderTriggerState(collider, false);
            _toolScraper.SetColliderTriggerState(collider, true);
            _toolRazor.SetColliderTriggerState(collider, true);
            _toolGrower.SetColliderTriggerState(collider, false);
            collider.enabled = false;
            _model.InsertSad();
            Image image = scar.GetComponent <Image>();
            image.color   = new Color(1, 1, 1, 0);
            image.enabled = true;
            image.DOFade(1, 0.1f).SetEase(Ease.Linear);
        }
        else if (false == isCut && false == _toolBandage.GetColliderTriggerState(collider))
        {
            _toolBandage.SetColliderTriggerState(collider, true);
            _toolScraper.SetColliderTriggerState(collider, false);
            _toolRazor.SetColliderTriggerState(collider, false);
            _toolGrower.SetColliderTriggerState(collider, true);
            scar.GetComponent <Image>().enabled = false;
            if (null != tool)
            {
                tool._drag.SetEnabled(false);
                tool._drag.BackPosition(UGUIDrag.DragBackEffect.TweenScale);
                GameObject bandage = Instantiate(_prefabBandage);
                bandage.transform.SetParent(_fixArea);
                bandage.transform.position   = scar.transform.position;
                bandage.transform.localScale = scar.transform.localScale;
                AudioManager.PlaySound(_soundPutIn);
                Sequence sequence = DOTween.Sequence();
                sequence.AppendInterval(0.5f);
                sequence.AppendCallback(() =>
                {
                    tool._drag.SetEnabled(true);
                });
                sequence.AppendInterval(1.5f);
                sequence.AppendCallback(() => {
                    AudioManager.PlaySound(_soundTakeOff);
                });
                sequence.Append(bandage.GetComponent <Image>().DOFade(0f, 0.8f).SetEase(Ease.Linear));
                sequence.OnComplete(() =>
                {
                    DestroyImmediate(bandage, true);
                });
            }
        }
    }
Example #2
0
    public void TriggerRed(Collider2D collider, bool isCut, ColliderTool tool = null)
    {
        if (!collider)
        {
            return;
        }
        RectTransform red = collider.GetComponent <RectTransform>();

        if (true == isCut && false == _toolScraper.GetColliderTriggerState(collider))
        {
            _toolUnguent.SetColliderTriggerState(collider, false);
            _toolScraper.SetColliderTriggerState(collider, true);
            _toolRazor.SetColliderTriggerState(collider, true);
            _toolGrower.SetColliderTriggerState(collider, false);
            collider.enabled = false;
            _model.InsertSad();
            Image image = red.GetComponent <Image>();
            image.color   = new Color(1, 1, 1, 0);
            image.enabled = true;
            image.DOFade(1, 0.1f).SetEase(Ease.Linear);
        }
        else if (false == isCut && false == _toolUnguent.GetColliderTriggerState(collider))
        {
            _toolUnguent.SetColliderTriggerState(collider, true);
            _toolScraper.SetColliderTriggerState(collider, false);
            _toolRazor.SetColliderTriggerState(collider, false);
            _toolGrower.SetColliderTriggerState(collider, true);
            red.GetComponent <Image>().enabled = false;
            if (null != tool)
            {
                GameObject cream = Instantiate(_prefabCream);
                cream.transform.SetParent(_fixArea);
                cream.transform.position   = red.transform.position;
                cream.transform.localScale = red.transform.localScale;
                AudioManager.PlaySound(_soundPutIn);
                Image    image    = cream.GetComponent <Image>();
                Sequence sequence = DOTween.Sequence();
                sequence.AppendInterval(2f);
                sequence.Append(cream.GetComponent <Image>().DOFade(0f, 0.8f).SetEase(Ease.Linear));
                sequence.OnComplete(() =>
                {
                    DestroyImmediate(cream, true);
                });
            }
        }
    }
Example #3
0
    public void TriggerMessy(Collider2D collider, bool isCut)
    {
        if (!collider)
        {
            return;
        }
        RectTransform messy = collider.GetComponent <RectTransform>();

        if (true == isCut && false == _toolScissors.GetColliderTriggerState(collider))
        {
            _toolScissors.SetColliderTriggerState(collider, true);
            _toolGrower.SetColliderTriggerState(collider, false);
            collider.enabled = false;
            Vector2    pos      = messy.anchoredPosition;
            Quaternion rotate   = messy.localRotation;
            Sequence   sequence = DOTween.Sequence();
            sequence.Append(messy.DOAnchorPosY(pos.y - 500, 1.2f).SetEase(Ease.Linear));
            sequence.Join(messy.DOLocalRotate(new Vector3(0, 0, 100), 1.2f, RotateMode.Fast));
            sequence.OnComplete(() =>
            {
                messy.GetComponent <Image>().enabled = false;
                messy.localRotation    = rotate;
                messy.anchoredPosition = pos;
            });
        }
        else if (false == isCut && false == _toolGrower.GetColliderTriggerState(collider))
        {
            _toolScissors.SetColliderTriggerState(collider, false);
            _toolGrower.SetColliderTriggerState(collider, true);
            collider.enabled = false;
            Image image = messy.GetComponent <Image>();
            image.enabled = true;
            Color color = image.color;
            image.color = new Color(color.r, color.g, color.b, 0f);
            image.DOFade(1f, 0.3f).SetEase(Ease.Linear);
        }
    }