Exemple #1
0
        public void FinishConfiguration(Goat goat)
        {
            Random random = new Random();

            foreach (Player p in Game1.players)
            {
                if (p != goat && !p.playerIsDead)
                {
                    float initialPositionX = (int)p.positionX;
                    float initialPositionY = (int)p.positionY;

                    float newPositionX = random.Next(0, Game1.screenWidth - (p.width) - 1);
                    float newPositionY = random.Next(0, Game1.screenHeight - (p.height) - 1);

                    p.positionX = newPositionX;
                    p.positionY = newPositionY;

                    p.AdjustPositionInCaseOfTilesIntersection(initialPositionX, initialPositionY);

                    Animation appearanceSmokeAnimation = new Animation();
                    appearanceSmokeAnimation.Initialize(appearanceSmokeTexture,
                                                        new Vector2(p.positionX - ((57 - p.width) / 2),
                                                                    p.positionY - ((57 - p.height) / 2)), 57, 57, 0, 8, 40, Color.White, 1f, true);

                    appearanceSmokes.Add(appearanceSmokeAnimation);
                }
            }

            goat.sp -= manaCost;
            goat.configuringRoutes = false;

            configurationElapsedTime = 0;

            dots = ".";
        }
Exemple #2
0
        public void Draw(SpriteBatch spriteBatch, Goat goat)
        {
            switch (goat.goatActions)
            {
            case Goat.GoatActions.InLove:
                if (showHeart)
                {
                    spriteBatch.Draw(heartTexture, heartRectangle, Color.White);
                }
                break;

            case Goat.GoatActions.ReleasingDisillusionRays:
                bool isRight;

                if (goat.side == Player.Side.Right)
                {
                    isRight = true;
                }
                else
                {
                    isRight = false;
                }

                disillusionRaysAnimation.Draw(spriteBatch, isRight);
                break;
            }
        }
Exemple #3
0
        public void Update(GameTime gameTime, Goat goat)
        {
            dotsPosition = new Vector2(goat.positionX + (goat.width / 2), goat.TopOfFirstMeasureBar() - dotsSize.Y - 5);
            textPosition = new Vector2(goat.positionX + (goat.width / 2), dotsPosition.Y - 15);

            dotsAddElapsedTime += (int)gameTime.ElapsedGameTime.TotalMilliseconds;

            if (dotsAddElapsedTime > dotsAddMillisecondsTime)
            {
                dots += ".";
                if (dots.Length > 5)
                {
                    dots = ".";
                }
                dotsSize           = Game1.font18.MeasureString(dots);
                dotsAddElapsedTime = 0;
            }

            configurationElapsedTime += (int)gameTime.ElapsedGameTime.TotalMilliseconds;

            if (configurationElapsedTime > configurationMillisecondsTime)
            {
                FinishConfiguration(goat);
            }
        }
Exemple #4
0
 public void ReleaseDisillusionRays(Goat goat)
 {
     //SoundsLibrary.PlaySound(SoundsLibrary.goatReleasingDisillusionRaysSound);
     UpdateDisillusionRaysPosition(goat);
     affectedByLoveInvisibility = false;
     goat.ChangeGoatAction(Goat.GoatActions.ReleasingDisillusionRays);
     disillusionRaysAnimation.currentFrame = 0;
     invisibilityElapsedTime = 0;
 }
