public DelayFX(FXController fx, DelayDelegate delayDelegate, object userData0, object userData1) : base(delayDelegate, userData0, userData1) { this.fx = fx; fx.AddFinishCallback(FxFinishCallback, null); }
public void StartFx(FXController fxController) { if (fxController) { fxController.Start(); } }
private void refreshCharacterCar() { //Get player prefeab currentVehicleIndex = PlayerPrefs.GetInt("CharacterSelected"); //Deactive all car, active the selected one for (int i = 0; i < carList.Count; i++) { //Deactive all car box collider carList[i].transform.GetComponent <BoxCollider>().enabled = false; //Deactive not selected car. Active selected car if (i == currentVehicleIndex) { Debug.Log("Set ACTIVE car number " + i + "Name : " + carList[i].name); carList[i].SetActive(true); //Set up new fx controller; fxController = carList[i].GetComponentInChildren <FXController>(); } else { carList[i].SetActive(false); } } }
//TODO:需要添加参数控制是否立即播放,这关系到声音在什么位置出现 public FXController CreateFxAndBuildParent(string filePath) { GameObject obj = PoolManager.Instance.Spawm(filePath, ClientCommon.AssetType.PFX, ClientCommon.AssetType.PFX.ToString()); // obj.name = System.IO.Path.GetFileName(filePath); // 注意,不能更改名字 FXController fx = obj.GetComponent <FXController>(); if (fx == null) { Transform parentTrans = new GameObject(obj.name).transform; ObjectUtility.AttachToParentAndResetLocalPosAndRotation(parentTrans, obj.transform); // Reset root transform parentTrans.localPosition = Vector3.zero; parentTrans.localRotation = Quaternion.identity; parentTrans.localScale = Vector3.one; fx = parentTrans.gameObject.AddComponent <FXController>(); fx.loop = true; fx.autoDestroy = true; obj = parentTrans.gameObject; } if (fx) { fx.Start(); } return(fx); }
void Update() { if (null == m_ObjTransform || null == m_ObjTransform.parent) { return; } Vector3 targetPos; Obj_Character Target = Singleton <ObjManager> .Instance.FindObjCharacterInScene(m_targetID); if (null == Target) { FXController curController = m_ObjTransform.parent.GetComponent <FXController>(); if (null != curController) { curController.Stop(); } return; } targetPos = Target.transform.position; targetPos.y += Height; LightingParent.localScale = new Vector3(1, 1, (targetPos - m_ObjTransform.position).magnitude / OrgLength); transform.LookAt(targetPos); }
public FxInst(FXController fx, int destroyMode, int userData) { instanceId = idAllcocator.NewID(); this.fxController = fx; this.destroyMode = destroyMode; this.userData = userData; }
public FXController Spawm() { if (released) { return(null); } if (template == null) { return(null); } FXController fx = null; if (despawmFXs.Count == 0 || despawmFXs[despawmFXs.Count - 1].GetNextPoolTime() > Time.time) { #if FX_POOL_METRICS allocCount++; #endif // Instantiate new FX var go = GameObject.Instantiate(template.gameObject) as GameObject; // Template is inactive, set new go active go.SetActive(true); // Get FXController fx = go.GetComponent <FXController>(); // Add a root GO as default fx.CreateRoot(); Object.DontDestroyOnLoad(fx.Root); // Set pool fx.FXPool = this; } else { #if FX_POOL_METRICS spawmFromPoolCount++; #endif // Get from pool fx = despawmFXs[despawmFXs.Count - 1]; despawmFXs.RemoveAt(despawmFXs.Count - 1); // Attach scene root ObjectUtility.AttachToParentAndResetLocalTrans(null, fx.Root); // Pooled Fx is inactive, set active fx.Root.gameObject.SetActive(true); } // Start FX fx.Start(); return(fx); }
// Start is called before the first frame update void Start() { anim = GetComponent <Animator>(); anim.speed = initialAnimatorSpeed; fxController = soundEffectParentObject.GetComponent <FXController>(); powerLevel = 0; levelDone = false; nextLevelTime = -1f; }
public FXController PlayFX(string fxName, GameObject parent, bool attachedToParent, bool autoDestroy, bool isResetLocalPos, bool startImmediately, bool setLayerAsParent = true) { // string fxPath = PathUtility.Combine(baseFxPath, fxName); FXController fx = CreateFxNonStart(fxName); // AssertHelper.Check(fx != null, fxName + " not exist!"); if (fx == null) { return(null); } // Attach to parent if (attachedToParent) { if (isResetLocalPos) { ObjectUtility.AttachToParentAndResetLocalPosAndRotation(parent.transform, fx.Root); } else { ObjectUtility.AttachToParentAndKeepLocalTrans(parent.transform, fx.Root); } } else { if (isResetLocalPos) { ObjectUtility.UnifyWorldTrans(parent.transform, fx.Root); } } // Set layer if (setLayerAsParent) { ObjectUtility.SetObjectLayer(fx.gameObject, parent.layer); } if (autoDestroy) { // Set auto destroy flag to FX script. FXController pfxScp = fx.GetComponentInChildren <FXController>(); if (pfxScp != null) { pfxScp.autoDestroy = true; pfxScp.loop = false; } } if (startImmediately) { fx.Start(); } return(fx); }
void triggerEffects() { FXController fXController = GameObject.Find("FX").GetComponent <FXController>(); SampleController sampleController = GameObject.Find("Audio Controller").GetComponent <SampleController>(); sampleController.playSound(SoundName.HIT); fXController.chromaticHit(); fXController.bloomHit(10f); }
private bool CheckParticlePlayerExist(FXController fx) { foreach (var item in fx.effects) { if (item != null && item is EParticlePlayer) { return(true); } } return(false); }
/// <summary> /// 如果想在创建后更改位置(一般目的是在指定位置播放声音),则应该调用CreateFxNonStart。 /// </summary> public FXController CreateFx(string filePath) { FXController fx = CreateFxNonStart(filePath); if (fx) { fx.Start(); } return(fx); }
public override void OnInspectorGUI() { FXController fx = target as FXController; EditorTools.DrawEntityMark(); base.OnInspectorGUI(); //GUI.backgroundColor = Color.yellow; //if (!CheckParticlePlayerExist(fx) && GUILayout.Button("添加粒子组件", GUILayout.Height(30))) //{ // EParticlePlayer particlePlayer = fx.gameObject.GetComponent<EParticlePlayer>(); // if(particlePlayer == null) // particlePlayer=fx.gameObject.AddComponent<EParticlePlayer>(); // fx.effects.Add(particlePlayer); // particlePlayer.particles.Clear(); // foreach (var v in fx.GetComponentsInChildren<ParticleSystem>(true)) // { // if (v.emission.enabled) // particlePlayer.particles.Add(v); // } //} //GUI.backgroundColor = Color.white; if (!Application.isPlaying) { simProgress = EditorGUILayout.IntSlider("Sample Preview", simProgress, 0, 100); if (GUI.changed) { fx.GetComponentsInChildren <ParticleSystem>(false, tempList); foreach (var item in tempList) { item.Simulate(simProgress / 100.0f); } } } if (GUILayout.Button("ScaleMode: Hierarchy")) { fx.GetComponentsInChildren <ParticleSystem>(false, tempList); foreach (var item in tempList) { item.scalingMode = ParticleSystemScalingMode.Hierarchy; } } GUILayout.Space(10); if (FXDrawBase.DrawFXEffects(fx, fx.effects)) { EditorTools.SetDirty(fx); } }
// Use this for initialization void Start() { print("-----------------------------------------------------------------------------------------------"); //Find the far left corner of the field sprite and add half of a block size to it to find the position of 0,0, then increase x to above the push line fieldRenderer = GetComponent <Renderer>(); blockCenterOffset = fieldRenderer.bounds.min + (blockSize / 2); fxControllerScript = GameObject.FindGameObjectWithTag("FX").GetComponent <MonoBehaviour>() as FXController; CreateStartingBlocks(-1, 6); }
public override void StopEffect(int effectID, bool bStopAll = true) { base.StopEffect(effectID, bStopAll); //材质变色材料停止的时候 置回初始颜色 if (m_EffectHolder != null) { Tab_Effect startEffect = TableManager.GetEffectByID(effectID, 0); if (null != startEffect) { if (startEffect.Type == (int)EEffectChangeType.TYPE_CHANGBLUE || startEffect.Type == (int)EEffectChangeType.TYPE_CHANGRED) { m_EffectHolder.SetMaterialInitColor(); } } } foreach (KeyValuePair <string, GameObject> pair in m_effectBindPointCache) { if (pair.Value == null || pair.Value.transform == null) { //Debug.LogError("m_effectBindPointCache 中 特效 是 null "); continue; } for (int i = 0; i < pair.Value.transform.childCount; i++) { Transform childTransform = pair.Value.transform.GetChild(i); if (childTransform) { FXController curController = childTransform.GetComponent <FXController>(); if (curController) { //处于播放完的隐藏状态 不需要stop if (curController.Remaindelay < 0 && curController.Remainduration < 0 && curController.gameObject.activeSelf == false) { continue; } if (curController.EffectID == effectID) { curController.Stop(); if (!bStopAll) { return; } } } } } } }
public void Release() { FreePooledFx(); if (template != null) { Object.Destroy(template.gameObject); } template = null; released = true; }
public void EffectDeactive(FXController curController) { if (m_dicEffectCache.ContainsKey(curController.EffectID) && null != m_dicEffectCache[curController.EffectID]) { m_dicEffectCache[curController.EffectID].Add(curController); } else { m_dicEffectCache.Add(curController.EffectID, new List <FXController>()); m_dicEffectCache[curController.EffectID].Add(curController); } OnEffectOver(curController.EffectID); }
// Start is called before the first frame update void Start() { allSheep = GameObject.FindGameObjectsWithTag("Sheep"); sheepPSystems = new ParticleSystem[allSheep.Length]; for (int i = 0; i < sheepPSystems.Length; i++) { sheepPSystems[i] = allSheep[i].GetComponentInChildren <ParticleSystem>(); } fxController = soundEffectParentObject.GetComponent <FXController>(); nextGrassBeatTime = Time.time + 1; nextSheepBeatTime = Time.time + 1.5f; poseChangeNextBeat = false; }
public void InitData(int sendId, int targetId) { mTrans = transform; if (null == mTrans.parent) { mFxController = null; return; } else { mFxController = mTrans.parent.GetComponent <FXController>(); } if (null == mFxController) { return; } Obj_Character Sender = Singleton <ObjManager> .Instance.FindObjCharacterInScene(sendId); Obj_Character Target = Singleton <ObjManager> .Instance.FindObjCharacterInScene(targetId); if (null == Sender || null == Target) { mFxController.Stop(); return; } m_startPos = Sender.transform.position; m_startPos.y += startHeight; mTrans.position = m_startPos; m_targetPos = Target.transform.position; m_targetPos.y += startHeight; m_dir = (m_targetPos - m_startPos); if (m_duration > 0) { m_speed = m_dir.magnitude / m_duration; } m_dir.Normalize(); m_targetID = targetId; m_targetGetTimer = 0; }
// Start is called before the first frame update void Start() { rb = GetComponent <Rigidbody2D>(); tr = GetComponent <Transform>(); playerReference = GameObject.Find("PlayerGrass"); nextManureSpawnTime = Time.time + Random.Range(0, manureSpawnInterval); nextSpeedUpTime = Time.time + speedUpInterval; soundEffectParentObject = GameObject.Find("SoundEffects"); fxController = soundEffectParentObject.GetComponent <FXController>(); topSpriteAnim = gameObject.GetComponentInChildren <Animator>(); currentPoseNum = -1; NewPose(); }
/// <summary> /// 使用这个接口创建的特效无法自动播放第二次,第二次播放需啊哟手动调用.Start,慎用 /// </summary> /// <param name="filePath"></param> /// <returns></returns> public FXController CreateFxNonStart(string filePath) { GameObject go = PoolManager.Instance.Spawm(filePath, ClientCommon.AssetType.PFX, ClientCommon.AssetType.PFX.ToString()); if (AssertHelper.Check(go != null, filePath + " not exist!") == false) { return(null); } FXController fx = go.GetComponent <FXController>(); if (fx != null) { fx.GetComponent <FXController>().ResetFX(false); } return(fx); }
public FxPool(Transform root, GameObject template) { // Get FxController var fx = template.GetComponent <FXController>(); if (fx == null) { fx = template.AddComponent <FXController>(); fx.loop = true; fx.autoDestroy = true; } // Inactive template template.SetActive(false); // Attach template to root ObjectUtility.AttachToParentAndKeepLocalTrans(root, template.transform); this.root = root; this.template = fx; this.released = false; }
// Use this for initialization void Start() { //Initialize basic stuff fieldScript = GameObject.FindGameObjectWithTag("Field").GetComponent <MonoBehaviour>() as FieldController; fieldScript.gameControllerScript = this; nextSpeedIncreaseTime = speedIncreaseInterval; nextPushTime = pushInterval; fxControllerScript = GameObject.FindGameObjectWithTag("FX").GetComponent <MonoBehaviour>() as FXController; loadingScreen = GameObject.FindGameObjectWithTag("LoadingScreen"); //Initialize Mode specific stuff if (gameType == GameType.Endless) { roundUI.enabled = false; difficultyUI.enabled = false; difficultyValueUI.enabled = false; } else if (gameType == GameType.Arcade) { scoreUI.enabled = false; hiScoreUI.enabled = false; } }
public void Despawm(FXController fx) { if (released) { Object.Destroy(fx.Root.gameObject); } else { #if FX_POOL_METRICS despawmToPoolCount++; #endif // Reset data fx.ClearFinishCallback(); fx.SetFreeToLastPoolTime(Time.time); Debug.Assert(fx.Root.parent != root); // Return to pool ObjectUtility.AttachToParentAndResetLocalTrans(root, fx.Root); fx.Root.gameObject.SetActive(false); despawmFXs.Insert(0, fx); } }
////////////////////////////////////////////////////////////////////////// // Particle public void PlayPfx(FXController pfx, int destroyMode, int usd, string modelBone, string bone, bool boneFollow, Vector3 offset, Vector3 rotate, bool useSpecificPosition, Vector3 specificPosition) { avatarFx.PlayPfx(pfx, destroyMode, usd, modelBone, bone, boneFollow, offset, rotate, useSpecificPosition, specificPosition); }
// Start is called before the first frame update void Start() { anim = GetComponent <Animator>(); soundEffectParentObject = GameObject.Find("SoundEffects"); fxController = soundEffectParentObject.GetComponent <FXController>(); }
// Play Pfx. public void PlayPfx(FXController fx, int destroyMode, int userData, string modelBone, string bone, bool boneFollow, Vector3 offset, Vector3 rotate, bool useSpecificPosition, Vector3 specificPosition) { // Set Render layer /** * Bug 记录。 * * 对于魔化卫庄的组合技,这个技能在主Action中有目标选择,但是每一个伤害事件都有自己的目标选择,最终可能有一种情况,即所有的EventTargetRecord中的目标均不包含Action选择的目标 * 在主Action中配置了一些播放特效的事件,这些事件服务器不作处理,也不会发给客户端,而是由客户端自己根据配置文件构建,构建时使用ActionRecord的TargetAvtarIndexs里的AvatarIndex, * 指定的AvatarIndex可能不在任何EventTargetRecord中,所以SkillCombatRound在遮罩屏幕时不会将这个角色点亮,导致“由这个角色”释放的特效也没有被点亮 * * 修改逻辑,如果正处于屏幕遮罩中,那么所有的特效都有应该具有SceneMaskLayer */ //BattleScene bs = BattleScene.GetBattleScene(); //int Layer = 0; //if (bs != null && bs.IsEnableSceneMask) // Layer = GameDefines.SceneMaskLayer; //else Layer = avatar.gameObject.layer; int Layer = avatar.gameObject.layer; // Set Render layer fx.Root.gameObject.layer = Layer; foreach (var subObj in fx.Root.GetComponentsInChildren <Transform>()) { subObj.gameObject.layer = Layer; } // If bone follow, attach to this bone. if (boneFollow) { var attachingGO = fx.Root; // Try to find specified if (modelBone != "") { var modelBoneObj = ObjectUtility.FindChildObject(attachingGO, modelBone); if (modelBoneObj != null) { attachingGO = modelBoneObj; } } // If specify bone, to this bone. if (bone != "") { var boneGO = ObjectUtility.FindChildObject(avatar.AvatarObject, bone); if (boneGO == null) { Debug.LogWarning(string.Format("Can not find bone:{0} in avatar", bone)); } ObjectUtility.AttachToParentAndResetLocalPosAndRotation(boneGO, attachingGO); } // Has no specify bone, to the root bone. else { ObjectUtility.AttachToParentAndResetLocalPosAndRotation(avatar.CachedTransform, attachingGO); } } // If not bone follow, just play at this bone position. else { // If specify bone, use this bone position. if (bone != "") { var boneGO = ObjectUtility.FindChildObject(avatar.CachedTransform, bone); if (boneGO == null) { Debug.LogWarning(string.Format("Can not find bone:{0} in avatar", bone)); } ObjectUtility.UnifyWorldTrans(boneGO, fx.Root); } // Has specific transform, use the transform. else if (useSpecificPosition) { fx.Root.position = specificPosition; } // Has no specify bone, use the root bone position. else { ObjectUtility.UnifyWorldTrans(avatar.CachedTransform, fx.Root); } } fx.Root.Translate(offset); fx.Root.Rotate(rotate); if (destroyMode != AvatarAction.Effect._DestroyType.Normal) { // Add to dictionary. var fxInst = new FxInst(fx, destroyMode, userData); fxMap[fxInst.instanceId] = fxInst; // Set auto destroy flag to Pfx script. //FXController PfxScript = fx.GetComponentInChildren<FXController>(); //if (PfxScript != null) { fx.autoDestroy = true; // Pfx will not loop except buff. if (destroyMode == AvatarAction.Effect._DestroyType.Buff) { fx.loop = true; } if (destroyMode == AvatarAction.Effect._DestroyType.BlockAction) { fx.AddFinishCallback(PfxFinishedBb, fxInst); } } } }
// Use this for initialization void Start() { fxControllerScript = fieldScript.fxControllerScript; blockRenderer = this.GetComponentInParent <SpriteRenderer>(); }
/// <summary> /// /// </summary> /// <param name="parentObj"></param> /// <param name="effectData"></param> /// <param name="delPlayEffect"></param> /// <param name="param"></param> protected void AddEffect(GameObject parentObj, Tab_Effect effectData, PlayEffectDelegate delPlayEffect, object param) { if (null == effectData) { LogModule.ErrorLog("effectData is null"); if (null != delPlayEffect) { delPlayEffect(null, param); } return; } ChangeMaterialColor(effectData.Type); //已经存在 数量加1 if (m_EffectCountCache.ContainsKey(effectData.EffectID)) { m_EffectCountCache[effectData.EffectID] = m_EffectCountCache[effectData.EffectID] + 1; } //不存在 添加进去 数量为1 else { m_EffectCountCache.Add(effectData.EffectID, 1); } if (effectData.IsOnlyDeactive && m_dicEffectCache.ContainsKey(effectData.EffectID) && m_dicEffectCache[effectData.EffectID].Count > 0) { FXController curFXController = m_dicEffectCache[effectData.EffectID][0]; m_dicEffectCache[effectData.EffectID].RemoveAt(0); if (curFXController) { //区域特效单独处理 if (effectData.Type == (int)EEffectChangeType.TYPE_TARGETAREA) { Games.SkillModle.SkillCore.SkillTargetData targetData = param as Games.SkillModle.SkillCore.SkillTargetData; if (targetData != null) { if (targetData._hasSet) { curFXController.ChangePositionForAreaEffect(GetTargetAreaPos(targetData, curFXController.GetPosition())); } else { curFXController.ResetAreaEffect(); } } } curFXController.Play(this); } if (null != delPlayEffect) { delPlayEffect(curFXController.m_FirstChild, param); } return; } AddEffectData curData = new AddEffectData(parentObj, effectData, delPlayEffect, param); m_NeedPlayEffectIdCacheList.Add(effectData.EffectID); //凑活的方式 如果 该粒子没有在 GameObject resObj = ResourceManager.LoadResource(effectData.Path) as GameObject; if (null != resObj) { LoadEffectComplete(new LoadedObjData() { LoadedObj = resObj }, curData); return; } BundleManager.LoadEffectInQueue(effectData.EffectID, LoadEffectComplete, curData); }
protected void LoadEffectComplete(LoadedObjData resObj, AddEffectData parameter1) { AddEffectData curData = parameter1; if (curData == null) { return; } Object loadedObj = resObj.LoadedObj; if (loadedObj == null) { LogModule.ErrorLog("add effect error:"); if (null != curData._delPlayEffect) { curData._delPlayEffect(null, curData._param); } return; } if (null == curData._effectData) { LogModule.ErrorLog("effectData is null"); if (null != curData._delPlayEffect) { curData._delPlayEffect(null, curData._param); } return; } if (null == curData._parentObj) { LogModule.DebugLog("curData._parentObj is null"); if (null != curData._delPlayEffect) { curData._delPlayEffect(null, curData._param); } return; } if (!m_NeedPlayEffectIdCacheList.Contains(curData._effectData.EffectID)) { if (null != curData._delPlayEffect) { curData._delPlayEffect(null, curData._param); } return; } GameObject effectObj = GameObject.Instantiate(loadedObj) as GameObject; if (null == effectObj) { if (null != curData._delPlayEffect) { curData._delPlayEffect(null, curData._param); } return; } GameObject fxController = ResourceManager.InstantiateResource("Prefab/Effect/FXController") as GameObject; if (null == fxController) { GameObject.Destroy(effectObj); LogModule.ErrorLog("can't find prefab fxcontroller in Prefab/Effect/FXController"); return; } FXController controllerComponent = fxController.GetComponent <FXController>(); if (controllerComponent == null) { LogModule.ErrorLog("can not find fxcontroller on gameobject"); GameObject.Destroy(fxController); GameObject.Destroy(effectObj); if (null != curData._delPlayEffect) { curData._delPlayEffect(null, curData._param); } return; } controllerComponent.m_Path = resObj.Url; ResourcesManager.Instance.AddCachedRef(controllerComponent.m_Path, EResourceType.Effect); m_NeedPlayEffectIdCacheList.Remove(curData._effectData.EffectID); effectObj.SetActive(false); if (null != curData._parentObj) { Utils.SetParent(fxController.transform, curData._parentObj.transform); } Utils.SetParent(effectObj.transform, fxController.transform); effectObj.transform.localPosition = new Vector3(curData._effectData.X, curData._effectData.Y, curData._effectData.Z); effectObj.transform.localRotation = Quaternion.Euler(curData._effectData.RotationX, curData._effectData.RotationY, curData._effectData.RotationZ); if (curData._effectData.Type == (int)EEffectChangeType.TYPE_TARGETAREA) { //add 由目标位置确定的区域特效 Games.SkillModle.SkillCore.SkillTargetData targetData = curData._param as Games.SkillModle.SkillCore.SkillTargetData; if (targetData != null && targetData._hasSet) { Vector3 cacPos = effectObj.transform.position; cacPos = GetTargetAreaPos(targetData, cacPos); effectObj.transform.position = cacPos; } } controllerComponent.OnlyDeactivate = curData._effectData.IsOnlyDeactive; controllerComponent.Delay = curData._effectData.DelayTime; controllerComponent.Duration = curData._effectData.Duration; controllerComponent.EffectGameObj = m_EffectGameObj; controllerComponent.IsFellowOwner = curData._effectData.IsFellowOwner; controllerComponent.EffectID = curData._effectData.EffectID; controllerComponent.Play(this); //进行一些特效的额外索引 OnAddEffectComplete(curData); if (null != curData._delPlayEffect) { curData._delPlayEffect(effectObj, curData._param); } }