作者sunup5566 (日上56)
看板C_Chat
標題Re: [問題] 所謂的魔法究竟是指什麼
時間Sun Oct 23 23:58:02 2016
魔法是驅動時間的力量
也是物質 能量 時空的根本
我們所處的宇宙
所在的星系
所站的大地
全部源自由魔法構成的系統
其實用這個系統的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也差不了多少
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 123.0.209.41
※ 文章網址: https://www.ptt.cc/bbs/C_Chat/M.1477238285.A.E50.html
推 hermis: 不要這樣wwww 10/23 23:58
推 Doracacazin: 哭了 10/23 23:59
推 SuperSg: 快推,不然別人會以為我看的懂 10/23 23:59
※ 編輯: sunup5566 (123.0.209.41), 10/24/2016 00:00:40
推 greenslime: 除了最後一行都看不懂wwwwww 10/24 00:00
推 norta: 偷婊三星 很好 10/24 00:01
推 tw15: 不要在.Cast裡面放進Samsung啦XD 10/24 00:01
※ 編輯: sunup5566 (123.0.209.41), 10/24/2016 00:02:16
→ ts1993: 偷裱三星 10/24 00:03
喔乾 少一個分號
※ 編輯: sunup5566 (123.0.209.41), 10/24/2016 00:09:39
推 GeogeBye: 寫這麼長一篇 給個推 雖然我看不懂 10/24 00:17
推 alanqq0624: 總而言之先推 10/24 00:24
推 suhorng: 好 10/24 06:02