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); } }
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(); }
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(); } }