public override bool Activate(SpellCursor cursor) { SpellVar value = cursor.Load <SpellVar>(this.index); if (value != null) { cursor.Annotate(value); } return(true); }
public override bool Activate(SpellCursor cursor) { int targetIndex = 0; foreach (SpellGlyph param in cursor.Parameters) { if (param is MarkerGlyph) { targetIndex = (param as MarkerGlyph).Index; break; } } cursor.Annotate(cursor.Load <SpellVar>(targetIndex)); return(true); }
public override bool Activate(SpellCursor cursor) { cursor.Annotate(this.Select(cursor)); return(true); }
public override bool Activate(SpellCursor cursor) { float baseEnergy = this.GetEnergyConsumption(); float usedEnergy = cursor.BoundTo.DrainEnergy(baseEnergy); Vector2 boundPos = cursor.BoundTo.Pos; PositionVar posVar = cursor.GetAnnotation <PositionVar>(); ObjectVar objVar = cursor.GetAnnotation <ObjectVar>(); ObjectVar selectedObjects = new ObjectVar(); if (objVar != null) { var weightedPos = objVar.Elements.Select(e => new { Weight = e.Weight, Interactor = e.Interactor, Pos = e.Interactor.Pos }); foreach (var p in weightedPos) { float energyMult = Spell.GetEfficiency((p.Pos - boundPos).Length) * p.Weight / objVar.Count; foreach (T magic in this.Create(p.Pos, usedEnergy * energyMult)) { ICmpSpellInteractor interactor = magic.GameObj.GetComponent <ICmpSpellInteractor>(); if (interactor != null) { selectedObjects.Add(interactor, energyMult); } } } } else if (posVar != null) { Vector2 targetPos = posVar.Position; float energyMult = Spell.GetEfficiency((targetPos - boundPos).Length); foreach (T magic in this.Create(posVar.Position, usedEnergy * energyMult)) { ICmpSpellInteractor interactor = magic.GameObj.GetComponent <ICmpSpellInteractor>(); if (interactor != null) { selectedObjects.Add(interactor, energyMult); } } } else { foreach (T magic in this.Create(boundPos, usedEnergy)) { ICmpSpellInteractor interactor = magic.GameObj.GetComponent <ICmpSpellInteractor>(); if (interactor != null) { selectedObjects.Add(interactor); } } } if (selectedObjects.Count > 0.0f) { cursor.Annotate(selectedObjects); } return(true); }