魔法是驅動時間的力量
也是物質 能量 時空的根本
我們所處的宇宙
所在的星系
所站的大地
全部源自由魔法構成的系統
其實用這個系統的SDK和system call
來操控世間萬物的developer
就是大家說的魔法使
像是大家都很喜歡的爆裂魔法
大概就是一段長這樣的code:
using Universe;
using Universe.Antimatter;
using Universe.Constant;
using Universe.Matter;
using Universe.TimeSpace;
using Magic.FireMagic;
using Magic.Magica.Human;
using Magic.Mana;
namespace FireMagic
{
public class Explosion : FireMagicBase
{
/// <summary>
/// 人類用的爆裂魔法:
/// 召喚反氫氣並導入特定的時空引起爆炸
/// </summary>
Antimatter h_antimatter;
Volume antimatterVol;
TimeSpace targetTs;
public Explosion(TimeSpace ts, double radius) :
base(FireMagicLevel.Advanced, FireMagicType.Circle, radius)
{
targetTs = ts;
h_antimatter = Antimatter.AntimatterFactory(Matter.H, MatterPhase.STPGas, MatterCharge.Balanced);
h_antimatter.SetMassByEnergy(base.MaxEnergy);
h_antimatter.SetBackGroundTimeSpace(ts);
antimatterVol = Antimatter.CountVolume(h_antimatter);
ManaCost = base.ManaCost;
ManaCost += h_antimatter.ManaCost;
ManaCost += targetTs.ManaCostToCreateCopy(antimatterVol);
ManaCost += targetTs.ManaCostToFreeze(antimatterVol);
ManaCost += targetTs.ManaCostToSwap(antimatterVol);
ManaCost += targetTs.ManaCostToResume(antimatterVol);
CoolDown = base.CoolDown;
CoolDown += h_antimatter.CoolDown;
CoolDown += targetTs.CreateCopyCoolDown(antimatterVol);
CoolDown += targetTs.FreezeCoolDown(antimatterVol);
CoolDown += targetTs.SwapCoolDown(antimatterVol);
CoolDown += targetTs.ResumeCoolDown(antimatterVol);
}
public double ManaCost
{
get;
protected set;
}
public double CoolDown
{
get;
protected set;
}
public override void Cast(Human caster, Vector4F target)
{
UniversalMana mana = UniversalMana.UniversalManaFactory(caster, ManaCost);
if(mana == null)
throw new NotEnoughManaException();
TimeSpace castAt = targetTs.GetSubTimeSpace(target, antimatterVol);
TimeSpace _castAt = TimeSpace.TimeSpaceFactory(mana, castAt);
try {
h_antimatter.CreateAntimatter(mana, _castAt);
castAt.Freeze(mana);
targetTs.Swap(mana, castAt, _castAt);
castAt.Resume(mana);
}
catch(CoolingDownException e) {
throw e;
}
catch(Exception e) {
if(Human.CanHandle(e)) {
throw e;
}
}
finally {
caster.SendMessage("EXPLOSION!!!!!");
}
}
}
}
魔法師使用這個魔法時
要先建立一個爆裂魔法的執行個體
Explosion h_ex = new Explosion(TimeSpace.LocalTimeSpace, 100);
接著呼叫其中的施放方法
h_ex.Cast(this, Samsung.LocationOnEarth.ToUniversalCoord());
就能快樂的使用爆裂魔法啦~
話說如果有Exception也沒關係
反正Exception跟Explosion也差不了多少