Exemple #1
0
        public double time; //Calculated value, how long it takes to make one trip along the elevator surface.

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="s">The sprite</param>
        /// <param name="walls">The list of level blocks in the level</param>
        /// <param name="l">The level this belongs to</param>
        public Elevatorbot(Texture2D s, List<LevelBlock> walls, LevelState l)
            : base(s, walls, l)
        {
            animatorSet = false;
            isElevating = false;
            attachedSurface = null;
            type = InteractorType.elevatorbot;
            platform = new MovingPlatform(new BoundingBox(), l, new Point(-1, -1), new Point(-1, -1), MovingPlatformRotationType.Bouncing);
            ledge = new MovingHangingLedge(new BoundingBox(), l, TextureLoader.grayblock, new Point(-1, -1), true);
        }
 private void btnCreateBlock_Click(object sender, EventArgs e)
 {
     switch ((DrawableType)cbxBlockTypes.SelectedItem)
     {
         case DrawableType.controlPanel:
             ControlPanel controlPanel = new ControlPanel(new BoundingBox(new Vector3(0, 0, 0), new Vector3(20, 20, 0)), state, null, null);
             lstBlocks.Items.Add(controlPanel);
             state.interactables.Add(controlPanel);
             break;
         case DrawableType.elevatorSurface:
             ElevatorSurface elevatorSurface = new ElevatorSurface(new BoundingBox(new Vector3(0, 0, 0), new Vector3(20, 50, 0)), state, null, true, new Vector2(10, 50), new Vector2(10, 0));
             lstBlocks.Items.Add(elevatorSurface);
             state.interactables.Add(elevatorSurface);
             break;
         case DrawableType.hangingLedge:
             HangingLedge hangingLedge = new HangingLedge(new BoundingBox(new Vector3(0, 0, 0), new Vector3(20, 20, 0)), state, null, new Microsoft.Xna.Framework.Point(20, 0), true);
             lstBlocks.Items.Add(hangingLedge);
             state.interactables.Add(hangingLedge);
             break;
         case DrawableType.movingHangingLedge:
             MovingHangingLedge movingHangingLedge = new MovingHangingLedge(new BoundingBox(new Vector3(0, 0, 0), new Vector3(20, 20, 0)), state, null, new Microsoft.Xna.Framework.Point(20, 0), true);
             lstBlocks.Items.Add(movingHangingLedge);
             state.interactables.Add(movingHangingLedge);
             break;
         case DrawableType.movingPlatform:
             MovingPlatform movingPlatform = new MovingPlatform(new BoundingBox(new Vector3(0, 0, 0), new Vector3(50, 50, 0)), state, new Microsoft.Xna.Framework.Point(25, 25), new Microsoft.Xna.Framework.Point(75, 25), MovingPlatformRotationType.Bouncing);
             lstBlocks.Items.Add(movingPlatform);
             state.walls.Add(movingPlatform);
             break;
         case DrawableType.pressurePlate:
             PressurePlate pressurePlate = new PressurePlate(new BoundingBox(new Vector3(0, 0, 0), new Vector3(50, 25, 0)), state, null, null);
             lstBlocks.Items.Add(pressurePlate);
             state.interactables.Add(pressurePlate);
             break;
         case DrawableType.rust:
             Rust rust = new Rust(new BoundingBox(new Vector3(0, 0, 0), new Vector3(50, 50, 0)), state);
             lstBlocks.Items.Add(rust);
             state.walls.Add(rust);
             break;
         case DrawableType.slope:
             Slope slope = new Slope(state, new Microsoft.Xna.Framework.Point(0, 50), new Microsoft.Xna.Framework.Point(50, 0));
             lstBlocks.Items.Add(slope);
             state.walls.Add(slope);
             break;
         case DrawableType.wall:
             Wall wall = new Wall(new BoundingBox(new Vector3(0, 0, 0), new Vector3(50, 50, 0)), state);
             wall.Sprite = state.wall;
             lstBlocks.Items.Add(wall);
             state.walls.Add(wall);
             break;
         case DrawableType.doodad:
             Doodad doodad = new Doodad(null, new Vector2(0, 0));
             lstBlocks.Items.Add(doodad);
             state.doodads.Add(doodad);
             break;
         case DrawableType.animatedDoodad:
             AnimatedDoodad animatedDoodad = new AnimatedDoodad(null, 50, 50, 2, 1, true, 1000, new Vector2(0, 0));
             lstBlocks.Items.Add(animatedDoodad);
             state.doodads.Add(animatedDoodad);
             break;
     }
 }
 public static ElevatorSurface ReadElevatorSurface(BinaryReader reader, LevelEditState l)
 {
     ElevatorSurface e = new ElevatorSurface(new BoundingBox(Vector3.Zero, Vector3.Zero), l, null, true, new Vector2(0,0), new Vector2(0,0));
     e.MinX = reader.ReadSingle();
     e.MinY = reader.ReadSingle();
     e.MaxX = reader.ReadSingle();
     e.MaxY = reader.ReadSingle();
     e.StartX = reader.ReadSingle();
     e.StartY = reader.ReadSingle();
     e.EndX = reader.ReadSingle();
     e.EndY = reader.ReadSingle();
     e.isRight = reader.ReadBoolean();
     byte b = reader.ReadByte();
     if (b == 22)
         e.Sprite = l.importedTextures[reader.ReadInt16()];
     b = reader.ReadByte();
     if (b == 22)
         e.Name = reader.ReadString();
     return e;
 }
Exemple #4
0
 /// <summary>
 /// This will dock the bot with the player after it is finished for whatever reason.
 /// </summary>
 /// <param name="p">The player this belongs to</param>
 public override void Dock(Player p)
 {
     //base.Dock(p); Method needs to be defined in the abstract?
     isElevating = false;
     attachedSurface = null;
 }
Exemple #5
0
 /// <summary>
 /// This will fire when the elevatorbot collides with an elevator surface, and will initiate the elevation procedure.
 /// It is called from the surface, not from within this bot.
 /// </summary>
 /// <param name="s">The surface it is colliding with.</param>
 public void elevate(ElevatorSurface s)
 {
     attachedSurface = s;
     lengthX = s.EndX - s.StartX;
     lengthY = s.EndY - s.StartY;
     time = lengthY / ELEVATING_SPEED_PIXELS_PER_SECOND;
     platform.SecondsPerCycle = (float)time;
     platform.MinX = hitBox.Min.X;
     platform.MinY = hitBox.Min.Y;
     platform.MaxX = hitBox.Max.X;
     platform.MaxY = hitBox.Max.Y;
     platform.BeginX = (int)attachedSurface.StartX;
     platform.BeginX = (int)attachedSurface.StartY;
     platform.EndX = (int)attachedSurface.StartX;
     platform.EndY = (int)attachedSurface.EndY;
     if (isRight)
     {
         ledge.PosX = hitBox.Min.X;
         ledge.PosY = hitBox.Min.Y;
         ledge.MinX = hitBox.Min.X - 5;
         ledge.MinY = hitBox.Min.Y;
         ledge.MaxX = hitBox.Min.X + 5;
         ledge.MaxY = hitBox.Min.Y + 5;
     }
     else
     {
         ledge.PosX = hitBox.Max.X;
         ledge.PosY = hitBox.Min.Y;
         ledge.MinX = hitBox.Max.X - 5;
         ledge.MinY = hitBox.Min.Y;
         ledge.MaxX = hitBox.Max.X + 5;
         ledge.MaxY = hitBox.Min.Y + 5;
     }
     time *= 1000;
     isRight = true;
 }