示例#1
0
文件: Game.cs 项目: joelhoro/JHLib
 public override void Evolve(Level level, Action action)
 {
     if (action == Action.UP || action == Action.DOWN)
         base.Evolve(level, this.action);
 }
示例#2
0
文件: Game.cs 项目: joelhoro/JHLib
        public void Start()
        {
            level = new Level(9,3);
            level.actors.Add(new Player(0, 1));
            level.actors.Add(new Target(8, 1));

            int[,] actors = new int[,] { { 2, 0 }, {2,1},{ 3, 1 }, { 4, 1 }, { 5, 1 }, {6,1},{ 6, 0 }, { 4,2 } };
            for(int i = 0; i <= actors.GetUpperBound(0); i++)
                level.actors.Add(new Actor(actors[i,0],actors[i,1]));

            level.actors.Add(new Arrow(1, 0, Action.UP));
            GameActionEvent += level.ActionHandler;

            if (GameStartEvent != null) GameStartEvent(this, EventArgs.Empty);
        }
示例#3
0
文件: Game.cs 项目: joelhoro/JHLib
 public virtual void Evolve(Level level, Action action)
 {
 }
示例#4
0
文件: Game.cs 项目: joelhoro/JHLib
        public override void Evolve(Level level, Action action)
        {
            switch (action)
            {
                case Action.DOWN:
                    y--;
                    break;
                case Action.UP:
                    y++;
                    break;
                case Action.LEFT:
                    x--;
                    break;
                case Action.RIGHT:
                    x++;
                    break;
            }

            x = Math.Min(Math.Max(x, 0), level.Width-1);
            y = (y+level.Height) % level.Height;
            return;
        }
示例#5
0
文件: Game.cs 项目: joelhoro/JHLib
 public void DrawBorder(Level level)
 {
     var border = new Rectangle();
     border.Width = WIDTH_PIXELS * level.Width;
     border.Height = HEIGHT_PIXELS * level.Height;
     border.Stroke = Brushes.Black;
     Canvas.SetTop(border, 0);
     Canvas.SetLeft(border, 0);
     canvas.Children.Add(border);
 }
示例#6
0
文件: Game.cs 项目: joelhoro/JHLib
        public void Draw(Level level, Actor actor)
        {
            var actorshape = new Ellipse();
            actorshape.Height = HEIGHT_PIXELS * CIRCLE_PERCENTAGE;
            actorshape.Width = WIDTH_PIXELS * CIRCLE_PERCENTAGE;

            actorshape.Fill = ActorColor(actor);

            Canvas.SetTop(actorshape, HEIGHT_PIXELS * (0.5 * (1-CIRCLE_PERCENTAGE) + (level.Height -1- actor.y)));
            Canvas.SetLeft(actorshape, WIDTH_PIXELS * (0.5 * (1 - CIRCLE_PERCENTAGE) + actor.x));

            canvas.Children.Add(actorshape);
        }
示例#7
0
文件: Game.cs 项目: joelhoro/JHLib
 public void Draw(Level level)
 {
     canvas.Children.Clear();
     DrawBorder(level);
     foreach (var actor in level.actors)
         Draw(level, actor);
 }