void RandamMove()
        {
            var toVect2D = new IntVect2D[] {
                new IntVect2D(movableCount, 0),
                new IntVect2D(-movableCount, 0),
                new IntVect2D(0, movableCount),
                new IntVect2D(0, -movableCount)
            };

            //移動可能範囲を取得
            toVect2D = toVect2D.Shuffle();
            foreach (var toV in toVect2D)
            {
                RequestMoveFromVect2D(toV);
                if (isDone == true)
                {
                    break;
                }
            }
            if (isDone == false)
            {
                isDone = true;
                if (OnCompleteMove != null)
                {
                    OnCompleteMove();
                }
            }
        }
        //攻撃範囲に近づくように移動
        void MoveForApproach()
        {
            var toVect2D = new IntVect2D[] {
                new IntVect2D(movableCount, 0),
                new IntVect2D(-movableCount, 0),
                new IntVect2D(0, movableCount),
                new IntVect2D(0, -movableCount)
            };

            toVect2D = toVect2D.Shuffle();
            List <VectAndDistance> vectAndDistance = new List <VectAndDistance>();

            //各移動後における攻撃範囲と敵キャラとの最小距離取得
            foreach (var toV in toVect2D)
            {
                vectAndDistance.Add(new VectAndDistance(GetDistanceInAttackRange(IntVect2D.Add(character.positionArray, toV)), toV));
            }

            //距離が小さい順に移動試行
            foreach (var toV in vectAndDistance.OrderBy(v => v.distance).Select(v => v.vect))
            {
                RequestMoveFromVect2D(toV);
                if (isDone == true)
                {
                    break;
                }
            }
        }
        //移動後攻撃範囲にいたら移動
        bool TryMoveInAttackRange()
        {
            var toVect2D = new IntVect2D[] {
                new IntVect2D(movableCount, 0),
                new IntVect2D(-movableCount, 0),
                new IntVect2D(0, movableCount),
                new IntVect2D(0, -movableCount)
            };

            //移動可能範囲を取得
            toVect2D = toVect2D.Shuffle();
            foreach (var toV in toVect2D)
            {
                if (CheckExistInAttackRange(IntVect2D.Add(character.positionArray, toV)))
                {
                    RequestMoveFromVect2D(toV);
                }
                if (isDone == true)
                {
                    return(true);
                }
            }
            return(false);
        }
Пример #4
0
 //移動後攻撃範囲にいたら移動
 bool TryMoveInAttackRange()
 {
     var toVect2D = new IntVect2D[] {
         new IntVect2D(movableCount, 0),
         new IntVect2D(-movableCount, 0),
         new IntVect2D(0, movableCount),
         new IntVect2D(0, -movableCount)
     };
     //移動可能範囲を取得
     toVect2D = toVect2D.Shuffle();
     foreach (var toV in toVect2D)
     {
         if (CheckExistInAttackRange(IntVect2D.Add(character.positionArray,toV)))
         {
             RequestMoveFromVect2D(toV);
         }
         if (isDone == true)return true;
     }
     return false;
 }
Пример #5
0
 void RandamMove()
 {
     var toVect2D = new IntVect2D[] {
         new IntVect2D(movableCount, 0),
         new IntVect2D(-movableCount, 0),
         new IntVect2D(0, movableCount),
         new IntVect2D(0, -movableCount)
     };
     //移動可能範囲を取得
     toVect2D = toVect2D.Shuffle();
     foreach (var toV in toVect2D)
     {
         RequestMoveFromVect2D(toV);
         if (isDone == true)
         {
             break;
         }
     }
     if (isDone == false)
     {
         isDone = true;
         if (OnCompleteMove != null) OnCompleteMove();
     }
 }
Пример #6
0
        //攻撃範囲に近づくように移動
        void MoveForApproach()
        {
            var toVect2D = new IntVect2D[] {
                new IntVect2D(movableCount, 0),
                new IntVect2D(-movableCount, 0),
                new IntVect2D(0, movableCount),
                new IntVect2D(0, -movableCount)
            };

            toVect2D = toVect2D.Shuffle();
            List<VectAndDistance> vectAndDistance = new List<VectAndDistance>();
            //各移動後における攻撃範囲と敵キャラとの最小距離取得
            foreach (var toV in toVect2D)
            {
                vectAndDistance.Add(new VectAndDistance(GetDistanceInAttackRange(IntVect2D.Add(character.positionArray, toV)), toV));
            }

            //距離が小さい順に移動試行
            foreach (var toV in vectAndDistance.OrderBy(v => v.distance).Select(v=>v.vect))
            {
                RequestMoveFromVect2D(toV);
                if (isDone == true)
                {
                    break;
                }

            }
        }