Esempio n. 1
0
 public void think(BattleMaster bm)
 {
     forget();
     this.bm=bm;
     cells=bm.getCells;
     // filterCells("replace","*","");
     // filterCells("markChess","*","chess");
     // return;
     switch(type){
     case"ai":
     from=null;
     to=null;
     card=null;
     cells=bm.getCells;
     command="";
     //統計我方可行動人員資料
     var arr=chessFilter(bm.getChesses,"myParty");
     var list=new List<Move>();
     foreach(var e in arr){
         // Debug.Log("daab");
         for(var i=0;i<e.numMove;i++)list.Add(new Move(e,"move"));
         for(var i=0;i<e.numAttack;i++)list.Add(new Move(e,"attack"));
         for(var i=0;i<e.numSummon;i++)list.Add(new Move(e,"summon"));
         for(var i=0;i<e.numSkill;i++)list.Add(new Move(e,"skill"));
         for(var i=0;i<e.numUltimate;i++)list.Add(new Move(e,"ultimate"));
     }
     //若無可行動人員則結束回合
     if(list.Count<1||tryErrror>100){
         command="endTurn";
         // Debug.Log("endTurn");
         return;
     }
     //隨機選擇一個行動
     Move move=U.choose(list.ToArray()) as Move;
     var chessSel=move.chess;
     if(chessSel==null)return;
     //選擇打誰
     var chessTarget=chooseChess("nearestEnemy",chessSel.cell);
     if(chessTarget==null)return;
     //清空Cells tag
     filterCells("replace","*","");
     //根據不同指令作分歧
     msg=move.command;
     switch(move.command){
     case"attack":
         //判斷可否攻擊此名最近敵人
         if(Cell.Distance(chessSel.cell,chessTarget.cell)<2){
             // sDebug.Log(Cell.Distance(chessSel.cell,chessTarget.cell));
             from=chessSel.cell;
             to=chessTarget.cell;
             command="attack";
             tryErrror=0;
         }else tryErrror++;
         // chessSel.cell
         break;
     case"summon":
         // Debug.Log("ddd");
         card=new Card();
         from=chessSel.cell;
         to=find("nearest",cellFilterMove(chessSel.cell,1),chessTarget.cell);
         command="magic";
         tryErrror=0;
         break;
     case"move":
         //尋找離目標最近的cell
         from=chessSel.cell;
         to=find("nearest",cellFilterMove(chessSel.cell,1),chessTarget.cell);
         command="move";
         tryErrror=0;
         // Debug.Log(cellFilterMove(chessSel.cell,1).Length);
         break;
     }
     break;
     case"player":
     to=bm.to;
     from=bm.from;
     card=bm.card;
     command=bm.command;
     break;
     }
 }
Esempio n. 2
0
 void Awake()
 {
     control=GetComponent<TRNTH.Control>();
     bm=GetComponent<Master.BattleMaster>();
 }