예제 #1
0
        /// <inheritdoc/>
        protected override void Update(Time time)
        {
            if (!(this.Owner is PlatformCharacter))
            {
                return;
            }

            //Calculate from Speed later?
            double yTolerance = 10.0;
            double xTolerance = 10.0;

            PlatformCharacter pc = this.Owner as PlatformCharacter;

            if (_triesToJump)
            {
                //Brains are walking against a wall:
                if (Math.Abs(pc.Velocity.X) < 5)
                {
                    //If position hasn't changed since last jump, change direction.
                    if ((pc.Position - lastJumpingPosition).Magnitude < 1)
                    {
                        pc.Stop();
                        this.Speed *= -1;
                    }
                    else
                    {
                        pc.Jump(JumpSpeed);
                        lastJumpingPosition = pc.Position;

                        //Brains don't change direction in mid-air while jumping:
                        if (!_fallsOffPlatforms)
                        {
                            _fallsOffPlatforms = true;
                            Timer.SingleShot(0.5, delegate
                                             { _fallsOffPlatforms = false; });
                        }
                    }
                }
            }

            //Changes direction if it's about to fall off a platform:
            if (!_fallsOffPlatforms && pc.IsAboutToFall() && Math.Abs(pc.Velocity.Y) < yTolerance)
            {
                pc.Stop();

                if (_triesToJump && Math.Abs(pc.Velocity.X) < xTolerance)
                {
                    this.Speed *= -1;
                }
            }

            if (!_triesToJump && Math.Abs(pc.Velocity.X) < xTolerance)
            {
                this.Speed *= -1;
            }

            pc.Walk(this.Speed);

            base.Update(time);
        }
예제 #2
0
    /// <summary>
    /// Lopettaa pelin, tulostaa syyn havioon, ja avaa monivalintaikkunan.
    /// </summary>
    /// <param name="syy">Syy.</param>
    public void PeliPaattyi(string syy)
    {
        fuksi.Stop();
        esteAjastin.Stop();
        for (int i = 0; i < esteet.Count; i++)
        {
            esteet[i].Stop();
        }
        hyppyKorkeus = 1500.0;
        liikeNopeus  = 800.0;
        StringBuilder viesti = new StringBuilder(syy + "\nTuloksesi: ");

        viesti.Append(pisteLaskuri.Value);
        MultiSelectWindow valikko = new MultiSelectWindow(viesti.ToString(),
                                                          "Aloita alusta",
                                                          "Lopeta");

        valikko.ItemSelected += ValikonNappi;
        Add(valikko);
    }