Exemple #5
0
        public Player LoadPlayer(ContentManager content, int width, int height, int deadWidth, int deadHeight)
        {
            if (side == Player.Side.Left)
            {
                position.X -= width;
            }

            Player player;

            Animation playerAnimation = new Animation();
            Texture2D playerTexture   = content.Load <Texture2D>("Graphics\\" + characterName.ToLower());

            // Frame dimensions: 39x - 45y
            playerAnimation.Initialize(playerTexture, position, width, height, 0, 0, 100, Color.White, 1f, true);

            Animation deadAnimation = new Animation();
            Texture2D deadTexture   = content.Load <Texture2D>("Graphics\\" + characterName.ToLower() + "_flying");

            deadAnimation.Initialize(deadTexture, position, deadWidth, deadHeight, 0, 3, 100, Color.White, 1f, false);

            Texture2D measureBar = content.Load <Texture2D>("Graphics\\measure_bar");
            Texture2D aimTexture = content.Load <Texture2D>("Graphics\\aim");
            Aim       aim        = new Aim(aimTexture, 30, 9, 50);

            Texture2D appearanceSmokeTexture = content.Load <Texture2D>("Graphics\\appearance_smoking");

            switch (characterName.ToLower())
            {
            case "dwarf":
                Animation boozeAnimation = new Animation();
                Texture2D boozeTexture   = content.Load <Texture2D>("Graphics\\booze");
                boozeAnimation.Initialize(boozeTexture, position, 9, 9, 0, 4, 100, Color.White, 1f, true);

                Animation lighterAnimation = new Animation();
                Texture2D lighterTexture   = content.Load <Texture2D>("Graphics\\lighter");
                lighterAnimation.Initialize(lighterTexture, position, 4, 7, 0, 4, 100, Color.White, 1f, true);

                Animation fireSpitAnimation = new Animation();
                Texture2D fireSpitTexture   = content.Load <Texture2D>("Graphics\\lighter_on_fire");
                fireSpitAnimation.Initialize(fireSpitTexture, position, 46, 32, 0, 4, 100, Color.White, 1f, true);

                FireSpitting fireSpitting = new FireSpitting(boozeAnimation, lighterAnimation, fireSpitAnimation, 2f, 100, 2f);

                Texture2D boozeSpinTexture = content.Load <Texture2D>("Graphics\\spinning_booze");

                //SpinningBooze boozeSpinning = new SpinningBooze(boozeSpinAnimation, 0.3f, 25, 5);

                player = new Dwarf(playerAnimation, deadAnimation, aim, measureBar, playerID, 100, 100, 0, 4, 5, new Vector2(6, 33),
                                   side, input, fireSpitting, boozeSpinTexture);
                break;

            case "dove":
                Animation sandwichAnimation = new Animation();
                Texture2D sandwichTexture   = content.Load <Texture2D>("Graphics\\sandwich");
                sandwichAnimation.Initialize(sandwichTexture, position, 9, 9, 0, 5, 400, Color.White, 1f, true);

                Animation stinkAnimation = new Animation();
                Texture2D stinkTexture   = content.Load <Texture2D>("Graphics\\stink");
                stinkAnimation.Initialize(stinkTexture, position, 45, 45, 0, 6, 100, Color.White, 1f, true);

                Texture2D pooTexture = content.Load <Texture2D>("Graphics\\poo");

                Texture2D forkTexture   = content.Load <Texture2D>("Graphics\\fork");
                Animation forkAnimation = new Animation();
                forkAnimation.Initialize(forkTexture, new Vector2(0, 0), 18, 18, 0, 7, 50, Color.White, 1f, true);

                Projectile fork = new Projectile(forkAnimation, 0, 30, 10);

                player = new Dove(playerAnimation, deadAnimation, aim, measureBar, playerID, 100, 100, 0.5f, 5, 5, new Vector2(3, 39),
                                  side, input, sandwichAnimation, pooTexture, 4, stinkAnimation, fork);
                break;

            case "skinny":
                Animation spaceshipAnimation = new Animation();
                Texture2D spaceshipTexture   = content.Load <Texture2D>("Graphics\\spaceship");
                spaceshipAnimation.Initialize(spaceshipTexture, position, 57, 30, 0, 4, 50, Color.White, 1f, true);

                Texture2D spaceshoot = content.Load <Texture2D>("Graphics\\spaceshoot");
                Texture2D crazyRay   = content.Load <Texture2D>("Graphics\\crazy_ray");

                Animation disappearanceAnimation = new Animation();
                Texture2D disappearanceTexture   = content.Load <Texture2D>("Graphics\\skinny_teleport");
                disappearanceAnimation.Initialize(disappearanceTexture, position, width, height, 0, 6, 50, Color.White, 1f, true);

                Animation appearanceSmokeAnimation = new Animation();
                appearanceSmokeAnimation.Initialize(appearanceSmokeTexture, position, 57, 57, 0, 8, 40, Color.White, 1f, true);

                Teleport tp = new Teleport(disappearanceAnimation, appearanceSmokeAnimation, 100f);

                player = new Skinny(playerAnimation, deadAnimation, aim, measureBar, playerID, 100, 100, 0.2f, 5, 5, new Vector2(6, 30),
                                    side, input, spaceshipAnimation, spaceshoot, crazyRay, tp, 0.7f);
                break;

            case "goat":
                Animation disillusionRaysAnimation = new Animation();
                Texture2D disillusionRaysTexture   = content.Load <Texture2D>("Graphics\\appearance_ray");
                disillusionRaysAnimation.Initialize(disillusionRaysTexture, position, 33, 48, 0, 3, 50, Color.White, 1f, true);

                Texture2D heart        = content.Load <Texture2D>("Graphics\\heart");
                Texture2D disconnected = content.Load <Texture2D>("Graphics\\disconnected");

                Love luv = new Love(heart, disillusionRaysAnimation);
                RoutesConfiguration routesConfig = new RoutesConfiguration(appearanceSmokeTexture);

                player = new Goat(playerAnimation, deadAnimation, aim, measureBar, playerID, 100, 100, 0.15f, 5, 5, new Vector2(6, 30),
                                  side, input, disconnected, luv, routesConfig);
                break;

            default:
                player = null;
                break;
            }

            return(player);
        }
