Beispiel #1
0
// -----------------------------------------------------------------------------
// Public Methods


    // [[ ----- SOUND EFFECT ----- ]]
    public void SoundEffect(FXType _type, int _num)
    {
        float duckTime = 0;

        switch (_type)
        {
        case FXType.Jump:
            int j = Mathf.Clamp(jumpFx.Length, 1, _num) - 1;
            audioC.PlayOneShot(jumpFx[j]);
            break;

        case FXType.Pickup:
            int f = Mathf.Clamp(pickupFx.Length, 1, _num) - 1;
            audioC.PlayOneShot(pickupFx[f]);
            break;

        case FXType.Death:
            duckTime = 2.75f;
            audioC.PlayOneShot(deathFx);
            break;

        case FXType.Checkpoint:
            duckTime = 3f;
            audioC.PlayOneShot(checkpointFx);
            break;
        }

        // duck audio
        if (duckTime > 0)
        {
            audioA.volume = musicDuckVol;
            audioB.volume = musicDuckVol;
            Invoke("Unduck", duckTime);
        }
    }
Beispiel #2
0
    public GameObject LoadFX(string fxName, float ttl, FXType type)
    {
        GameObject fx = GameObject.Instantiate(Resources.Load(fxName) as GameObject);

        int index = 0;

        switch (type)
        {
        case FXType.BulletHole:
            index = FindEmptySlot(_bulletHoles, _bulletHoleTimers);
            if (_bulletHoles[index] != null)
            {
                _bulletHoles[index].GetComponent <WFX_BulletHoleDecal>().StartFadeOut();
            }
            _bulletHoles[index]      = fx;
            _bulletHoleTimers[index] = ttl;
            break;

        case FXType.BulletImpact:
            //don't need to do anything; autodestruct
            break;

        case FXType.BloodSpatter:
            fx.transform.localScale = fx.transform.localScale * 2;
            BloodSpatter spatter = new BloodSpatter();
            spatter.Spatter = fx;
            spatter.TTL     = ttl;
            spatter.Timer   = 0;
            _bloodSpatters.Add(spatter);
            break;
        }

        return(fx);
    }
 public void PlaySFX(FXType type, int index, AudioSource source)
 {
     if (index < sfxClips[type].Length && index >= 0)
     {
         source.clip = sfxClips[type][index];
         source.PlayOneShot(sfxClips[type][index]);
     }
 }
Beispiel #4
0
 public UnityEngine.GameObject SpawnFX(FXType effectName, Vector3 position, Quaternion rotation, float vol = -1, Transform parent = null, bool onesie = false)
 {
     if (!FX_Dict.ContainsKey(effectName))
     {
         return(SpawnFX(fx_default, position, rotation.eulerAngles, vol, parent, FXType.Default));
     }
     return(SpawnFX(FX_Dict[effectName], position, rotation.eulerAngles, vol, parent, effectName));
 }
Beispiel #5
0
 public UnityEngine.GameObject SpawnFX(FXType effectName, Vector3 position, Vector3 rotation, float vol = -1, Transform parent = null, bool onesie = false)
 {
     if (!FX_Dict.ContainsKey(effectName))
     {
         return(SpawnFX(fx_default, position, rotation, vol, parent, FXType.Default));
     }
     return(SpawnFX(FX_Dict[effectName], position, rotation, vol, parent, effectName));
     //return SpawnFX(FX_Dict.GetValueOrDefault(effectName, FX_Dict[FXType.Default]), position, rotation, vol, parent);
 }
Beispiel #6
0
    public GameObject GetFXInstance(FXType type)
    {
        if (type == FXType.Explosion)
        {
            return(GameObject.Instantiate(_explosionPrefab));
        }

        return(null);
    }
