Example #1
0
        public void push(Robot.Direction dir)
        {
            Dir = dir;

            switch (dir)
            {
            case Robot.Direction.Down:
                vel.Y = speed;
                vel.X = 0;
                break;

            case Robot.Direction.Up:
                vel.Y = -speed;
                vel.X = 0;
                break;

            case Robot.Direction.Right:
                vel.X = speed;
                vel.Y = 0;
                break;

            case Robot.Direction.Left:
                vel.X = -speed;
                vel.Y = 0;
                break;
            }

            Point tileToCheck = Robot.Adjacent(Center, dir);

            if (game.GameScreen.stage.PassableLayer[tileToCheck.X, tileToCheck.Y])
            {
                moving = true;
                game.GameScreen.stage.PassableLayer[Stage.PosToTile(Center).X, Stage.PosToTile(Center).Y] = true;
            }
        }
Example #2
0
        public static Point Adjacent(Vector2 centerPos, Direction dir)
        {
            var p = Stage.PosToTile(centerPos);

            switch (dir)
            {
            case Direction.Left:
                p.X--;
                break;

            case Direction.Right:
                p.X++;
                break;

            case Direction.Up:
                p.Y--;
                break;

            case Direction.Down:
                p.Y++;
                break;
            }

            return(p);
        }
Example #3
0
        public override void Update(GameTime t)
        {
            if (moving)
            {
                var p = Robot.Adjacent(Center, Dir);

                if (game.GameScreen.stage.PassableLayer[p.X, p.Y])
                {
                    pos += vel;
                }
                else
                {
                    moving   = false;
                    stopping = true;
                }
            }
            else if (stopping)
            {
                stopDist += Math.Abs(vel.X) + Math.Abs(vel.Y);
                if (stopDist > Stage.TileSize / 2)
                {
                    vel      = Vector2.Zero;
                    pos      = Stage.TileToPos(Stage.PosToTile(Center));
                    stopping = false;
                    moving   = false;
                    game.GameScreen.stage.PassableLayer[Stage.PosToTile(Center).X, Stage.PosToTile(Center).Y] = false;
                }
                else
                {
                    pos += vel;
                }
            }
        }
Example #4
0
        public void SnapToTile()
        {
            //HACK the fact that he's not tile-sized
            Point tileCenter = Stage.PosToTile(Center);
            float diffX      = Size.X - Stage.TileSize;
            float diffY      = Size.Y - Stage.TileSize;

            position = new Vector2(tileCenter.X * Stage.TileSize - (diffX / 2.0f), tileCenter.Y * Stage.TileSize - (diffY));
        }
Example #5
0
        public void ActivateObject()
        {
            if (energy > 0)
            {
                energy--;
                Point tile = g.GameScreen.robot.AdjacentTile();

                g.GameScreen.stage.objects.ForEach((o) =>
                {
                    if (Stage.PosToTile(o.Center) == tile)
                    {
                        if (o is Button)
                        {
                            g.GameScreen.robot.PlayPush();
                            ((Button)o).push();
                        }
                    }
                });
            }
        }
Example #6
0
        public ADHDObject(ADHDGame g, SpriteBatch sb, Texture2D t, Vector2 pos, Rectangle init, int nFrames, float rate, bool l, int TYPE)
        {
            game       = g;
            upLeft     = Stage.PosToTile(pos);
            lowerRight = new Point(
                upLeft.X + init.Width / Stage.TileSize - 1,
                upLeft.Y + init.Height / Stage.TileSize - 1);
            position = pos;

            tex   = t;
            batch = sb;
            size  = new Vector2(init.Width, init.Height);

            anim = new Animation(init, nFrames, rate, l);
            if (l)
            {
                anim.Play();
            }
            type = TYPE;
        }
Example #7
0
        public override void Update(GameTime time)
        {
            base.Update(time);

            Robot r = game.GameScreen.robot;

            if (!opening && !r.moving && IsOver(Stage.PosToTile(r.Center)))
            {
                //trigger airlock
                opening = true;
                SoundEffect sound = game.Content.Load <SoundEffect>("airlock");
                sound.Play();
                PlayAnimation();
                game.GameScreen.End(EndScreen.Ending.Airlock, 5.0f);
                game.GameScreen.robot.scaling = true;
                if (game.GameScreen.robot.position.Y > position.Y - 96)
                {
                    //game.GameScreen.robot.
                }
            }
        }
Example #8
0
 public void PushObject()
 {
     if (energy > 0)
     {
         energy--;
         push  = g.GameScreen.robot.position;
         adj.X = g.GameScreen.robot.AdjacentTile().X;
         adj.Y = g.GameScreen.robot.AdjacentTile().Y;
         if (!g.GameScreen.stage.PassableLayer[Stage.PosToTile(adj).X, Stage.PosToTile(adj).Y])
         {
             g.GameScreen.stage.objects.ForEach((o) => {
                 if (o.type == 1)
                 {
                     if (Stage.PosToTile(o.Center) == g.GameScreen.robot.AdjacentTile())
                     {
                         g.GameScreen.robot.PlayPush();
                         ((HoverDolly)o).push(g.GameScreen.robot.Dir);
                     }
                 }
                 ;
             });
         }
     }
 }