Пример #1
0
 public void OnUse(Diver diver, Room room)
 {
     if (coolDown <= 0)
     {
         room.AddEntity(new Bomb(diver.X, diver.Y));
         coolDown = 200;
     }
 }
Пример #2
0
 public void OnUse(Diver diver, Room room)
 {
     if (action == Action.None)
     {
         action = Action.Shooting;
         length = 0;
         direction = diver.FacingDirection;
     }
 }
Пример #3
0
        public void Draw(Graphics graphics, Diver diver)
        {
            if (action != Action.None)
            {
                int tipX = diver.X + diver.Width / 2 + length * direction;
                int tipY = diver.Y + diver.Height - 12;

                if (direction < 0)
                {
                    graphics.Begin();
                    graphics.Draw(texture, new Point(tipX, tipY - 4), new Rectangle(0, action == Action.Pulling ? 8 : 0, length, 8), Color.White);
                    graphics.End();
                }
                else
                {
                    graphics.Begin();
                    graphics.Draw(texture, new Rectangle(diver.X + diver.Width / 2, tipY - 4, length, 8), new Rectangle(0, action == Action.Pulling ? 8 : 0, length, 8), Color.White, 0.0f, Vector2.Zero, SpriteEffects.FlipHorizontally, 0.0f);
                    graphics.End();
                }
            }
        }
Пример #4
0
        public Sea(string name, 
            int width,
            int height,
            int firstRoomX,
            int firstRoomY)
        {
            Width = width;
            Height = height;
            Name = name;
            this.firstRoomX = firstRoomX;
            this.firstRoomY = firstRoomY;

            tileSet = new SpriteGrid(DiverGame.DefaultContent.Load<Texture2D>("tileset"), 4, 4);

            miniMap = new MiniMap(this);

            // To load new game...
            PreloadAllRooms(false);
            // or, to load a saved game (also preloads rooms)
            // LoadState();

            panel = DiverGame.DefaultContent.Load<Texture2D>("panel");

            speedyDiver = new SpeedyDiver();
            fattyDiver = new FattyDiver();
            tinyDiver = new TinyDiver();
            speedyDiver.X = 170;
            speedyDiver.Y = 224 - speedyDiver.Height;
            fattyDiver.X = 200;
            fattyDiver.Y = 224 - fattyDiver.Height;
            tinyDiver.X = 230;
            tinyDiver.Y = 224 - tinyDiver.Height;

            diver = speedyDiver;
            diver.Enabled = true;
            boat.AddEntity(fattyDiver);
            boat.AddEntity(tinyDiver);

            EnterBoat();
        }
Пример #5
0
 public void onDiverChange(Diver diver)
 {
     this.diver = diver;
 }
Пример #6
0
 public void Update(Diver diver, Room room, State s)
 {
     if(coolDown > 0) coolDown--;
 }
Пример #7
0
        public void Draw(Graphics graphics, Diver diver)
        {
            graphics.Begin();

            graphics.End();
        }
Пример #8
0
        public void Update(Diver diver, Room room, State s)
        {
            switch (action)
            {
                case Action.Shooting:
                    if (direction != diver.FacingDirection)
                    {
                        action = Action.Retracting;
                        break;
                    }

                    length += shootSpeed;
                    int tipX = diver.X + diver.Width / 2 + length * direction;
                    int tipY = diver.Y + diver.Height - 12;
                    if (room.TileMap.IsSolid(tipX / 16, tipY / 16))
                    {
                        diver.Freeze = true;
                        action = Action.Pulling;
                    }
                    else if (length > maxLength)
                    {
                        action = Action.Retracting;
                    }
                    break;

                case Action.Pulling:
                    length -= pullSpeed;
                    diver.Velocity = new Point(direction * pullSpeed * Diver.Resolution, 0);
                    diver.MoveWithCollision(room);
                    diver.JumpVelocity = 0;
                    if (length <= 0 || diver.Velocity.X == 0)
                    {
                        action = Action.None;
                        diver.Freeze = false;
                    }
                    break;

                case Action.Retracting:
                    length -= pullSpeed;
                    if (length <= 0)
                    {
                        action = Action.None;
                        diver.Freeze = false;
                    }
                    break;

                case Action.None:
                    break;
            }
        }