Beispiel #1
0
        public void Update(GameTime gameTime)
        {
            var timer = (float)gameTime.ElapsedGameTime.TotalSeconds;

            if (preMatch)
            {
                rpsOne.Update(gameTime);
                rpsTwo.Update(gameTime);

                if (rpsOne.Decision != 0 && rpsTwo.Decision != 0)
                {
                    rpsOne.ShowChoice = true;
                    rpsTwo.ShowChoice = true;

                    if (rpsOne.Ready && rpsTwo.Ready)
                    {
                        if (rpsOne.ThisBeats(rpsTwo))
                        {
                            rpsOne.Win = 1;
                            rpsTwo.Win = 2;

                            One.IsServing = true;
                            Collision.Instance.LastTouched = One;

                            remainingDelay -= timer;

                            if (remainingDelay <= 0)
                            {
                                preMatch       = false;
                                remainingDelay = delay;
                            }
                        }
                        else
                        {
                            if (rpsTwo.ThisBeats(rpsOne))
                            {
                                rpsTwo.Win = 1;
                                rpsOne.Win = 2;

                                Two.IsServing = true;
                                Collision.Instance.LastTouched = Two;


                                remainingDelay -= timer;

                                if (remainingDelay <= 0)
                                {
                                    preMatch       = false;
                                    remainingDelay = delay;
                                }
                            }
                            else
                            {
                                remainingDelay -= timer;

                                if (remainingDelay <= 0)
                                {
                                    rpsOne.Decision   = 0;
                                    rpsTwo.Decision   = 0;
                                    rpsOne.ShowChoice = false;
                                    rpsTwo.ShowChoice = false;
                                    rpsOne.Ready      = false;
                                    rpsTwo.Ready      = false;

                                    remainingDelay = delay;
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                if (One == bumblebeeOne)
                {
                    bumblebeeOne.UpdateAnim();
                }

                if (Two == bumblebeeTwo)
                {
                    bumblebeeTwo.UpdateAnim();
                }

                if (One == dolphinOne)
                {
                    dolphinOne.UpdateAnim();
                }

                if (Two == dolphinTwo)
                {
                    dolphinTwo.UpdateAnim();
                }

                if (One.Points == maxPoints && !isFinished)
                {
                    //winner == one -> Ende
                    isFinished = true;
                    winner     = One;
                    looser     = Two;

                    if (iceField != null)
                    {
                        iceField.GroupOne.SetCheering();
                        iceField.Confetti = new Confetti(new Vector3(-iceField.Width / 2, -iceField.Length / 2, 0), new Vector3(iceField.Width / 2, -iceField.Length / 2, 0));
                    }

                    if (meadowField != null)
                    {
                        meadowField.GroupOne.SetCheering();
                        meadowField.Confetti = new ConfettiFlower(new Vector3(-meadowField.Width / 2, -meadowField.Length / 2, 0), new Vector3(meadowField.Width / 2, -meadowField.Length / 2, 0));
                    }

                    if (waterField != null)
                    {
                        waterField.GroupOne.SetCheering();
                        waterField.Confetti = new ConfettiFish(new Vector3(-waterField.Width / 2, -waterField.Length / 2, 0), new Vector3(waterField.Width / 2, -waterField.Length / 2, 0));
                    }
                }

                if (Two.Points == maxPoints && !isFinished)
                {
                    //winner == two -> Ende
                    isFinished = true;
                    winner     = Two;
                    looser     = One;

                    if (iceField != null)
                    {
                        iceField.GroupTwo.SetCheering();
                        iceField.Confetti = new Confetti(new Vector3(-iceField.Width / 2, iceField.Length / 2, 0), new Vector3(iceField.Width / 2, iceField.Length / 2, 0));
                    }

                    if (meadowField != null)
                    {
                        meadowField.GroupTwo.SetCheering();
                        meadowField.Confetti = new ConfettiFlower(new Vector3(-meadowField.Width / 2, meadowField.Length / 2, 0), new Vector3(meadowField.Width / 2, meadowField.Length / 2, 0));
                    }

                    if (waterField != null)
                    {
                        waterField.GroupTwo.SetCheering();
                    }
                }

                if (pinguinOne != null && pinguinTwo != null)
                {
                    pinguinOne.Update(Field);
                    pinguinTwo.Update(Field);
                }

                if (bumblebeeOne != null && bumblebeeTwo != null)
                {
                    bumblebeeOne.Update(Field);
                    bumblebeeTwo.Update(Field);
                }

                if (dolphinOne != null && dolphinTwo != null)
                {
                    dolphinOne.Update(Field);
                    dolphinTwo.Update(Field);
                }

                if (change_size)
                {
                    changeSizePlus.Update(rnd);
                    changeSizeMinus.Update(rnd);
                }

                if (change_velocity)
                {
                    changeVelocityPlus.Update(rnd);
                    changeVelocityMinus.Update(rnd);
                }

                if (iceField != null)
                {
                    iceField.Update(rnd);
                }

                if (meadowField != null)
                {
                    meadowField.Update(rnd);
                }

                if (waterField != null)
                {
                    waterField.Update(rnd);
                }

                if (isFinished)
                {
                    //
                    if (pinguinOne != null && pinguinTwo != null)
                    {
                        pinguinOne.CheeringP();
                        pinguinTwo.CheeringP();
                    }

                    if (bumblebeeOne != null && bumblebeeTwo != null)
                    {
                        bumblebeeOne.CheeringB();
                        bumblebeeTwo.CheeringB();
                    }

                    if (dolphinOne != null && dolphinTwo != null)
                    {
                        dolphinOne.CheeringD();
                        dolphinTwo.CheeringD();
                    }
                    //
                    text.Update(gameTime);
                    text.Position = text.Position + new Vector2(0, -counter);

                    if (text.Position.Y <= -750)
                    {
                        text.Position.Y = 1200;
                    }
                }

                if (!isFinished)
                {
                    Ball.Instance.Update();
                }

                Collision.Instance.CollisionMethod(Field);
            }
        }