Beispiel #7
0
    public void PlayFX(Vector3 position, FXType hitType, string colorText, float duration, float scale = 1)
    {
        GameObjectPoolManager.PrefabNames prefabName = (GameObjectPoolManager.PrefabNames)Enum.Parse(typeof(GameObjectPoolManager.PrefabNames), hitType.ToString());
        Color   color = ClientUtils.HTMLColorToColor(colorText);
        FX_Base fx    = GameObjectPoolManager.Instance.PoolDict[prefabName].AllocateGameObject <FX_Base>(transform);

        fx.transform.position = position;
        fx.Play(color, duration, scale);
    }
    /// <summary>
    /// Spawns a specific FX at a given position.
    /// </summary>
    /// <param name="_fxRype">Type of FX to instantiate.</param>
    /// <param name="_transformPhoton">PhotonView of the transform to use as FX parent.</param>
    public void SpawnEffect(FXType _fxRype, PhotonView _transformPhotonView)
    {
        if (PhotonNetwork.offlineMode)
        {
            Instantiate(GetFX((FXType)_fxRype), _transformPhotonView.transform, false);
            return;
        }

        TDS_RPCManager.Instance?.RPCPhotonView.RPC("CallMethodOnline", PhotonTargets.All, TDS_RPCManager.GetInfo(photonView, GetType(), "SpawnEffect"), new object[] { (int)_fxRype, _transformPhotonView });
    }
 public void PlayParticle(FXType type, int index, Vector3 source)
 {
     try
     {
         Instantiate(particles[type][index], source, Quaternion.identity);
     } catch (Exception e)
     {
         Debug.LogWarning("Particles Failed: " + e);
     }
 }
Beispiel #10
0
        public void PlaySoundEffect(FXType fxType)
        {
            IFXClip fxClip = _fxClips.FirstOrDefault(x => x.FxType == fxType);

            if (fxClip == null)
            {
                _logger.LogError(LoggedFeature.Audio, $"FX Clip not found: {fxType}");
                return;
            }

            _fxFactory.Create(fxClip.Clip);
        }
Beispiel #11
0
    void CollisionSound(GameObject other, Collision2D collision)
    {
        FXType effectName = FXType.Default;

        if (other.HasTag(Tag.Ball))
        {
            effectName = FXType.BallToBall;
        }
        else
        {
            effectName = FXType.BallToWall;
        }
        var vol = Mathf.Clamp(collision.contacts[0].normalImpulse, 0, collisionFXThreshold) / collisionFXThreshold;

        FX_Spawner.instance.SpawnFX(effectName, transform.position, Quaternion.identity, vol: vol);
    }
    /// <summary>
    /// Get the related FX.
    /// </summary>
    /// <param name="_fxType">Type of FX to get object from.</param>
    /// <returns>Returns the Particle system associated with the gieven type.</returns>
    public GameObject GetFX(FXType _fxType)
    {
        switch (_fxType)
        {
        case FXType.Kaboom:
            return(kaboomFX.gameObject);

        case FXType.Poof:
            return(poofFX.gameObject);

        case FXType.MagicAppear:
            return(magicPoofFX.gameObject);

        case FXType.MagicDisappear:
            return(disappearMagicPoofFX.gameObject);

        case FXType.RabbitPoof:
            return(rabbitMagicPoofFX.gameObject);

        case FXType.BeardGrowsUp:
            return(beardGrowFX.gameObject);

        case FXType.BeardDamaged:
            return(beardDamagedFX.gameObject);

        case FXType.Heal:
            return(healFX);

        case FXType.MrLoyalTeleportation:
            return(loyalTeleportationFX);

        case FXType.MrLoyalEndTeleportation:
            return(loyalEndTeleportationFX);

        default:
            // Nothing to see here...
            return(null);
        }
    }
    public FXBase getEffect(Vector2 position, Quaternion rotQuat, FXType type)
    {
        FXBase returnVal = null;
        switch(type)
        {
            case FXType.FXT_Hit01:
                returnVal = ObjectPoolManager.CreatePooled(m_hit01.gameObject, position, rotQuat).GetComponent<FXHit>();
                break;
            case FXType.FXT_Fire01:
                returnVal = ObjectPoolManager.CreatePooled(m_fire01.gameObject, position, rotQuat).GetComponent<FXFire01>();
                break;
            case FXType.FXT_Ice01:
                returnVal = ObjectPoolManager.CreatePooled(m_ice01.gameObject, position, rotQuat).GetComponent<FXIce01>();
                break;
            case FXType.FXT_Shock01:
                returnVal = ObjectPoolManager.CreatePooled(m_shock01.gameObject, position, rotQuat).GetComponent<FXShock01>();
                break;
        }

        returnVal.GetComponent<SpriteRenderer>().sortingOrder = 4;
        returnVal.GetComponent<SpriteRenderer>().sortingLayerName = "default";

        return returnVal;
    }
