private void ThrowHit(BalloonInfo bi)
    {
        hookedBalloon = bi;
        Vector3 dir     = bi.transform.position - transform.position;
        float   dist    = dir.magnitude;
        Vector3 heading = dir / dist;
        float   newDist = dist * HookMovePercentage.Value;

        targetPosition      = transform.position + heading * newDist;
        otherTargetPosition = bi.transform.position - heading * newDist;

        startPosition      = transform.position;
        otherStartPosition = bi.transform.position;

        startTime = Time.time;

        Destroy(hook);

        GetComponent <Rigidbody2D>().bodyType    = RigidbodyType2D.Kinematic;
        bi.GetComponent <Rigidbody2D>().bodyType = RigidbodyType2D.Kinematic;

        if (bi.GetComponent <BalloonAIStabbing>() != null)
        {
            bi.GetComponent <BalloonAIStabbing>().enabled = false;
        }
    }
Beispiel #2
0
 public void Raise(BalloonInfo bi)
 {
     for (int i = eventListeners.Count - 1; i >= 0; i--)
     {
         eventListeners[i].OnEventRaised(bi);
     }
 }
    public void Taunt(BalloonInfo bi)
    {
        GameObject go = Instantiate(TauntPrefab);

        go.transform.position = bi.transform.position + Vector3.up * 2f;
        go.GetComponentInChildren <TextMeshProUGUI>().text = GetRandomTaunt();
        go.transform.parent = bi.transform;

        StartCoroutine(RemoveTaunt(TauntLength.Value, go));
    }
    private void PullBalloon()
    {
        float t = (Time.time - startTime) / HookMoveDuration.Value;

        if (t >= 1f)
        {
            GetComponent <Rigidbody2D>().bodyType = RigidbodyType2D.Dynamic;
            hookedBalloon.GetComponent <Rigidbody2D>().bodyType = RigidbodyType2D.Dynamic;

            if (hookedBalloon.GetComponent <BalloonAIStabbing>() != null)
            {
                hookedBalloon.GetComponent <BalloonAIStabbing>().enabled = true;
            }

            hookedBalloon = null;
            hook          = null;
            enabled       = false;
            return;
        }

        transform.position = Vector3.Lerp(startPosition, targetPosition, t);
        hookedBalloon.transform.position = Vector3.Lerp(otherStartPosition, otherTargetPosition, t);
    }
Beispiel #5
0
 public void OnEventRaised(BalloonInfo value)
 {
     Response.Invoke(value);
 }