Esempio n. 1
0
 public Instruction.Result Unpack()
 {
     // if (!Unpacker) return Instruction.Result.ERROR;
     Instruction.Result result = Instruction.Result.ERROR;
     if (container is GridContainer)
     {
         GridContainer target = null;
         GridContainer from   = (GridContainer)container;
         result = from.QueryAdjacentContainer(antOri, ref target);
         if (result == Instruction.Result.SUCCEED)
         {
             if (!target.Compatible(this))
             {
                 return(Instruction.Result.INCOMPATIBLE);
             }
             result = from.TryUnpack(this);
             if (result == Instruction.Result.SUCCEED)
             {
                 from.Release(this);
                 target.Contain(this);
                 target.HoleCheck();
                 from.TargetCheck();
             }
         }
     }
     return(result);
 }
Esempio n. 2
0
 public Instruction.Result Move(Orientation oriVal)
 {
     if (type == Type.Ant && antOri != oriVal)
     {
         return(Instruction.Result.INVALID_ANT_MOVE);
     }
     Instruction.Result result = Instruction.Result.ERROR;
     if (container is GridContainer)
     {
         GridContainer target = null;
         GridContainer from   = (GridContainer)container;
         result = from.QueryAdjacentContainer(oriVal, ref target);
         if (result == Instruction.Result.SUCCEED)
         {
             if (!target.Compatible(this))
             {
                 return(Instruction.Result.INCOMPATIBLE);
             }
             from.Release(this);
             target.Contain(this);
             target.HoleCheck();
         }
     }
     return(result);
 }