public void StopEffect(FC_GLOBAL_EFFECT effId) { List <LivingEffect> tobeRemoveEffects = new List <LivingEffect>(); foreach (LivingEffect livingEff in _livingEffects) { if (livingEff._effID == (int)effId) { EffectInstance go = livingEff._effect; go.LifeTick = -1; go.DeadTick = -1; go.FinishEffect(true); go.myTransform.parent = _myRoot; go.gameObject.SetActive(false); tobeRemoveEffects.Add(livingEff); } } //remove living effects foreach (LivingEffect livingEff in tobeRemoveEffects) { _livingEffects.Remove(livingEff); } tobeRemoveEffects.Clear(); }
//play effect with ID at pos and rot public EffectInstance PlayEffect(FC_GLOBAL_EFFECT effId, Vector3 effPos, Quaternion effRot, Vector3 scale) { EffectInstance eff = PlayEffect(effId, effPos, effRot); if (eff != null) { eff.myTransform.localScale = scale; } return(eff); }
public void Init() { _active = false; //get block and get parameters Blockade blockAde = gameObject.GetComponent <Blockade>(); Assertion.Check(blockAde != null); _prefabName = blockAde._gateForGame; _fadeoutSfxName = blockAde._fadeinSfxName; _fadeinSfxName = blockAde._fadeinSfxName; _fadeoutEffect = blockAde._fadeoutEffect; }
private GameObject AddEffectToPool(FC_GLOBAL_EFFECT effId) { if (_myRoot == null) { _myRoot = Utils.NewGameObjectWithParent("Global_Effect_Root"); } GameObject instance = GameObject.Instantiate(_globalEffectPrefab[(int)effId]) as GameObject; instance.transform.parent = _myRoot; instance.transform.localPosition = Vector3.zero; instance.transform.localRotation = Quaternion.identity; instance.SetActive(false); return(instance); }
public void PlayEffect(int part) { if (part >= FCConst.GLOBAL_EFFECT_START) { //I am playing a global effect //play global effect from part id FC_GLOBAL_EFFECT effId = (FC_GLOBAL_EFFECT)(part - (int)FCConst.GLOBAL_EFFECT_START); switch (effId) { case FC_GLOBAL_EFFECT.BASH: //get blade track pos Transform trans = Utils.FindTransformByNodeName(_thisTransform, "A"); if (trans == null) { Debug.LogError("no weapon blade track!(" + gameObject.name + ")"); } Vector3 pos = trans.position; //set height from my foot pos.y = _thisTransform.position.y; GlobalEffectManager.Instance.PlayEffect(effId, pos); break; case FC_GLOBAL_EFFECT.BORN: // from current character's position. Vector3 bornPos = _thisTransform.localPosition; GlobalEffectManager.Instance.PlayEffect(effId, bornPos); break; case FC_GLOBAL_EFFECT.BLOOD: // from current character's position. Vector3 bloodPos = GetSlotNode(EnumEquipSlot.belt).position; GlobalEffectManager.Instance.PlayEffect(effId, bloodPos); break; default: Assertion.Check(false, "try to play a invalid global effect"); break; } } }
protected override void InstantiatePool() { base.InstantiatePool(); _myRoot = LevelManager.Singleton.GlobalEffectRoot; _allEffectArray = new Dictionary <FC_GLOBAL_EFFECT, List <EffectInstance> >(); for (FC_GLOBAL_EFFECT i = FC_GLOBAL_EFFECT.START; i < FC_GLOBAL_EFFECT.MAX; i++) { _allEffectArray[i] = new List <EffectInstance>(); } //we have enough global effects? Assertion.Check(_globalEffectList.GetLength(0) == (int)FC_GLOBAL_EFFECT.MAX, "not enough global effects"); //preload prefabs _globalEffectPrefab = new List <GameObject>(); foreach (string effPath in _globalEffectList) { GameObject instance = InJoy.AssetBundles.AssetBundles.Load(effPath, typeof(GameObject)) as GameObject; _globalEffectPrefab.Add(instance); } // init 4 instances for each effect. for (FC_GLOBAL_EFFECT i = FC_GLOBAL_EFFECT.START; i < FC_GLOBAL_EFFECT.MAX; ++i) { List <EffectInstance> list = _allEffectArray[i]; for (int j = 0; j < 4; ++j) { GameObject go = AddEffectToPool(i); EffectInstance ei = go.GetComponent <EffectInstance>(); Assertion.Check(ei != null); ei.global_effect_id = i; list.Add(ei); } } }
public void PlayEffect(FC_GLOBAL_EFFECT effId, Vector3 effPos) { PlayEffect(effId, effPos, Quaternion.identity); }
public EffectInstance PlayEffect(FC_GLOBAL_EFFECT effId, Vector3 effPos, Quaternion effRot) { if (effId == FC_GLOBAL_EFFECT.INVALID) { return(null); } //get empty gameobject? List <EffectInstance> effList = _allEffectArray[effId]; EffectInstance effResult = null; if (effList.Count > 0) { foreach (EffectInstance effInst in effList) { if (!effInst.gameObject.activeSelf) { effResult = effInst; break; } } } //no empty? create one if (effResult == null) { if (effList.Count == FCConst.GLOBAL_EFFECT_COUNT) { //already full, select a slot which is nearly dead effList.Sort(Compare); EffectInstance slot = effList[0]; EffectInstance effTemp = slot; if (effTemp != null) { //recycle back to pool effTemp.LifeTick = effTemp._lifeTime; effTemp.FinishEffect(true); slot.gameObject.SetActive(false); effResult = slot; } } else { //size is not full, add a new one GameObject ego = AddEffectToPool(effId); effResult = ego.GetComponent <EffectInstance>(); Assertion.Check(effResult != null); effResult.global_effect_id = effId; effList.Add(effResult); } } //set enable and pos Assertion.Check(effResult != null); effResult.gameObject.SetActive(true); Transform effectRsltTransform = effResult.myTransform; effectRsltTransform.position = effPos; effectRsltTransform.rotation = effRot; //add to living list LivingEffect liveEff = new LivingEffect(); liveEff._effect = effResult; liveEff._avatar = null; liveEff._effID = (int)effId; _livingEffects.Add(liveEff); //get effect instanse and start effect EffectInstance eff = effResult; if (eff != null) { eff.LifeTick = eff._lifeTime; eff.DeadTick = eff._deadTime; eff.BeginEffect(); } return(effResult); }
public override void AttackEnter() { base.AttackEnter(); _iceGround = _iceGround0; if (SkillData.CurrentLevelData.effect == 1) { _iceGround = _iceGround1; } else if (SkillData.CurrentLevelData.effect == 2) { _iceGround = _iceGround2; } _controlBySelf = false; _step = 0; Vector3 dir = Vector3.zero; if (_owner.KeyAgent.keyIsPress(FC_KEY_BIND.DIRECTION)) { dir = _owner.KeyAgent._directionWanted; _controlBySelf = true; _owner.ACOwner.SetAniMoveSpeedScale(-_aniMoveSpeedScale); } else if (_owner.ACOwner.IsClientPlayer) { dir = _owner.ThisTransform.forward; _controlBySelf = true; _owner.ACOwner.SetAniMoveSpeedScale(-_aniMoveSpeedScale); } /*else if(_owner.ParryTarget != null) * { * dir = _owner.ParryTarget.ThisTransform.position - _owner.ACOwner.ThisTransform.position; * dir.y = 0; * dir.Normalize(); * }*/ else if (CheatManager.flashMode == 2) { _controlBySelf = true; dir = _owner.ACOwner.ThisTransform.forward; _owner.ACOwner.SetAniMoveSpeedScale(-_aniMoveSpeedScale); } else { dir = _owner.ThisTransform.forward; } _sourcePos = _owner.ACOwner.ThisTransform.localPosition; if (dir != Vector3.zero) { _owner.ACOwner.ACRotateToDirection(ref dir, true); if (_currentBindKey != FC_KEY_BIND.NONE) { if (!_owner.KeyAgent.keyIsPress(FC_KEY_BIND.DIRECTION)) { _owner.KeyAgent._directionWanted = dir; } } } _owner.ParryTarget = null; if (_owner.ACOwner.IsClientPlayer) { _owner._updateAttackPos = true; _owner._attackMoveSpeed = 2; } _owner.SetActionSwitchFlag(FC_ACTION_SWITCH_FLAG.CANT_ROTATE); _owner.ACOwner.CanAcceptTimeScale = true; _owner.ACOwner.ACEnableCollisionWithOtherACS(false); _currentState = AttackBase.ATTACK_STATE.STEP_1; //BeginEffect(); }