예제 #1
0
            public void Blast(Level l)
            {
                if (Death)
                {
                    return;
                }

                Position p = l.GetSpritePosition(this);

                for (int y = p.y - 1; y <= p.y + 1; y++)
                {
                    for (int x = p.x - 1; x <= p.x + 1; x++)
                    {
                        if ((x > 0) && (x < 19) && (y > 0) && (y < 13))
                        {
                            if (l.GetSprite(x, y).GetType() == typeof(Digger))
                            {
                                Digger d = (Digger)l.GetSprite(x, y);
                                l.Digger.Die();
                            }
                            else
                            {
                                if (l.GetSprite(x, y).GetType().BaseType == typeof(Ghost))
                                {
                                    Ghost g = (Ghost)l.GetSprite(x, y);
                                    g.Die();
                                    l.Score += 99;
                                }

                                l.SetSprite(x, y, new Nothing());
                            }
                        }
                    }
                }

                Die();
            }
예제 #2
0
            public void Simulate(Level l, int x, int y)
            {
                int dx = x;
                int dy = y;

                // Nothing
                if (l.GetSprite(x, y + 1).GetType() == typeof(Nothing))
                {
                    dy = y + 1;
                }
                else
                {
                    // Stone or diamond
                    if ((l.GetSprite(x, y + 1).GetType() == typeof(Stone)) || (l.GetSprite(x, y + 1).GetType() == typeof(Diamond)))
                    {
                        if (l.GetSprite(x - 1, y + 1).GetType() == typeof(Nothing) && l.GetSprite(x - 1, y).GetType() == typeof(Nothing))
                        {
                            dx = x - 1;
                            dy = y + 1;
                        }
                        else
                        {
                            if (l.GetSprite(x + 1, y + 1).GetType() == typeof(Nothing) && l.GetSprite(x + 1, y).GetType() == typeof(Nothing))
                            {
                                dx = x + 1;
                                dy = y + 1;
                            }
                        }
                    }

                    // Changer
                    if ((l.GetSprite(x, y + 1).GetType() == typeof(Changer)) && (l.GetSprite(x, y).GetType() == typeof(Stone)) && (l.GetSprite(x, y + 2).GetType() == typeof(Nothing)))
                    {
                        dy = y + 2;
                    }
                }

                // Mark
                if ((dx != x) || (dy != y))
                {
                    l.SetSprite(dx, dy, new Marker());
                }
            }
예제 #3
0
            public void Move(Level l)
            {
                if (dead)
                {
                    return;
                }

                Position p = l.GetSpritePosition(this);
                Position d = new Position(p);
                Position z = new Position(d);

                direction = Directions.None;
                if (Keys[0])
                {
                    z.x--; direction = Directions.Left;
                }
                else
                {
                    stone[0] = false;
                    if (Keys[1])
                    {
                        z.x++; direction = Directions.Right;
                    }
                    else
                    {
                        stone[1] = false;
                        if (Keys[2])
                        {
                            z.y--; direction = Directions.Up;
                        }
                        else
                        {
                            if (Keys[3])
                            {
                                z.y++; direction = Directions.Down;
                            }
                        }
                    }
                }

                if (!d.Equal(z))
                {
                    // Nothing
                    if (l.GetSprite(z.x, z.y).GetType() == typeof(Nothing))
                    {
                        l.SetSprite(d.x, d.y, this);
                    }

                    // Diamond
                    if (l.GetSprite(z.x, z.y).GetType() == typeof(Diamond))
                    {
                        l.Collected += 1;
                        l.Score     += 3;
                    }

                    // Stone
                    if (l.GetSprite(z.x, z.y).GetType() == typeof(Stone))
                    {
                        if ((z.x > d.x) && (l.GetSprite(z.x + 1, z.y).GetType() == typeof(Nothing)))
                        {
                            if (stone[1])
                            {
                                l.SetSprite(d.x + 2, d.y, l.GetSprite(d.x + 1, d.y));
                                l.SetSprite(d.x + 1, d.y, new Nothing());
                            }
                            stone[1] = !stone[1];
                        }

                        if ((z.x < d.x) && (l.GetSprite(z.x - 1, z.y).GetType() == typeof(Nothing)))
                        {
                            if (stone[0])
                            {
                                l.SetSprite(d.x - 2, d.y, l.GetSprite(d.x - 1, d.y));
                                l.SetSprite(d.x - 1, d.y, new Nothing());
                            }
                            stone[0] = !stone[0];
                        }
                    }

                    // Ground
                    if (l.GetSprite(z.x, z.y).GetType() == typeof(Nothing) ||
                        l.GetSprite(z.x, z.y).GetType() == typeof(Ground) ||
                        l.GetSprite(z.x, z.y).GetType() == typeof(Diamond))
                    {
                        l.SetSprite(z.x, z.y, this);
                        l.SetSprite(d.x, d.y, new Buffer());
                    }

                    // Exit
                    if (l.GetSprite(z.x, z.y).GetType() == typeof(Exit))
                    {
                        l.Exit();
                    }

                    // Ghost
                    if (l.GetSprite(z.x, z.y).GetType().BaseType == typeof(Ghost))
                    {
                        l.Digger.Die();
                    }
                }

                Animate(l, z.x, z.y);
            }
