Ejemplo n.º 1
0
        // 將 buffer 往 vector 移動一格.
        // camera 也會更著移動.
        public void MoveForward(Vector2D vector)
        {
            // remove line.
            Dimention dimention = Dimention.Null;
            int       value     = 0;

            switch (vector)
            {
            case Vector2D.Up:
                dimention = Dimention.Y;
                value     = center.Y.value - extra;
                break;

            case Vector2D.Down:
                dimention = Dimention.Y;
                value     = center.Y.value + extra;
                break;

            case Vector2D.Left:
                dimention = Dimention.X;
                value     = center.X.value + extra;
                break;

            case Vector2D.Right:
                dimention = Dimention.X;
                value     = center.X.value - extra;
                break;
            }

            RemoveLine(dimention, value);


            // move bufferCenter and camera.
            this.center.MoveFor(vector, 1);
            //        GameObjectMove(camera, Convert(vector));


            // add line.
            Point2D point = this.center.Copy();

            point.MoveFor(vector, extra);
            vector = VectorConvert.Rotate(vector);
            point.MoveFor(vector, extra);
            vector = VectorConvert.Invert(vector);

            AddLine(point, vector, Width);
        }
Ejemplo n.º 2
0
        public void Horizon()
        {
            ep.Add(-20);
            if (ep.IsZero)
            {
                return;
            }

            Point2D  targetPosition = this.posit.Copy();
            Vector2D targetVector   = this.Vect;

            if (GlobalAsset.player != null && this.Plain.Dimention == GlobalAsset.player.Plain.Dimention)
            {
                SkillManager.showSkill(Skill.horizon, this);
            }
            else
            {
                SkillManager.showSkill(Skill.attack, this);
            }

            targetPosition.MoveFor(targetVector, 1);
            targetVector = VectorConvert.Rotate(targetVector);
            targetPosition.MoveFor(targetVector, 2);
            targetVector = VectorConvert.Invert(targetVector);

            for (int i = 0; i < 3; ++i)
            {
                targetPosition.MoveFor(targetVector, 1);
                Grid targetGrid = World.GetAt(targetPosition.Binded);

                if (targetGrid == null)
                {
                    continue;
                }
                if (targetGrid.Obj == null)
                {
                    continue;
                }

                if (targetGrid.Obj is Attackable)
                {
                    Attackable target = (Attackable)targetGrid.Obj;
                    target.BeAttack(this);
                }
            }
        }
Ejemplo n.º 3
0
        // 漫無目的亂走.
        private void Wander()
        {
            Vector2D targetVector = RandomVector(10);

            for (int i = 0; i < 4; ++i)
            {
                Point2D target = this.posit.Copy();
                target.MoveFor(targetVector, 1);
                Grid targetGrid = World.GetAt(target.Binded);

                if (targetGrid != null && (targetGrid.IsEmpty() || targetGrid.Obj is Food))
                {
                    break;
                }
                else
                {
                    targetVector = VectorConvert.Rotate(targetVector);
                }
            }


            moveCommamd = Convert(targetVector);
        }
Ejemplo n.º 4
0
        // 在家附近巡邏.不會離太遠.
        private void Patrol(Creater home)
        {
            Point2D  temp   = this.posit.Copy();
            Vector2D target = RandomVector(10);

            for (int i = 0; i < 4; ++i)
            {
                temp.MoveFor(target, 1);
                if (temp.DistanceTo(home.position) > patrolDist)
                {
                    temp.MoveFor(target, -1);
                    target = VectorConvert.Rotate(target);
                }
                else
                {
                    moveCommamd = Convert(target);
                    return;
                }
            }

            skillCommand = SkillCommand.None;
            patrolDist   = this.posit.DistanceTo(home.position);
        }
Ejemplo n.º 5
0
 // 將 Maze 的座標轉成 Unity 的座標.
 private static Vector2 Convert(Point2D point)
 {
     return(VectorConvert.Convert(point));
 }
Ejemplo n.º 6
0
 // 將 Maze 的方向轉成 Unity 的方向.
 private static Vector2 Convert(Vector2D vector)
 {
     return(VectorConvert.Convert(vector));
 }