示例#1
0
	IEnumerator PlayFx(PlayerFxDatum d)
	{
		GameObject fxPrefab = null;
		GameObject thisFx = null;
		Transform thisFxT = null;
		string fxName = System.IO.Path.GetFileNameWithoutExtension( d.prefabPath );
		foreach (GameObject g in allFx)
		{
			if (g.name == fxName)
			{
				fxPrefab = g;
				break;
			}
		}

		yield return new WaitForSeconds(d.delay);
		float birthTime = Time.time;
		float lifeTime = 2;
		if (fxPrefab != null)
		{
			Vector3 pos =  d.pos;
			if (d.fxType == FxType.AtEnemy)
			{
				pos += Vector3.forward * 7;
			}
			Debug.Log (d.prefabPath);
			thisFx = GameObject.Instantiate(fxPrefab, transform.TransformPoint( pos), transform.rotation * Quaternion.Euler(d.rot)) as GameObject;
			thisFxT = thisFx.transform;
			FxDuration duration = thisFx.GetComponent< FxDuration>();
			if ( duration != null ){
				lifeTime = duration.duration == -1? lifeTime : duration.duration;
			}

		}


		if (thisFx != null)
		{
			while (Time.time < lifeTime + birthTime)
			{
				if (d.fxType == FxType.Bullet)
				{
					thisFxT.position += thisFxT.forward * 15 * Time.deltaTime;
				}
				yield return null;
			}
			GameObject.Destroy(thisFx);
		}
	}
示例#2
0
	public PlayerFxData(PlayerFxDatum[] data)
	{
		this.data = data;
	}