예제 #4
0
            public override void Move(Level l)
            {
                if (Death)
                {
                    return;
                }

                Position p = l.GetSpritePosition(this);

                Position[] w = { new Position(p), new Position(p), new Position(p), new Position(p) };

                if (Direction == Directions.Left)
                {
                    w[0].x--; w[1].y--; w[2].y++; w[3].x++;
                }
                if (Direction == Directions.Right)
                {
                    w[0].x++; w[1].y++; w[2].y--; w[3].x--;
                }
                if (Direction == Directions.Up)
                {
                    w[0].y--; w[1].x++; w[2].x--; w[3].y++;
                }
                if (Direction == Directions.Down)
                {
                    w[0].y++; w[1].x--; w[2].x++; w[3].y--;
                }

                for (int i = 0; i < 4; i++)
                {
                    if (!p.Equal(w[i]))
                    {
                        Position d = new Position(w[i]);

                        // Digger
                        if (l.GetSprite(d.x, d.y).GetType() == typeof(Digger))
                        {
                            l.Digger.Die();
                        }

                        // Nothing
                        if (l.GetSprite(d.x, d.y).GetType() == typeof(Nothing))
                        {
                            if (d.x < p.x)
                            {
                                Direction = Directions.Left;
                            }
                            if (d.x > p.x)
                            {
                                Direction = Directions.Right;
                            }
                            if (d.y < p.y)
                            {
                                Direction = Directions.Up;
                            }
                            if (d.y > p.y)
                            {
                                Direction = Directions.Down;
                            }

                            l.SetSprite(d.x, d.y, this);
                            l.SetSprite(p.x, p.y, new Nothing());

                            return;
                        }
                    }
                }
            }
예제 #5
0
            public void Move(Level l, int x, int y)
            {
                int dx = x;
                int dy = y;

                // Follow gravitation
                if (l.GetSprite(x, y + 1).GetType() == typeof(Marker))
                {
                    dy = y + 1;
                }
                else
                {
                    // Falls to the left or to the right
                    if (l.GetSprite(x, y + 1).GetType() == typeof(Stone) || l.GetSprite(x, y + 1).GetType() == typeof(Diamond) || l.GetSprite(x, y + 1).GetType() == typeof(Nothing))
                    {
                        if (l.GetSprite(x - 1, y + 1).GetType() == typeof(Marker) && (l.GetSprite(x - 1, y).GetType() == typeof(Nothing) || l.GetSprite(x - 1, y).GetType() == typeof(Marker)))
                        {
                            dx = x - 1;
                            dy = y + 1;
                        }
                        else
                        {
                            if (l.GetSprite(x + 1, y + 1).GetType() == typeof(Marker) && (l.GetSprite(x + 1, y).GetType() == typeof(Nothing) || l.GetSprite(x + 1, y).GetType() == typeof(Marker)))
                            {
                                dx = x + 1;
                                dy = y + 1;
                            }
                        }
                    }

                    // Changer
                    if (l.GetSprite(x, y + 1).GetType() == typeof(Changer) && l.GetSprite(x, y).GetType() == typeof(Stone) && l.GetSprite(x, y + 2).GetType() == typeof(Marker))
                    {
                        dy = y + 2;
                    }
                }

                // Move
                if ((dx != x) || (dy != y))
                {
                    if ((dy - y) == 2)
                    {
                        // changer
                        l.SetSprite(dx, dy, new Diamond());
                    }
                    else
                    {
                        l.SetSprite(dx, dy, l.GetSprite(x, y));
                        if (l.GetSprite(dx, dy).GetType() == typeof(UvStone))
                        {
                            l.SetSprite(dx, dy, new Stone());
                        }
                    }

                    l.SetSprite(x, y, new Nothing());

                    // Kill digger if necessary
                    if (l.GetSprite(dx, dy + 1).GetType() == typeof(Digger))
                    {
                        l.Digger.Die();
                    }

                    if (l.GetSprite(dx, dy + 1).GetType().BaseType == typeof(Ghost))
                    {
                        Ghost g = (Ghost)l.GetSprite(dx, dy + 1);
                        g.Blast(l);
                    }
                }
            }