protected override bool Trigger() { Vector3 origin = Skill.Caster.Avatar.GetBindPosition(Bind); RaycastHit hit; if (Physics.Raycast(origin, Skill.Caster.Dir, out hit, MaxDis)) { Collider col = hit.collider; if (HitEffectID > 0) { EffectUnit unit = GTWorld.Instance.Ect.LoadEffect(HitEffectID, 0, KTransform.Create(hit.point, Vector3.zero), null, true); unit.Release(HitEffectDuration); } CharacterView view = col.GetComponent <CharacterView>(); if (view != null) { if (Skill.Caster.Match(Affect, view.Owner)) { for (int i = 0; i < Children.Count; i++) { Children[i].ApplyHitPoint = hit.point; Children[i].ApplyHitDir = Vector3.up; Children[i].ClearAttackList(); Children[i].AddInAttackList(view.Owner); } End(); } } } return(base.Trigger()); }
protected override bool MakeResult(Character cc) { if (cc == null) { return(false); } EffectUnit unit = null; if (World) { Transform p = cc.Avatar.GetBindTransform(Bind); unit = GTWorld.Instance.Ect.LoadEffect(ID, 0, Retain); unit.CacheTransform.parent = p; unit.CacheTransform.localPosition = Offset; unit.CacheTransform.localEulerAngles = Euler; unit.CacheTransform.parent = null; unit.CacheTransform.localScale = Scale; } else { Transform p = cc.Avatar.GetBindTransform(Bind); unit = GTWorld.Instance.Ect.LoadEffect(ID, 0, KTransform.Create(Offset, Euler, Scale), p, Retain); } unit.Release(Duration); return(true); }
public EffectUnit LoadEffect(int id, ulong guid, bool retain = true) { EffectUnit tab = new EffectUnit(id, guid, KTransform.Default, null, retain); Effects[tab.GUID] = tab; return(tab); }
public void Update() { while (addCache.Count > 0) { MapUnit unit = addCache[0]; addCache.RemoveAt(0); switch (unit.unittype) { case UnitType.creature: if (!creatureUnits.ContainsKey(unit.id)) { creatureUnits.Add(unit.id, unit); } break; case UnitType.effect: if (!effectUnits.ContainsKey(unit.id)) { effectUnits.Add(unit.id, unit); } break; } } foreach (var c in creatureUnits) { if (CheckIsMoved(c.Value as CircleMapUnit)) { c.Value.next = c.Value.positon + c.Value.speed; } else { c.Value.next = c.Value.positon; } } foreach (var e in effectUnits) { e.Value.next = e.Value.positon + e.Value.speed; } foreach (var e in effectUnits) { Group sg = e.Value.unit.Group; foreach (var c in creatureUnits) { if (c.Value.unit.Group != sg && IsCollided(e.Value, c.Value)) { EffectUnit effectunit = e.Value.unit as EffectUnit; if (!effectunit.IsContainKey(c.Value.id)) { effectunit.AddUnit(c.Value.id); } } } } //view }
public EffectUnit LoadEffect(int id, ulong guid, KTransform data, Transform parent, bool retain = true) { EffectUnit tab = new EffectUnit(id, guid, data, parent, retain); Effects[tab.GUID] = tab; return(tab); }
static void Main(string[] args) { Serializer ser = new Serializer(); Trait xmlTrait = ser.Deserialize <Trait>("trait.xml"); EffectCity xmlEffectCity = ser.Deserialize <EffectCity>("effectCity.xml"); EffectPlayer xmlEffectPlayer = ser.Deserialize <EffectPlayer>("effectPlayer.xml"); EffectUnit xmlEffectUnit = ser.Deserialize <EffectUnit>("effectUnit.xml"); // Load Trait.xml, then load other XMLs // Look for trait in city, player, unit. // If found, add to output obj OldWorldXmlParser parser = new OldWorldXmlParser(); var vals = parser.GetArchtypeMetadata(); foreach (var key in vals) { Console.WriteLine(key.Key); foreach (var val in key.Value) { Console.WriteLine($"{val.Key} + {val.Value}"); } } Console.Read(); }
protected override bool MakeResult(Character cc) { EffectUnit unit = null; if (cc == null) { return(false); } Transform p = cc.Avatar.GetBindTransform(Bind); unit = GTWorld.Instance.Ect.LoadEffect(ID, 0, Retain); unit.CacheTransform.parent = p; unit.CacheTransform.localPosition = Offset; unit.CacheTransform.localEulerAngles = Euler; unit.CacheTransform.parent = null; unit.Release(Duration); ActTree item = Clone <ActTree>(this); item.Skill = this.Skill; item.StTime = 0; item.EdTime = 0; item.Clear(); for (int i = 0; i < item.Children.Count; i++) { item.Children[i].ApplyCenter = unit.CacheTransform; item.Children[i].ApplyHitPoint = unit.CacheTransform.position; } GTWorld.Instance.Act.Run(item); return(true); }
public override void Exit() { if (Unit != null) { Unit.Release(); Unit = null; } }
public virtual void Release() { if (mUnit != null) { mUnit.Release(); mUnit = null; } }
public override void Enter() { if (World) { Transform p = Carryer.Avatar.GetBindTransform(Bind); Unit = GTWorld.Instance.Ect.LoadEffect(ID, 0, Retain); Unit.CacheTransform.parent = p; Unit.CacheTransform.localPosition = Offset; Unit.CacheTransform.localEulerAngles = Euler; Unit.CacheTransform.parent = null; Unit.CacheTransform.localScale = Scale; Unit.CacheTransform.localEulerAngles = Euler + Carryer.Euler; } else { Transform p = Carryer.Avatar.GetBindTransform(Bind); Unit = GTWorld.Instance.Ect.LoadEffect(ID, 0, KTransform.Create(Offset, Euler, Scale), p, Retain); } }
public Dictionary <string, Dictionary <string, object> > GetArchtypeMetadata() { var retDict = new Dictionary <string, Dictionary <string, object> >(); Serializer ser = new Serializer(); Trait xmlTrait = ser.Deserialize <Trait>("trait.xml"); EffectCity xmlEffectCity = ser.Deserialize <EffectCity>("effectCity.xml"); EffectPlayer xmlEffectPlayer = ser.Deserialize <EffectPlayer>("effectPlayer.xml"); EffectUnit xmlEffectUnit = ser.Deserialize <EffectUnit>("effectUnit.xml"); var listOfArchtypes = GetArchtypes(xmlTrait); foreach (var archtype in listOfArchtypes) { var traitEntry = xmlTrait.Entries.First(a => a.Name.Contains(archtype)); var archtypeStats = new Dictionary <string, object>(); // LeaderEffectPlayer - EffectPlayer (applies global) // GeneralEffectUnit - EffectUnit (applies bonuses to the unit it is controlling.) // LeaderEffectUnit - EffectUnit (not sure) // GovernorEffectCity - EffectCity (governor) if (traitEntry.LeaderEffectPlayer != null) { //var newdict = GetLeaderEffectPlayer(zealotEntry, xmlEffectPlayer); var effPlayerEntry = xmlEffectPlayer.Entries.First(a => a.zType == traitEntry.LeaderEffectPlayer); var newdict = GetKeyValuesFromXml(effPlayerEntry); archtypeStats = archtypeStats.Concat(newdict).ToDictionary(x => x.Key, x => x.Value); } if (traitEntry.GeneralEffectUnit != null) { var effPlayerEntry = xmlEffectUnit.Entries.First(a => a.zType == traitEntry.GeneralEffectUnit); var newdict = GetKeyValuesFromXml(effPlayerEntry); archtypeStats = archtypeStats.Concat(newdict).ToDictionary(x => x.Key, x => x.Value); } if (traitEntry.LeaderEffectUnit != null) { var effPlayerEntry = xmlEffectUnit.Entries.First(a => a.zType == traitEntry.LeaderEffectUnit); var newdict = GetKeyValuesFromXml(effPlayerEntry); archtypeStats = archtypeStats.Concat(newdict).ToDictionary(x => x.Key, x => x.Value); } if (traitEntry.GovernorEffectCity != null) { var effPlayerEntry = xmlEffectCity.Entries.First(a => a.zType == traitEntry.GovernorEffectCity); var newdict = GetKeyValuesFromXml(effPlayerEntry); archtypeStats = archtypeStats.Concat(newdict).ToDictionary(x => x.Key, x => x.Value); } List <string> removeProcessedKeys = new List <string>(); Dictionary <string, object> postProcessDict = new Dictionary <string, object>(); // Post process elements. foreach (var stat in archtypeStats) { if (stat.Key.Contains("EffectCity")) { var entry = xmlEffectCity.Entries.First(a => a.zType == (string)stat.Value); var childValues = GetKeyValuesFromXml(entry); foreach (var childval in childValues) { postProcessDict[childval.Key] = childval.Value; } removeProcessedKeys.Add("EffectCity"); } } removeProcessedKeys.ForEach(a => archtypeStats.Remove(a)); archtypeStats = archtypeStats.Concat(postProcessDict).ToDictionary(x => x.Key, x => x.Value); retDict[archtype] = archtypeStats; } return(retDict); }