Exemplo n.º 1
0
    private void SpawnEffects(bool paintImpactParticle, bool paintDecal, Vector3 hitPosition, Quaternion decalRot, Quaternion paintImpactRot, int paintType)
    {
        paintMuzzleFlashParticle.Initialise(PlayerManager.instance.entity.paintController.GetPaintColor((PaintController.PaintType)paintType));
        muzzleFlashParticle.Play();

        if (!photonView.IsMine)
        {
            AudioController audioController = ObjectPooler.instance.GrabFromPool("Audio_GunFire", transform.position, Quaternion.identity).GetComponent <AudioController>();
            audioController.Play(transform);
        }

        if (paintImpactParticle)
        {
            GameObject          newSpawn = ObjectPooler.instance.GrabFromPool("PaintImpact", hitPosition, paintImpactRot);
            PaintImpactParticle pip      = newSpawn.GetComponent <PaintImpactParticle>();
            if (pip)
            {
                pip.Initialise(PlayerManager.instance.entity.paintController.GetPaintColor((PaintController.PaintType)paintType));
            }
        }

        if (paintDecal)
        {
            GameObject newSpawn = ObjectPooler.instance.GrabFromPool("PaintDecal", hitPosition, decalRot);
            PaintDecal decal    = newSpawn.GetComponent <PaintDecal>();
            if (decal)
            {
                decal.Initialise(PlayerManager.instance.entity.paintController.GetPaintColor((PaintController.PaintType)paintType));
            }
        }
    }
Exemplo n.º 2
0
 private void Awake()
 {
     if (instance == null)
     {
         //if not, set instance to this
         instance = this;
     }
     else if (instance != this)     //If instance already exists and it's not this:
     //Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a GameManager.
     {
         Destroy(gameObject);
         return;
     }
 }