コード例 #1
0
    /** Creates a PotaTween component to play the preset */
    public PotaTween Initialize(GameObject gameObject, int id = 0)
    {
        this.gameObject = gameObject;
        this.transform  = gameObject.transform;

        PotaTween potaTween = PotaTween.Create(this.gameObject, id);

        potaTween.Tag                = Tag;
        potaTween.PlayOnEnable       = PlayOnEnable;
        potaTween.PlayOnStart        = PlayOnStart;
        potaTween.Duration           = Duration;
        potaTween.Speed              = Speed;
        potaTween.Delay              = Delay;
        potaTween.Loop               = Loop;
        potaTween.LoopsNumber        = LoopsNumber;
        potaTween.EasingReference    = EasingReference;
        potaTween.EaseEquation       = EaseEquation;
        potaTween.Curve              = Curve;
        potaTween.FlipCurveOnReverse = FlipCurveOnReverse;

        potaTween.Position = Position;
        potaTween.Rotation = Rotation;
        potaTween.Scale    = Scale;
        potaTween.Color    = Color;
        potaTween.Alpha    = Alpha;
        potaTween.Float    = Float;

        potaTween.onStart    = onStart;
        potaTween.onComplete = onComplete;

        return(potaTween);
    }
コード例 #2
0
ファイル: HookController.cs プロジェクト: GustavGMD/GGJ2018
 // Use this for initialization
 void Start()
 {
     hookTip.SetActive(false);
     transform.localScale = preAttackScale;
     _potaTween           = PotaTween.Create(gameObject);
     hookTip.GetComponent <HookBehaviour>().onEnemyCollision += OnEnemyCollision;
 }
コード例 #3
0
    public void BlobJoinAnimation(GameObject p_target, Vector3 p_from)
    {
        //p_target.GetComponent<Renderer>().enabled = true;
        hookPivots[hookPivots.Count - 1].GetComponent <HookController>().SetBodySprite(false);
        p_target.GetComponent <SpriteBubbleManager>().ActivateObjects(true);
        //p_target.transform.SetParent(null);
        //p_target.transform.localScale = Vector3.one * 3;
        Vector2 __startingPosition = p_target.transform.position;
        //p_target.transform.SetParent(transform);
        PotaTween __pTween = p_target.GetComponent <PotaTween>();

        __pTween.Clear();
        __pTween.SetPosition(p_from, transform.position);
        __pTween.SetEaseEquation(Ease.Equation.InSine);
        __pTween.UpdateCallback(delegate
        {
            //Debug.Log(new Vector2((p_target.transform.position.x - __startingPosition.x), p_target.transform.position.y - __startingPosition.y));
            //p_target.transform.position = (Vector2)transform.position + ((__startingPosition - (Vector2)p_target.transform.position) * __pTween.Float.Value);
            __pTween.Position.To = (Vector2)transform.position;
        });
        __pTween.Play(delegate
        {
            //p_target.GetComponent<Renderer>().enabled = false;
            hookPivots[hookPivots.Count - 1].GetComponent <HookController>().SetBodySprite(true);
            p_target.GetComponent <SpriteBubbleManager>().ActivateObjects(false);
        });
    }
コード例 #4
0
    public virtual void OnPanelEnable()
    {
        PotaTween tween = animEnable.Initialize(gameObject);

        tween.Play(() => {
            GetComponent <CanvasGroup>().interactable = true;
        });
    }
コード例 #5
0
    public virtual void OnPanelDisable()
    {
        PotaTween tween = animDisable.Initialize(gameObject);

        tween.Play(() => {
            gameObject.SetActive(false);
        });
        GetComponent <CanvasGroup>().interactable = false;
    }