Exemple #6
0
        public void Update(GameTime gameTime, Goat goat)
        {
            if (affectedByLoveInvisibility)
            {
                invisibilityElapsedTime += (int)gameTime.ElapsedGameTime.TotalMilliseconds;

                if (invisibilityElapsedTime > invisibilityMillisecondsTime)
                {
                    ReleaseDisillusionRays(goat);
                }

                return;
            }

            switch (goat.goatActions)
            {
            case Goat.GoatActions.InLove:
                heartElapsedTime += (int)gameTime.ElapsedGameTime.TotalMilliseconds;

                if (heartElapsedTime > heartMillisecondsTime)
                {
                    if (!showHeart)
                    {
                        showHeart = true;
                        timesHeartBlinked++;
                    }
                    else
                    {
                        showHeart = false;

                        if (timesHeartBlinked >= maxHeartBlinks)
                        {
                            affectedByLoveInvisibility = true;
                            goat.ChangeGoatAction(Goat.GoatActions.None);
                            timesHeartBlinked = 0;
                            goat.sp          -= manaCost;
                        }
                    }

                    heartElapsedTime = 0;
                }

                if (showHeart)
                {
                    UpdateHeartPosition(goat);
                }

                break;

            case Goat.GoatActions.ReleasingDisillusionRays:
                UpdateDisillusionRaysPosition(goat);

                foreach (Player p in Game1.players)
                {
                    if (p != goat)
                    {
                        bool alreadyHit = false;

                        if (playersHitByDisillusionRays.Count > 0)
                        {
                            foreach (Player ph in playersHitByDisillusionRays)
                            {
                                if (ph == p)
                                {
                                    alreadyHit = true;
                                }
                            }
                        }

                        if (!alreadyHit)
                        {
                            if (disillusionRaysAnimation.destinationRect.Intersects(p.body) && !p.playerIsDead)
                            {
                                p.hp -= disillusionRaysDamage;
                                playersHitByDisillusionRays.Add(p);
                            }
                        }
                    }
                }

                if (disillusionRaysAnimation.LastFrame())
                {
                    goat.ChangeGoatAction(Goat.GoatActions.None);
                    playersHitByDisillusionRays.Clear();

                    return;
                }

                disillusionRaysAnimation.Update(gameTime);
                break;
            }
        }
Exemple #7
0
 public void UpdateDisillusionRaysPosition(Goat goat)
 {
     disillusionRaysPositionX = goat.positionX;
     disillusionRaysPositionY = goat.positionY;
 }
Exemple #8
0
 public void UpdateHeartPosition(Goat goat)
 {
     heartRectangle = new Rectangle((int)goat.positionX + (goat.width / 2) - (heartTexture.Width / 2),
                                    (int)goat.TopOfFirstMeasureBar() - heartTexture.Height - 5,
                                    heartTexture.Width, heartTexture.Height);
 }