Beispiel #14
0
	public GameObject LoadFX(string fxName, float ttl, FXType type)
	{
		GameObject fx = GameObject.Instantiate(Resources.Load(fxName) as GameObject);

		int index = 0;

		switch(type)
		{
		case FXType.BulletHole:
			index = FindEmptySlot(_bulletHoles, _bulletHoleTimers);
			if(_bulletHoles[index] != null)
			{
				_bulletHoles[index].GetComponent<WFX_BulletHoleDecal>().StartFadeOut();
			}
			_bulletHoles[index] = fx;
			_bulletHoleTimers[index] = ttl;
			break;
		case FXType.BulletImpact:
			//don't need to do anything; autodestruct
			break;
		}

		return fx;
	}
Beispiel #15
0
    public void DoFX(FXType fxType, Vector2 fxPosition)
    {
        if (pool == null)
        {
            pool = ObjectPool.instance;
        }

        string animStateName = fxType.ToString();

        if (fxType == FXType.Bugs)
        {
            if (AreaController.instance.active_area.areaType == AreaType.Interior)
            {
                return;
            }

            animStateName += Random.Range(0, 2).ToString();
        }
        GameObject fxGobj = pool.GetObjectForType("FX", true, fxPosition);

        // set animation
        fxGobj.GetComponentInChildren <Animator>().Play(animStateName);
        activeFX.Add(fxGobj);
    }
 /// <summary>
 /// Spawns a specific FX at a given position.
 /// </summary>
 /// <param name="_fxtype">Type of FX to instantiate.</param>
 /// <param name="_position">Position where to spawn the FX.</param>
 public void SpawnEffect(FXType _fxtype, Vector3 _position)
 {
     TDS_RPCManager.Instance?.RPCPhotonView.RPC("CallMethodOnline", PhotonTargets.All, TDS_RPCManager.GetInfo(photonView, GetType(), "SpawnEffect"), new object[] { (int)_fxtype, _position.x, _position.y, _position.z });
 }
Beispiel #17
0
 //---------------------------------------------------------------------------------- -
 public void SpawnEffect(FXType fxType)
 {
     m_fxSpawner.SpawnEffect(fxType);
 }
Beispiel #18
0
            protected AbstractFXMesh(IMeshLoader loader, Transform anchor, string characterRace, FXType type)
            {
                this.anchor        = anchor;
                this.CharacterRace = characterRace;
                this.FxType        = type;

                parent = GameObject.Find("ModularMesh");
                if (parent == null)
                {
                    parent = new GameObject("ModularMesh");
                }

                loadCallback = (meshes) => LoadingMeshes(meshes);
                loader.ParseMeshes(this, loadCallback);
            }
Beispiel #19
0
 public FxMeshTypeBone(FXType type, string bone)
 {
     mesh     = type;
     boneName = bone;
 }
Beispiel #20
0
    public UnityEngine.GameObject SpawnFX(UnityEngine.GameObject fx, Vector3 position, Vector3 rotation, float vol = -1, Transform parent = null, FXType effectName = FXType.Default)
    {
        if (fx == null)
        {
            return(null);
        }

        if (onesieTracker.ContainsKey(effectName))
        {
            if (onesieTracker[effectName])
            {
                return(null);
            }
        }

        UnityEngine.GameObject spawned_fx = Instantiate(fx, position, Quaternion.identity);
        if (onesieChecker.ContainsKey(effectName) && onesieChecker[effectName])
        {
            onesieTracker[effectName] = spawned_fx;
        }


        if (spawned_fx == null)
        {
            return(null);
        }

        spawned_fx.transform.parent = (parent != null ? parent : holder.transform);

        if (rotation != Vector3.zero)
        {
            spawned_fx.transform.forward = rotation;
        }
        FX_Object fx_obj = spawned_fx.GetComponent <FX_Object>();

        fx_obj.vol        = vol;
        fx_obj.mixerGroup = mixer;

        return(spawned_fx);
    }
Beispiel #21
0
 public void PlayFX(Transform parentTrans, FXType hitType, string colorText, float duration, float scale = 1)
 {
     PlayFX(parentTrans.position, hitType, colorText, duration, scale);
 }
Beispiel #22
0
 public GameObject SpawnFX(FXType effectName, Vector3 position, Vector3 rotation)
 {
     return(SpawnFX(fx_objs[(int)effectName], position, rotation));
 }