Exemple #1
0
 public override void Setup()
 {
     base.Setup();
     soundCtrl    = GetComponentInChildren <BulletSoundController>();
     spawnSticky  = false;
     stickyObject = null;
 }
Exemple #2
0
    protected override void ObjectSpawnEvent()
    {
        muzzleFlashParticle.transform.position    = shotPosition;
        muzzleFlashParticle.transform.eulerAngles = new Vector3(0, 0, shotAngle);
        muzzleFlashParticle.Play();
        soundCtrl.Shot();
        bulletParticle.Play();

        spawnSticky  = false;
        stickyObject = null;

        Ray        ray = new Ray(transform.position, transform.right);
        RaycastHit hitInfo;

        if (Physics.SphereCast(ray, bulletCollider.radius, out hitInfo, 100f, layersToCheck))
        {
            if (hitInfo.transform.gameObject.layer == LayerMask.NameToLayer("Obstacle"))
            {
                stickyObject = PoolManager.instance.GetPooledObject(stickyObjectType, gameObject).GetComponent <StickyObject>();
                spawnSticky  = stickyObject.Init(hitInfo.point, hitInfo.normal, Quaternion.LookRotation(Vector3.forward, hitInfo.normal));
            }
        }

        base.ObjectSpawnEvent();
    }
Exemple #3
0
    IEnumerator DelaySticky(StickyObject obj)
    {
        Destroy(obj.GetComponent<Rigidbody>());
        obj.GetComponent<StickyObject>().group = group;
        obj.transform.parent = group.transform;

        yield return null;
    }
Exemple #4
0
 void MergeGroups(StickyObject other)
 {
     Debug.Log("Merge groups");
     other.transform.parent = null;
     if (other.group.transform.childCount == 0)
     {
         Destroy(other.group.gameObject);
     }
     other.group = null;
     AddToOwnGroup(other);
 }
Exemple #5
0
 void AddToOwnGroup(StickyObject obj)
 {
     StartCoroutine(DelaySticky(obj));
 }