Exemple #1
0
        public void Initialize(List<Texture2D> charactersTexture, int type, GraphicsDevice graphicsDevice)
        {
            animation = new Animation();
            Health = 100f;

            switch (type)
            {
                case 0:
                    Strength = 30;
                    Ammunition = 100;
                    Speed = 8;
                    animation.Initialize(charactersTexture.ElementAt(type), Vector2.Zero, 32, 32, 1, 100, Color.White, 1f, true);
                    break;
                case 1:
                    Strength = 15;
                    Ammunition = 10;
                    Speed = 12;
                    animation.Initialize(charactersTexture.ElementAt(type), Vector2.Zero, 32, 32, 1, 100, Color.White, 1f, true);
                    break;

                default:
                    Strength = 100;
                    Ammunition = 100;
                    Speed = 1.0f;
                    animation.Initialize(charactersTexture.ElementAt(type), Vector2.Zero, 32, 32, 1, 100, Color.White, 1f, true);
                    break;

            }

            Health = 100;
        }
Exemple #2
0
        public void Initialize(Vector2 initialPosition, int shootDirection, Texture2D texture, float Damage, ConnectionTest con)
        {
            speed = 25f;
            this.con = con;
            direction = shootDirection;

               // Console.WriteLine("new projectile");
            Position = initialPosition;

            sprite = new Animation();

            sprite.Initialize(texture, Position, 64, 64, 3, 30, Color.White, 1, true);

            this.Damage = Damage;
            Active = true;

            spawnDuration = TimeSpan.FromSeconds(.5f);

            lifeTime = new Stopwatch();
            lifeTime.Start();
        }
Exemple #3
0
        private void createWalls(Texture2D barrierTexture)
        {
            int widthNeed = width / 32;
            int heightNeed = height / 32;

            for (int i = 0; i < widthNeed; i++)
            {

                Animation barrierAnimation = new Animation();
                barrierAnimation.Initialize(barrierTexture, Vector2.Zero, 32, 32, 1, 30, Color.White, 1f, true);

                Barrier barr = new Barrier();
                if (i != 0)
                    barr.Initialize(barrierAnimation, new Vector2(walls[i - 1].Position.X + 32, 16), false, true);
                else
                    barr.Initialize(barrierAnimation, new Vector2(16, 16), false, true);

                walls.Add(barr);

            }

            for (int i = 0; i < widthNeed; i++)
            {

                Animation barrierAnimation = new Animation();
                barrierAnimation.Initialize(barrierTexture, Vector2.Zero, 32, 32, 1, 30, Color.White, 1f, true);

                Barrier barr = new Barrier();
                if (i != 0)
                    barr.Initialize(barrierAnimation, new Vector2(walls[i - 1].Position.X + 32, heightNeed * 32), false, true);
                else
                    barr.Initialize(barrierAnimation, new Vector2(16, heightNeed * 32), false, true);

                walls.Add(barr);

            }

            for (int i = 0; i < heightNeed - 1; i++)
            {
                Animation barrierAnimation = new Animation();
                barrierAnimation.Initialize(barrierTexture, Vector2.Zero, 32, 32, 1, 30, Color.White, 1f, true);

                int counter = walls.Count;

                Barrier barr = new Barrier();
                if (i != 0 && i != heightNeed)
                {
                    barr.Initialize(barrierAnimation, new Vector2(16, walls[counter - 1].Position.Y + 32), false, true);
                    //Console.WriteLine(barr.Position);
                }
                else if (i == 0)
                {
                    barr.Initialize(barrierAnimation, new Vector2(16, 48), false, true);
                    // Console.WriteLine(barr.Position);
                    // Console.WriteLine(walls.Count);
                }

                counter++;

                walls.Add(barr);

            }

            for (int i = 0; i < heightNeed - 1; i++)
            {
                Animation barrierAnimation = new Animation();
                barrierAnimation.Initialize(barrierTexture, Vector2.Zero, 32, 32, 1, 30, Color.White, 1f, true);

                int counter = walls.Count;

                Barrier barr = new Barrier();
                if (i != 0 && i != heightNeed)
                {
                    barr.Initialize(barrierAnimation, new Vector2(widthNeed * 32 - 16, walls[counter - 1].Position.Y + 32), false, true);
                }
                else if (i == 0)
                {
                    barr.Initialize(barrierAnimation, new Vector2(widthNeed * 32 - 16, 48), false, true);
                }

                counter++;

                walls.Add(barr);

            }
        }
Exemple #4
0
        private void createCollectables(Texture2D barrierTexture)
        {
            //Add collectables to the map

            Random r = new Random();
            float posX;
            float posY;

            for (int i = 0; i < 10; i++)
            {
                posX = r.Next(40, width - 40);
                posY = r.Next(40, height - 40);
                Animation barrierAnimation = new Animation();
                barrierAnimation.Initialize(barrierTexture, Vector2.Zero, 32, 32, 1, 30, Color.White, 1f, true);

                //Collectable coll = new Collectable();

                //coll.Initialize(new Vector2(posX, posY));

                //collectables.Add(coll);
            }
        }
Exemple #5
0
        private void AddBarrier()
        {
            Animation barrierAnimation = new Animation();

            barrierAnimation.Initialize(wallTexture, Vector2.Zero, 16, 16, 1, 30, Color.White, 1f, true);

            Vector2 position = bPo;

            Barrier barrier = new Barrier();

            barrier.Initialize(barrierAnimation, position, true, true);

            barriers.Add(barrier);
            Console.WriteLine("Barriers: {0}", barriers.Count);
            bPo.X += 16;
        }
Exemple #6
0
        private void received_collectables(List<Vector2> collectablesPosition, List<int> type)
        {
            //Console.WriteLine("got collectables");
            List<Collectable> collectables = new List<Collectable>();
            for(int i=0; i<collectablesPosition.Count; i++)
            {
                Animation collectableAnimation = new Animation();
                collectableAnimation.Initialize(collectableTexture, Vector2.Zero, 32, 32, 1, 30, Color.White, 1f, true);

                Collectable coll = new Collectable();

                coll.Initialize(new Vector2(collectablesPosition[i].X, collectablesPosition[i].Y), type[i]);

                coll.setAnimation(collectableAnimation);

                collectables.Add(coll);
            }

            level.setCollectables(collectables);
        }
Exemple #7
0
        private void received_barriers(List<Vector2> barriersPosition, List<int> type)
        {
            //Console.WriteLine("got collectables");
            List<Barrier> barriers = new List<Barrier>();
            for (int i = 0; i < barriersPosition.Count; i++)
            {
                Animation barrierAnimation = new Animation();
                barrierAnimation.Initialize(barrierTexture, Vector2.Zero, 32, 32, 1, 30, Color.White, 1f, true);

                Barrier barr = new Barrier();

                barr.Initialize(barrierAnimation, new Vector2(barriersPosition[i].X, barriersPosition[i].Y), true, false);

                barriers.Add(barr);
            }

            level.setBarriers(barriers);
        }
Exemple #8
0
 public void setAnimation(Animation animation)
 {
     CollectableAnimation = animation;
 }