Esempio n. 1
0
        public Enemy(Vector2 position, Camera2d camera)
            : base(camera)
        {
            this.position = position;

            // Definicja animacji postaci
            this.animation = new Animation(2, 5, Direction.Left);
            AnimationFrame eiti1 = new AnimationFrame(@"Game\eiti1", new Rectangle(0, 0, 200, 200), new Rectangle(0, 0, 40, 40));
            eiti1.origin = new Vector2(100, 180);
            AnimationFrame eiti2 = new AnimationFrame(@"Game\eiti2", new Rectangle(0, 0, 200, 200), new Rectangle(0, 0, 40, 40));
            eiti2.origin = new Vector2(100, 180);
            this.animation.framesLeft.Add(eiti1);
            this.animation.framesLeft.Add(eiti2);
            this.animation.framesRight.Add(eiti1);
            this.animation.framesRight.Add(eiti2);
            this.animation.framesUp.Add(eiti1);
            this.animation.framesUp.Add(eiti2);
            this.animation.framesDown.Add(eiti1);
            this.animation.framesDown.Add(eiti2);

            this.animationDeath = new Animation(20, 15, Direction.Left);

            AnimationFrame frame;
            for (int i = 1; i <= 10; i++)
            {
                frame = new AnimationFrame(@"Game\AnimationDeath\eiti1_klatka" + i.ToString(), new Rectangle(0, 0, 200, 200), new Rectangle(0, 0, 40, 40));
                frame.origin = new Vector2(100, 180);
                if (i == 10)
                    for (int j = 0; j < 11; j++)
                    {
                        this.animationDeath.framesLeft.Add(frame);
                        this.animationDeath.framesRight.Add(frame);
                        this.animationDeath.framesUp.Add(frame);
                        this.animationDeath.framesDown.Add(frame);
                    }
                else
                {
                    this.animationDeath.framesLeft.Add(frame);
                    this.animationDeath.framesRight.Add(frame);
                    this.animationDeath.framesUp.Add(frame);
                    this.animationDeath.framesDown.Add(frame);
                }
            }

            List<Vector2> points = new List<Vector2>();

            points.Add(new Vector2(-BoundariesSize, 0));
            points.Add(new Vector2(0, -BoundariesSize));
            points.Add(new Vector2(BoundariesSize, 0));
            points.Add(new Vector2(0, BoundariesSize));

            this.boundaries = Boundaries.CreateFromPoints(points);

            this.health = 6;
            this.speed = 0.55f;
            this.timeLastShot = new TimeSpan();
        }
Esempio n. 2
0
 public Unit(Camera2d camera)
 {
     this.camera = camera;
 }
Esempio n. 3
0
        public Fighter(bool playerControlled, Vector2 position, Camera2d camera)
            : base(camera)
        {
            this.playerControlled = playerControlled;
            this.position = position;

            // Definicja animacji postaci
            this.animation = new Animation(2, 5, Direction.Left);
            AnimationFrame mini1 = new AnimationFrame(@"Game\mini1", new Rectangle(0, 0, 200, 200), new Rectangle(0, 0, 40, 40));
            mini1.origin = new Vector2(100, 180);
            AnimationFrame mini2 = new AnimationFrame(@"Game\mini2", new Rectangle(0, 0, 200, 200), new Rectangle(0, 0, 40, 40));
            mini2.origin = new Vector2(100, 180);
            this.animation.framesLeft.Add(mini1);
            this.animation.framesLeft.Add(mini2);
            this.animation.framesRight.Add(mini1);
            this.animation.framesRight.Add(mini2);
            this.animation.framesUp.Add(mini1);
            this.animation.framesUp.Add(mini2);
            this.animation.framesDown.Add(mini1);
            this.animation.framesDown.Add(mini2);

            this.animationDeath = new Animation(20, 15, Direction.Left);

            AnimationFrame frame;
            for (int i = 1; i <= 10; i++)
            {
                frame = new AnimationFrame(@"Game\AnimationDeath\mini1_klatka" + i.ToString(), new Rectangle(0, 0, 200, 200), new Rectangle(0, 0, 40, 40));
                frame.origin = new Vector2(100, 180);
                if (i == 10)
                    for (int j = 0; j < 11; j++)
                    {
                        this.animationDeath.framesLeft.Add(frame);
                        this.animationDeath.framesRight.Add(frame);
                        this.animationDeath.framesUp.Add(frame);
                        this.animationDeath.framesDown.Add(frame);
                    }
                else
                {
                    this.animationDeath.framesLeft.Add(frame);
                    this.animationDeath.framesRight.Add(frame);
                    this.animationDeath.framesUp.Add(frame);
                    this.animationDeath.framesDown.Add(frame);
                }
            }

            List<Vector2> points = new List<Vector2>();

            points.Add(new Vector2(-BoundariesSize, 0));
            points.Add(new Vector2(0, -BoundariesSize));
            points.Add(new Vector2(BoundariesSize, 0));
            points.Add(new Vector2(0, BoundariesSize));

            this.boundaries = Boundaries.CreateFromPoints(points);

            this.health = 8;
            this.isActive = true;
            this.speed = 0.75f;
            this.timeLastShot = new TimeSpan();

            this.destination = new Vector2(position.X, position.Y);
        }