private void Awake() { if (instance == null) { instance = this; } }
protected override void StartSpell() { if (_spellInfo.spellEffectInfos != null && _spellInfo.spellEffectInfos.Count > 0) { transform.position = _spellInfo.spellEffectInfos[0].targetCharacter.position_pivot; } VFX wantedVFX = null; foreach (var effect in _spellInfo.spellEffectInfos) { if (_spellInfo.spellEffectInfos[0].effectOnCharacter == SpellEffectOnChar.Buff) { wantedVFX = Instantiate <VFX>(_healEffect); } else { wantedVFX = Instantiate <VFX>(_damageEffect); } wantedVFX.transform.position = effect.targetCharacter.position_pivot; wantedVFX.StartVfx(); } ApplySpellEffectsAndDestroyIt(); }
public static void PlayVFX(VFX vfx) { if (vfx == VFX.Paired) { Instance.pairVFX.Play(); } }
void Start() { vfx = GameObject.Find("VFX & SFX").GetComponent <VFX>(); // Tetirs Constructor if (vfx) { m_tetris = new Tetris(new BlockSpawner(blocks), vfx); } else { m_tetris = new Tetris(new BlockSpawner(blocks)); } // draw row line for (int i = 0; i <= Tetris.Height + Tetris.ExtraHeight - 1; i++) { var row = Instantiate(linePrefab, this.transform); row.positionCount = 2; row.SetPosition(0, new Vector3(-offset, i - offset)); row.SetPosition(1, new Vector3(Tetris.Width - offset, i - offset)); } // draw col line for (int i = 0; i <= Tetris.Width; i++) { var col = Instantiate(linePrefab, this.transform); col.positionCount = 2; col.SetPosition(0, new Vector3(i - offset, -offset)); col.SetPosition(1, new Vector3(i - offset, Tetris.Height + Tetris.ExtraHeight - 1 - offset)); } state = GameState.Pause; StartGame(); }
public void Vfx(string str, string vecstr, Character Char) { string[] vecstrs = vecstr.Split('/'); Vector3 vector = new Vector3(float.Parse(vecstrs[0]), float.Parse(vecstrs[1]), float.Parse(vecstrs[2])); VFX.ShowVFX(str, vector + Char.transform.localPosition); }
private void Awake() { _vfx = GetComponent <VFX>(); _rb = gameObject.GetComponent <Rigidbody2D>(); _sprite = GetComponent <SpriteRenderer>(); _collider2D = GetComponent <CircleCollider2D>(); _touchHandler = FindObjectOfType <TouchHandler>(); }
private void CreateVFX(VFX neededVFX, Vector3 pos, Vector3 scale) { _vfx = Instantiate(neededVFX); _vfx.transform.position = pos; _vfx.SetScale(scale); _vfx.StartVfx(OnEffectEnd); }
//public string[] VFXStr; public override void BuffAdded(Character p_chara, string str) { m_name = "stunned"; base.BuffAdded(p_chara, str); VFXGO = VFX.ShowVFX("Stunned", new Vector3(0f, 1f, 0f), p_chara); }
public override void BuffAdded(Character p_chara, string str) { m_name = "playVFX"; base.BuffAdded(p_chara, str); VFXStr = str.Split('/'); VFXGO = VFX.ShowVFX(VFXStr[0], new Vector3(float.Parse(VFXStr[1]), float.Parse(VFXStr[2]), float.Parse(VFXStr[3])), p_chara); }
public void PlayVFX(VFX vfx, Vector3 position) { if (!m_VFXToPrefabDictionary.ContainsKey(vfx)) { Debug.LogError("Missing VFX @ " + vfx); return; } StartCoroutine(PlayVFXCoroutine(vfx, position)); }
public void HandleChangingFlag(BattleFlags newFlags, BattleFlags previousFlags, Vector3 scale) { if (newFlags == previousFlags) { return; } _vfx = null; Vector3 pos = Vector3.zero; List <BattleFlags> newFlagList = new List <BattleFlags>(); List <BattleFlags> prevFlagList = new List <BattleFlags>(); foreach (BattleFlags flag in Enum.GetValues(typeof(BattleFlags))) { if ((newFlags & flag) == flag) { newFlagList.Add(flag); } if ((previousFlags & flag) == flag) { prevFlagList.Add(flag); } } foreach (BattleFlags nFlag in newFlagList) { if (!prevFlagList.Contains(nFlag)) { switch (nFlag) { case BattleFlags.Fear: _vfx = _fearEffect; pos = _tr_Helper_Fear.position; break; case BattleFlags.DamageReduction: _vfx = _damageReductionEffect; pos = _tr_Helper_Fear.position; break; case BattleFlags.DeathRattle: _vfx = _deathRattle; pos = transform.position; break; } } } if (_vfx != null) { CreateVFX(_vfx, pos, scale); } }
void Start() { VFX.Initialize(); ItemGenerator.Initialize(); GridManager.Initialize(); Synched.SetSeed(Random.Range(0, int.MaxValue)); GameManager.Initialize(); }
public void Awake() { if (_instance == null) _instance = this; else { Debug.Log("There are another instance of Effects"); Object.Destroy(this); } ConvertToDictionary(); }
private IEnumerator PlayVFXCoroutine(VFX vfx, Vector3 position) { GameObject spawnedPrefab = Instantiate(m_VFXToPrefabDictionary[vfx], transform); spawnedPrefab.transform.position = position; ParticleSystem particleSystem = spawnedPrefab.GetComponent <ParticleSystem>(); particleSystem.Play(true); yield return(new WaitForSeconds(particleSystem.main.duration + 0.5f)); Destroy(spawnedPrefab); }
public void Awake() { if (_instance == null) { _instance = this; } else { Debug.Log("There are another instance of Effects"); Object.Destroy(this); } ConvertToDictionary(); }
public void Vfx(string str, Character Char) { string name = ""; int father = 0; Vector3 pos = new Vector3(0, 0, 0); string[] vfxstrs = str.Split('&'); Vector3 scale = new Vector3(1f, 1f, 1f); GameObject VFXGO = null; foreach (string s in vfxstrs) { switch (s.Split(':')[0]) { case ("name"): name = s.Split(':')[1]; break; case ("father"): father = int.Parse(s.Split(':')[1]); break; case ("pos"): string[] posstrs = s.Split(':')[1].Split('/'); pos = new Vector3(float.Parse(posstrs[0]), float.Parse(posstrs[1]), float.Parse(posstrs[2])); break; case ("scale"): string[] sclstrs = s.Split(':')[1].Split('/'); scale = new Vector3(float.Parse(sclstrs[0]), float.Parse(sclstrs[1]), float.Parse(sclstrs[2])); break; } } if (father == 0) { VFXGO = VFX.ShowVFX(name, pos); } if (father == 1) { VFXGO = VFX.ShowVFX(name, pos, Char); } if (father == 2) { VFXGO = VFX.ShowVFX(name, pos, Char.mTarget.GetComponent <Character>()); } VFXGO.transform.localScale = new Vector3(VFXGO.transform.localScale.x * scale.x, VFXGO.transform.localScale.y * scale.y, VFXGO.transform.localScale.z * scale.z); }
//敌人死亡的时候从玩家的目标列表中去除,然后销毁模型和ui override public void Die() { base.Die(); gameObject.AddComponent <VFX>(); VFX vfx = gameObject.GetComponent <VFX>(); // Destroy(UIHpNum.transform.parent.gameObject); Player.Instance.enemyList.Remove(gameObject); vfx.StartCoroutine("FadeOut"); Player.Instance.money += lootMoney; UIBarController.Instance.ClearBarWarn(); Debug.Log("Enemy Die"); }
public virtual void Deactivate() { if (base.meshRenderer != null) { Material[] auxMaterials = base.meshRenderer.materials; auxMaterials[materialIndexToChange] = base.deactivatedMaterial; base.meshRenderer.materials = auxMaterials; } isActive = false; base.objectToActivate.Deactivate(); base.objectToActivate.Deactivate(gameObject); if (VFX != null) { VFX.SetActive(false); } }
void CreateNewInstances(int index) { var vfx = List[index]; for (int i = 0; i < poolSize; ++i) { VFX newVfx = new VFX(); var particles = Instantiate(vfx.effect); particles.SetActive(false); newVfx.effect = particles; newVfx.type = vfx.type; m_Pool[(int)vfx.type].Enqueue(newVfx); } }
public ParticleSystem Play(string name, Transform position) { VFX vfx = vfxEffects.Find(v => v.name.Equals(name)); ParticleSystem ps = null; if (vfx != null) { ps = vfx.Play(position); ps.transform.SetParent(this.transform); StartCoroutine(DisablePS(ps, vfx.time)); } else { Debug.LogWarning("El vfx no existe: " + name); } return(ps); }
public Asset Add(Asset asset) { Model m = (asset as Model); int index; if (m != null) { index = Models.Count; Models.Add(m); foreach (ModelBone bone in m.Bones) { switch (bone.Type) { case BoneType.Light: Light light = new Light(); light.LinkWith(bone); Entities.Add(light); break; case BoneType.VFX: VFX vfx = new VFX(); vfx.LinkWith(bone); Entities.Add(vfx); break; } } OnAdd?.Invoke(this, new AddEventArgs(asset, index)); } else { index = Materials.Entries.IndexOf(asset as Material); if (index == -1) { index = Materials.Entries.Count; Materials.Entries.Add(asset as Material); OnAdd?.Invoke(this, new AddEventArgs(asset, index)); } } return(asset); }
void Attack(string attackName, VFX VFX, int attackStringLength) { playerAnimator.SetTrigger(attackName); print("PlayerCombatController: attackName: " + attackName); if (VFX != null) { Instantiate(VFX, Player.transform.position + Vector3.up * 5, Player.transform.rotation); } //Ensure attack string index wraps around once all attacks have been completed. if (attackStringIndex < attackStringLength - 1) { attackStringIndex++; //playerAnimator.ResetTrigger(attackName); } else { attackStringIndex = 0; playerAnimator.ResetTrigger(attackName); } }
void CreateInstance(VFX vfx, Vector4 position, bool flip, Transform parent, TileBase tileOverride) { VFXInstancePool poolToUse = null; if (tileOverride == null || !vfx.vfxOverrideDictionnary.TryGetValue(tileOverride, out poolToUse)) { poolToUse = vfx.pool; } var instance = poolToUse.Pop(); instance.expires = Time.time + vfx.lifetime; if (flip) { instance.transform.localScale = new Vector3(-1, 1, 1); } else { instance.transform.localScale = new Vector3(1, 1, 1); } instance.parent = parent; instance.SetPosition(position); m_RunningFx.Push(instance); }
//Playing VFX from script public void PlayVFX(VFX vfx, Vector3 position, Vector3 rotation) { switch (vfx) { case VFX.Hit: if (VFXHit != null) { Instantiate(VFXHit, position, Quaternion.Euler(rotation.x, rotation.y, rotation.z)); } break; case VFX.TakeHit: if (VFXTakeHit != null) { Instantiate(VFXHit, position, Quaternion.Euler(rotation.x, rotation.y, rotation.z)); } break; case VFX.Jump: if (VFXJump != null) { Instantiate(VFXHit, position, Quaternion.Euler(rotation.x, rotation.y, rotation.z)); } break; case VFX.Dodge: if (VFXDodge != null) { Instantiate(VFXHit, position, Quaternion.Euler(rotation.x, rotation.y, rotation.z)); } break; default: break; } }
virtual public void Hit(int dDamage, bool noAfterattack = false, bool isDefenceToDisable = false, string penetrateEffstr = "", bool isDefencePenetrate = false, string sfxstr = "SLASH", string fxstr = "NORMAL") { //普通攻击目标 if (mTarget != null) { Character cTarget = mTarget.GetComponent <Character>(); bool ishit = true; //判断对方护盾 if (cTarget.HasBuff("defend")) { //破防 if (isDefencePenetrate) { if (penetrateEffstr == "1") { dDamage += 5; } VFX.ShowVFX("PierceHit", new Vector3(4f, 0f, -1f) + transform.localPosition); //todo:通用的破防音效 } else { //被防到硬直; if (isDefenceToDisable) { GameObject fxClone = Instantiate(Resources.Load("VFX/DefendBig"), cTarget.transform.position, Quaternion.identity) as GameObject; fxClone.transform.localScale = new Vector3(fxClone.transform.localScale.x * cTarget.transform.Find("pos_defendfx").transform.localScale.x, fxClone.transform.localScale.y, fxClone.transform.localScale.z); SoundController.Instance.PlayAudioEffect("PDEFEND"); isDefenced = true; } else { //被防住 GameObject fxClone = Instantiate(Resources.Load("VFX/Defend"), cTarget.transform.Find("pos_defendfx").transform.position, Quaternion.identity) as GameObject; fxClone.transform.localScale = new Vector3(3f * cTarget.transform.Find("pos_defendfx").transform.localScale.x, 3f, 3f); SoundController.Instance.PlayAudioEffect("DEFEND"); } //释放防御成功带的技能 string defskillstr = (cTarget.buffs.Find((Buff obj) => obj.m_name == "defend") as Buff_defend).EffStr; cTarget.CastSkill(defskillstr); //Debug.Log("防御成功附带技能:" + defskillstr); ishit = false; } } //反击 foreach (Buff b in cTarget.buffs) { bool iscountered = false; if (b.m_name == "counter") { ishit = false; (b as Buff_counter).CounterAction(); iscountered = true; } if (iscountered) { GameObject fxClone = Instantiate(Resources.Load("VFX/CounterHit"), cTarget.transform.Find("pos_defendfx").transform.position, Quaternion.identity) as GameObject; fxClone.transform.localScale = new Vector3(3f * cTarget.transform.Find("pos_defendfx").transform.localScale.x, 3f, 3f); SoundController.Instance.PlayAudioEffect("PDEFEND"); SuperController.Instance.ShowInputTip("Counter!"); } } //确定被击中时 if (ishit) { cTarget.GetComponent <VFX>().StartCoroutine("GetHit"); SoundController.Instance.PlayAudioEffect(sfxstr); cTarget.Damage(CalcDmg(getCurrentATK(), cTarget.getCurrentDEF(), dDamage), this); if (cTarget.isPlayer) { Camera.main.gameObject.transform.DOShakePosition(1, 0.5f); } } //执行BUFF中的攻击结束效果 if (!noAfterattack) { List <Buff> tempbuffs = new List <Buff>(); tempbuffs.AddRange(buffs); foreach (Buff b in tempbuffs) { b.AfterAttack(this); } } } //如过被防住了 触发效果 if (isDefenced) { IsDefended(); } // lastAction = actionType.Hit; }
private void Start() { if (Instance == null) Instance = this; }
public static void Emit(Vector3 point, Quaternion rotation, VFX VFX, int amount) { switch (VFX) { case VFX.SlimeDeath: // Hasn't been spawned yet. if (slimeDeath.loaded == false) { // Spawn and assign. //TODO: Move "Resources.Load" into here ---V slimeDeath.go = GameObject.Instantiate(slimeDeath.go); slimeDeath.ps = slimeDeath.go.GetComponent <ParticleSystem>(); slimeDeath.loaded = true; } slimeDeath.go.transform.localPosition = point; slimeDeath.go.transform.localRotation = rotation; slimeDeath.ps.Emit(amount); break; case VFX.ShadowBoltHit: // Hasn't been spawned yet. if (shadowBoltHit.loaded == false) { // Spawn and assign. shadowBoltHit.go = GameObject.Instantiate(shadowBoltHit.go); shadowBoltHit.ps = shadowBoltHit.go.GetComponentInChildren <ParticleSystem>(); shadowBoltHit.loaded = true; } shadowBoltHit.go.transform.localPosition = point; shadowBoltHit.go.transform.localRotation = rotation; shadowBoltHit.ps.Emit(amount); break; case VFX.Bats: if (bats.loaded == false) { bats.go = Resources.Load <GameObject>("FX/Bats"); bats.go = GameObject.Instantiate(bats.go); bats.ps = bats.go.GetComponent <ParticleSystem>(); bats.loaded = true; } bats.go.transform.localPosition = point; bats.go.transform.localRotation = rotation; bats.ps.Play(); break; case VFX.Coins: if (coins.loaded == false) { coins.go = Resources.Load <GameObject>("FX/Coins"); coins.go = GameObject.Instantiate(coins.go); coins.ps = coins.go.GetComponent <ParticleSystem>(); coins.loaded = true; } coins.go.transform.localPosition = point; coins.go.transform.localRotation = rotation; coins.ps.Emit(amount); break; case VFX.Stomp: if (stomp.loaded == false) { stomp.go = Resources.Load <GameObject>("FX/StompParticle"); stomp.go = GameObject.Instantiate(stomp.go); stomp.ps = stomp.go.GetComponent <ParticleSystem>(); stomp.loaded = true; } stomp.go.transform.localPosition = point; stomp.go.transform.localRotation = rotation; stomp.ps.Play(); break; } }
public Tetris(BlockSpawner spawner, VFX vfx) : this(spawner) { this.vfx = vfx; }
//Private Methods private void OnEffectEnd(VFX endedVFX) { Destroy(endedVFX.gameObject); }
//Playing VFX from animation public void PlayAnimationTriggeredVFX(string vfx) { VFX parsedEnumVFX = (VFX)System.Enum.Parse(typeof(VFX), vfx); switch (parsedEnumVFX) { case VFX.Attack1: if (VFXHit != null) { GameObject vfxInstance = Instantiate(VFXAttack1, VFXAttack1Spawn.position, VFXAttack1Spawn.rotation); vfxInstance.transform.SetParent(VFXHitSpawn); } break; case VFX.Attack2: if (VFXHit != null) { GameObject vfxInstance = Instantiate(VFXAttack2, VFXAttack2Spawn.position, VFXAttack2Spawn.rotation); vfxInstance.transform.SetParent(VFXHitSpawn); } break; case VFX.Attack3: if (VFXHit != null) { GameObject vfxInstance = Instantiate(VFXAttack3, VFXAttack3Spawn.position, VFXAttack3Spawn.rotation); vfxInstance.transform.SetParent(VFXHitSpawn); } break; case VFX.Attack4: if (VFXHit != null) { GameObject vfxInstance = Instantiate(VFXAttack4, VFXAttack4Spawn.position, VFXAttack4Spawn.rotation); vfxInstance.transform.SetParent(VFXHitSpawn); } break; case VFX.Hit: if (VFXHit != null) { GameObject vfxInstance = Instantiate(VFXHit, VFXHitSpawn.position, VFXHitSpawn.rotation); vfxInstance.transform.SetParent(VFXHitSpawn); } break; case VFX.TakeHit: if (VFXTakeHit != null) { Instantiate(VFXTakeHit, VFXTakeHitSpawn.position, VFXTakeHitSpawn.rotation); } break; case VFX.Jump: if (VFXJump != null) { Instantiate(VFXJump, VFXJumpSpawn.position, VFXJumpSpawn.rotation); } break; case VFX.Dodge: if (VFXDodge != null) { Instantiate(VFXDodgeSpawn, VFXDodgeSpawn.position, VFXDodgeSpawn.rotation); } break; default: break; } }
public static void OpenVehicle(string path) { SceneManager.Current.SetCoordinateSystem(CoordinateSystem.LeftHanded); SceneManager.Current.Reset(); string assetFolder = Path.GetDirectoryName(path); Model vehicle = (Model)SceneManager.Current.Add(SceneManager.Current.Content.Load <Model, CNTImporter>(Path.GetFileName(path), assetFolder)); // Load supporting documents if (File.Exists(Path.Combine(assetFolder, "setup.lol"))) { vehicle.SupportingDocuments["Setup"] = Setup.Load(Path.Combine(assetFolder, "setup.lol")); } if (File.Exists(Path.Combine(assetFolder, "Structure.xml"))) { List <string> findMaterials(StructurePart part) { List <string> materials = new List <string>(); materials.AddRange(part.DamageSettings.Methods.Where(m => m.Name == "CrushDamageMaterial" && m.HasBeenSet).Select(m => m.Parameters[2].Value.ToString())); foreach (StructurePart child in part.Parts) { materials.AddRange(findMaterials(child)); } return(materials); } Structure structure = Structure.Load(Path.Combine(assetFolder, "Structure.xml")); foreach (string material in findMaterials(structure.Root)) { SceneManager.Current.Content.Load <Material, MT2Importer>(material, assetFolder, true); } vehicle.SupportingDocuments["Structure"] = structure; } if (File.Exists(Path.Combine(assetFolder, "SystemsDamage.xml"))) { vehicle.SupportingDocuments["SystemsDamage"] = SystemsDamage.Load(Path.Combine(assetFolder, "SystemsDamage.xml")); } if (File.Exists(Path.Combine(assetFolder, "vehicle_setup.cfg"))) { vehicle.SupportingDocuments["VehicleSetupConfig"] = VehicleSetupConfig.Load(Path.Combine(assetFolder, "vehicle_setup.cfg")); foreach (VehicleMaterialMap materialMap in vehicle.GetSupportingDocument <VehicleSetupConfig>("VehicleSetupConfig").MaterialMaps) { foreach (KeyValuePair <string, string> kvp in materialMap.Substitutions) { SceneManager.Current.Content.Load <Material, MT2Importer>(kvp.Value, assetFolder, true); } } } if (File.Exists(Path.Combine(assetFolder, "vehicle_setup.lol"))) { vehicle.SupportingDocuments["VehicleSetup"] = VehicleSetup.Load(Path.Combine(assetFolder, "vehicle_setup.lol")); } if (File.Exists(Path.Combine(assetFolder, "vfx_anchors.lol"))) { vehicle.SupportingDocuments["VFXAnchors"] = VFXAnchors.Load(Path.Combine(assetFolder, "vfx_anchors.lol")); } if (File.Exists(Path.Combine(assetFolder, "collision.cnt"))) { vehicle.SupportingDocuments["Collision"] = SceneManager.Current.Content.Load <Model, CNTImporter>("collision.cnt", assetFolder); } if (File.Exists(Path.Combine(assetFolder, "opponent_collision.cnt"))) { vehicle.SupportingDocuments["OpponentCollision"] = SceneManager.Current.Content.Load <Model, CNTImporter>("opponent_collision.cnt", assetFolder); } //if (File.Exists(assetFolder + "CrashSoundsConfig_Car.xml")) { vehicle.SupportingDocuments["SystemsDamage"] = SystemsDamage.Load(assetFolder + "SystemsDamage.xml"); } foreach (ModelBone bone in vehicle.Bones) { string boneName = bone.Name.ToLower(); // Name = bone.Name if (boneName.StartsWith("wheel_")) { Core.Entities.Wheel wheel = new Core.Entities.Wheel(); wheel.LinkWith(bone); SceneManager.Current.Entities.Add(wheel); } else if (boneName.StartsWith("vfx_")) { VFX vfx = new VFX(); vfx.LinkWith(bone); SceneManager.Current.Entities.Add(vfx); } else if (boneName.StartsWith("driver")) { Driver driver = new Driver(); driver.LinkWith(bone); SceneManager.Current.Entities.Add(driver); } } SceneManager.Current.SetContext("Carmageddon Max Damage", ContextMode.Car); }