コード例 #6
0
    public void OnAttackHitMethod(PlayerBehaviour p_other)
    {
        if (p_other != this)
        {
            //atingiu um player isolado
            if (p_other.capturedPlayersStack.Count == 1)
            {
                //Adiciona elementos nas stacks: Referencia ao objeto a ser animado, e referência ao Input q ele usa
                capturedPlayersStack.Add(p_other.capturedPlayersStack[0]);
                capturedInputsStack.Add(p_other.capturedInputsStack[0]);
                hookPivots.Add(p_other.hookPivots[0]);
                p_other.hookPivots[0].GetComponent <HookController>().onAttackHit += OnAttackHitMethod;
                p_other.hookPivots[0].GetComponent <HookController>().DisableHookCollider();

                //Reseta atributos do player capturado
                CleanCapturedPlayer(p_other.gameObject);

                //adiciona um componente de Tween que será usado para as animações
                PotaTween.Create(p_other.gameObject);

                //Play animations
                BlobJoinAnimation(p_other.gameObject, p_other.transform.position);
                GrowingAnimation(1f);
            }
            //atingiu um Blob
            else
            {
                //A blob atingida desprende um de seus blobs: chamamos um método nela que retorna o objeto a ser manipulado, e um outro que retorna o input
                //Pega a referência das coisas do outro
                GameObject __tempObject = p_other.RemoveParticleFromBlob();
                char       __tempInput  = p_other.RemoveInputFromBlob();
                GameObject __tempPivot  = p_other.RemoveHookPivotFromBlob();
                capturedPlayersStack.Add(__tempObject);
                capturedInputsStack.Add(__tempInput);
                hookPivots.Add(__tempPivot);
                __tempPivot.transform.parent.SetParent(transform);
                __tempPivot.GetComponent <HookController>().onAttackHit += OnAttackHitMethod;

                //chama as animações
                BlobJoinAnimation(__tempObject, p_other.transform.position);
                GrowingAnimation(1);
                p_other.GrowingAnimation(0);
            }

            //desativa pra ele não colidir com mais nada
            //__tempHook.SetActive(false);
        }
    }
コード例 #7
0
    public void GrowingAnimation(float p_delay)
    {
        if (GetComponent <PotaTween>() == null)
        {
            PotaTween.Create(gameObject);
        }
        PotaTween __pTween = GetComponent <PotaTween>();

        __pTween.SetScale(transform.localScale, Vector3.one * (10 + (capturedPlayersStack.Count)));
        __pTween.SetEaseEquation(Ease.Equation.OutElastic);
        __pTween.SetDelay(p_delay);
        __pTween.Play(delegate
        {
            UpdateHookPivots();
        });
        //UpdateHookPivots();
    }
コード例 #8
0
ファイル: PotaTween.cs プロジェクト: HenriqueDerosa/PotaTween
    /// <summary>
    /// Creates a new PotaTween, or returns an existing with the same target and id.
    /// </summary>
    /// <param name="target">GameObject that the tween will be attached to.</param>
    /// <param name="id">Id of the tween for reference.</param>
    public static PotaTween Create(GameObject target, int id = 0)
    {
        PotaTween[] tweens = target.GetComponents <PotaTween>();

        if (tweens != null)
        {
            for (int i = 0; i < tweens.Length; i++)
            {
                if (tweens[i].Id == id)
                {
                    return(tweens[i]);
                }
            }
        }

        PotaTween tween = target.AddComponent <PotaTween>();

        tween.Id = id;
        tween.Initialize();

        return(tween);
    }
コード例 #9
0
    public void UpdateHookPivots()
    {
        float __archSize = (2 * Mathf.PI) / hookPivots.Count;

        for (int i = 0; i < hookPivots.Count; i++)
        {
            //atualiza o parent do pivot
            hookPivots[i].transform.parent.parent   = gameObject.transform;
            hookPivots[i].transform.parent.position = transform.position;
            //hookPivots[i].transform.localScale = Vector3.one/2;
            hookPivots[i].transform.parent.localScale = Vector3.one;

            //calcula o novo ângulo
            float __targetAngle = i * __archSize;
            int   __num         = i;

            //coloca tween nos pivots, ou confere se eles já têm
            if (hookPivots[i].GetComponent <PotaTween>() == null)
            {
                PotaTween.Create(hookPivots[i].gameObject);
            }
            PotaTween __pTween = hookPivots[i].GetComponent <PotaTween>();
            __pTween.Clear();
            __pTween.SetFloat(hookPivots[i].transform.eulerAngles.z, __targetAngle * Mathf.Rad2Deg);
            __pTween.UpdateCallback(delegate()
            {
                if (hookPivots.Count > __num)
                {
                    hookPivots[__num].transform.parent.eulerAngles = new Vector3(0, 0, __pTween.Float.Value);
                }
            });

            //ativa o tween pra ir pra posição
            __pTween.Play();
        }
    }