Exemplo n.º 1
0
        public Player(Vector2 p)
        {
            pos = p;
            //rectangle = new Rectangle(p.X, p.Y, PLAYER_WIDTH, PLAYER_HEIGHT);
            //rectangle.setTexture("../../res/tex/george.png");

            bounds = new Bounds(PLAYER_WIDTH, PLAYER_HEIGHT);

            boundingBox = new BoundingBox(p.X, p.Y, bounds);

            XLG.keyboard.KeyDown += new EventHandler<KeyboardKeyEventArgs>(OnKeyDown);
            XLG.keyboard.KeyUp += new EventHandler<KeyboardKeyEventArgs>(OnKeyUp);

            facing = -1;

            /// TIMER INIT
            timers  = new List<Timer>();
            punchCooldown = new Timer(40);
            punchLength = new Timer(2);

            timers.Add(punchCooldown);
            timers.Add(punchLength);

            /// ANIM INIT
            standingLAnim = new Animation(1, AnimationMode.PAUSE);
            standingRAnim = new Animation(1, AnimationMode.PAUSE);
            walkingLAnim = new Animation(8, AnimationMode.LOOP, LoopMode.PINGPONG);
            walkingRAnim = new Animation(8, AnimationMode.LOOP, LoopMode.PINGPONG);

            standingLAnim.AddFrame(ImageManager.GetImage(ImageName.player_standing_L00), bounds.width, bounds.height);
            standingRAnim.AddFrame(ImageManager.GetImage(ImageName.player_standing_R00), bounds.width, bounds.height);

            walkingLAnim.AddFrame(ImageManager.GetImage(ImageName.player_walking_L00), bounds.width, bounds.height);
            walkingLAnim.AddFrame(ImageManager.GetImage(ImageName.player_walking_L01), bounds.width, bounds.height);
            walkingLAnim.AddFrame(ImageManager.GetImage(ImageName.player_walking_L02), bounds.width, bounds.height);

            walkingRAnim.AddFrame(ImageManager.GetImage(ImageName.player_walking_R00), bounds.width, bounds.height);
            walkingRAnim.AddFrame(ImageManager.GetImage(ImageName.player_walking_R01), bounds.width, bounds.height);
            walkingRAnim.AddFrame(ImageManager.GetImage(ImageName.player_walking_R02), bounds.width, bounds.height);

            currentAnim = standingLAnim;
        }
Exemplo n.º 2
0
        public Building(Vector2 pos, Bounds bounds)
        {
            health = 5;

            this.pos = pos;
            this.boundingBox = new BoundingBox(pos.X, pos.Y, bounds);

            standing000 = new Rectangle(pos.X, pos.Y, bounds.width, bounds.height);
            standing001 = new Rectangle(pos.X, pos.Y, bounds.width, bounds.height);
            standing002 = new Rectangle(pos.X, pos.Y, bounds.width, bounds.height);
            standing000.setTexture("../../res/tex/building/standing000.png");
            standing001.setTexture("../../res/tex/building/standing001.png");
            standing002.setTexture("../../res/tex/building/standing002.png");
            List<Rectangle> standingFrames = new List<Rectangle>();
            standingFrames.Add(standing000);
            standingFrames.Add(standing001);
            standingFrames.Add(standing002);
            standingAnim = new Animation(standingFrames, 100, AnimationMode.LOOP);

            hit000 = new Rectangle(pos.X, pos.Y, bounds.width, bounds.height);
            hit001 = new Rectangle(pos.X, pos.Y, bounds.width, bounds.height);
            hit002 = new Rectangle(pos.X, pos.Y, bounds.width, bounds.height);
            hit000.setTexture("../../res/tex/building/hit000.png");
            hit001.setTexture("../../res/tex/building/hit001.png");
            hit002.setTexture("../../res/tex/building/hit002.png");
            List<Rectangle> hitFrames = new List<Rectangle>();
            hitFrames.Add(hit000);
            hitFrames.Add(hit001);
            hitFrames.Add(hit002);
            hitAnim = new Animation(hitFrames, 8, AnimationMode.LOOP);

            hit = false;
            hitAnimTimer = new Timer(30);

            currentAnim = standingAnim;
        }