Beispiel #1
0
 // Start is called before the first frame update
 void Awake()
 {
     playerController = GetComponent <PlayerController>();
     bombInteractable = GetComponent <BombInteractable>();
     StatTracker      = ScriptableObject.CreateInstance <StatTracker>();
     playerList.AddItem(this);
 }
Beispiel #2
0
    private void OnTriggerEnter(Collider other)
    {
        BombInteractable bi = other.gameObject.GetComponent <BombInteractable>();

        if (bi != null && bi.type != InteractableType.GROUND)
        {
            if (bi.GetComponent <Player>() != Owner)
            {
                Explode();
            }
        }
    }
Beispiel #3
0
    protected virtual void Explode()
    {
        CameraShake.CameraShakeEvent.Invoke(data.shakeDuration, data.shakeMagnitude);

        if (GetType() == typeof(ThrowingBomb))
        {
            Owner.gameObject.GetComponent <PlayerController>().PlayThrowingExplosion();
        }
        else
        {
            Owner.gameObject.GetComponent <PlayerController>().PlayBigExplosion();
        }

        GameObject effect = Instantiate(data.explosionEffect, transform.position, transform.rotation);

        Destroy(effect, 1f);

        Collider[] colliders = Physics.OverlapSphere(transform.position, data.radius);
        List <BombInteractable> bombInteractables = new List <BombInteractable>();

        foreach (Collider hit in colliders)
        {
            BombInteractable bi = hit.GetComponent <BombInteractable>();
            if (bi)
            {
                bombInteractables.Add(bi);

                Vector3 difference = bi.transform.position - transform.position;
                difference.y = data.upForce;
                Vector3 direction = Vector3.Normalize(difference);

                bi.Explode(direction, data.force, Owner);
            }
        }

        // Adds hits to StatTracker
        Owner.StatTracker.AddStat(new CountStat(Owner, "hits", bombInteractables.Count));
        Owner.StatTracker.AddStat(new RecordStat(Owner, "mostHitsWithOneBomb", bombInteractables.Count));

        if (bombEffect != null)
        {
            bombEffect.Activate(bombInteractables);
        }

        Destroy(gameObject);
    }
Beispiel #4
0
 public void SetTarget(BombInteractable target)
 {
     this.target = target;
 }