Exemplo n.º 1
0
 public virtual void Update(float gameTime, Map map, ParticleManager particleManager, Character[] characters)
 {
     location += trajectory * gameTime;
     frame -= gameTime;
     if (frame < 0.0f)
         KillMe();
 }
Exemplo n.º 2
0
        public override void Update(Character[] c, int ID, Map map)
        {
            me = c[ID];

            if (jobFrame < 0f)
            {
                float r = RandomGenerator.GetRandomFloat(0f, 1f);
                if (r < 0.6f)
                {
                    job = JOB_MELEE_CHASE;
                    jobFrame = RandomGenerator.GetRandomFloat(2f, 4f);
                    FindTarg(c);
                }
                else if (r < 0.8f)
                {
                    job = JOB_AVOID;
                    jobFrame = RandomGenerator.GetRandomFloat(1f, 2f);
                    FindTarg(c);
                }
                else
                {
                    job = JOB_IDLE;
                    jobFrame = RandomGenerator.GetRandomFloat(.5f, 1f);
                }
            }

            base.Update(c, ID, map);
        }
Exemplo n.º 3
0
        public override void Update(float gameTime, Map map, ParticleManager pMan, Character[] c)
        {
            if (HitManager.CheckHit(this, c, pMan))
                frame = 0f;

            trajectory.Y = (float)Math.Sin((double)frame * 13.0) * 150f;

            if (map.CheckParticleCollision(location))
            {
                this.frame = 0f;
                pMan.MakeExplosion(location, 1f);
            }

            pMan.AddParticle(new Fire(location, -trajectory / 8f,
                .5f, RandomGenerator.GetRandomInt(0, 4)));
            pMan.AddParticle(new Smoke(location,
                RandomGenerator.GetRandomVector2(-20f, 20f, -50f, 10f)
                - trajectory / 10f,
                1f, .8f, .6f, 1f, .5f,
                RandomGenerator.GetRandomInt(0, 4)));
            pMan.AddParticle(new Heat(location,
                RandomGenerator.GetRandomVector2(-20f, 20f, -50f, -10f),
                RandomGenerator.GetRandomFloat(.5f, 2f)));

            base.Update(gameTime, map, pMan, c);
        }
Exemplo n.º 4
0
 public HUD(SpriteBatch spriteBatch, Texture2D spritesTexture, Texture2D nullTexture, Character[] characters, Map map)
 {
     this.spriteBatch = spriteBatch;
     this.spritesTexture = spritesTexture;
     this.nullTexture = nullTexture;
     this.characters = characters;
     this.map = map;
     scoreDraw = new ScoreDraw(spriteBatch, spritesTexture);
 }
Exemplo n.º 5
0
        public override void Update(float gameTime, Map map, ParticleManager particleManager, Character[] characters)
        {
            if (HitManager.CheckHit(this, characters, particleManager))
                frame = 0f;

            if (map.CheckParticleCollision(location))
            {
                frame = 0f;
                particleManager.MakeBulletDust(location, trajectory);
            }
            base.Update(gameTime, map, particleManager, characters);
        }
Exemplo n.º 6
0
        public virtual void Update(Character[] c, int ID, Map map)
        {
            me = c[ID];

            me.keyLeft = false;
            me.keyRight = false;
            me.keyUp = false;
            me.keyDown = false;
            me.keyAttack = false;
            me.keySecondary = false;
            me.keyJump = false;

            jobFrame -= RuinExplorersMain.FrameTime;

            DoJob(c, ID);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Updates the Character, checks for collision and handles input.
        /// This method has been verified!
        /// </summary>
        /// <param name="gameTime">The game time.</param>
        public void Update(Map map, ParticleManager particleManager, Character[] character)
        {
            if (Ai != null)
                Ai.Update(character, ID, map);

            PressedKey = PressedKeys.None;
            if (keyAttack)
            {
                PressedKey = PressedKeys.Attack;
                if (keyUp) PressedKey = PressedKeys.Lower;
                if (keyDown) PressedKey = PressedKeys.Upper;
            }
            if (keySecondary)
            {
                PressedKey = PressedKeys.Secondary;
                if (keyUp) PressedKey = PressedKeys.SecUp;
                if (keyDown) PressedKey = PressedKeys.SecDown;
            }
            if (PressedKey > PressedKeys.None)
            {
                if (GotoGoal[(int)PressedKey] > -1)
                {
                    SetFrame(GotoGoal[(int)PressedKey]);

                    if (keyLeft)
                        Face = CharacterDirection.Left;
                    if (keyRight)
                        Face = CharacterDirection.Right;

                    PressedKey = PressedKeys.None;

                    for (int i = 0; i < GotoGoal.Length; i++)
                        GotoGoal[i] = -1;

                    frame = 0f;
                }
            }

            if (StunFrame > 0f)
                StunFrame -= RuinExplorersMain.FrameTime;

            #region update dying
            if (DyingFrame > -1f)
            {
                DyingFrame += RuinExplorersMain.FrameTime;
            }
            #endregion

            #region Update Animation
            if (DyingFrame < 0)
            {
                Animation animation = characterDefinition.Animations[Animation];
                KeyFrame keyFrame = animation.KeyFrames[AnimationFrame];

                frame += RuinExplorersMain.FrameTime * 30.0f;

                if (frame > (float)keyFrame.Duration)
                {
                    int pframe = AnimationFrame;

                    script.DoScript(Animation, AnimationFrame);
                    CheckTrigger(particleManager);

                    frame -= (float)keyFrame.Duration;
                    if (AnimationFrame == pframe)
                        AnimationFrame++;

                    keyFrame = animation.KeyFrames[AnimationFrame];

                    if (AnimationFrame >=
                        animation.KeyFrames.Length)
                        AnimationFrame = 0;
                }

                if (keyFrame.FrameReference < 0)
                    AnimationFrame = 0;

                if (AnimationName == "jhit")
                {
                    if (Trajectory.Y > -100f)
                        SetAnim("jmid");
                }
            }

            #endregion

            #region Collision with other characters
            for (int i = 0; i < character.Length; i++)
            {
                if (i != ID)
                {
                    if (character[i] != null)
                    {
                        if (!Ethereal && !character[i].Ethereal)
                        {
                            if (Location.X > character[i].Location.X - 90f * character[i].Scale &&
                         Location.X < character[i].Location.X + 90f * character[i].Scale &&
                         Location.Y > character[i].Location.Y - 120f * character[i].Scale &&
                         Location.Y < character[i].Location.Y + 10f * character[i].Scale)
                            {
                                float dif = (float)Math.Abs(Location.X - character[i].Location.X);
                                dif = 180f * character[i].Scale - dif;
                                dif *= 2f;
                                if (Location.X < character[i].Location.X)
                                {
                                    CollisionMove = -dif;
                                    character[i].CollisionMove = dif;
                                }
                                else
                                {
                                    CollisionMove = dif;
                                    character[i].CollisionMove = -dif;
                                }
                            }
                        }
                    }
                }
            }

            if (CollisionMove > 0f)
            {
                CollisionMove -= 400f * RuinExplorersMain.FrameTime;
                if (CollisionMove < 0f)
                    CollisionMove = 0f;
            }
            if (CollisionMove < 0f)
            {
                CollisionMove += 400f * RuinExplorersMain.FrameTime;
                if (CollisionMove > 0f)
                    CollisionMove = 0f;
            }
            #endregion

            #region Update Location by Trajectory
            Vector2 previousLocation = new Vector2(Location.X, Location.Y);

            if (State == CharacterState.Ground || (State == CharacterState.Air && floating))
            {
                if (Trajectory.X > 0f)
                {
                    Trajectory.X -= RuinExplorersMain.Friction * RuinExplorersMain.FrameTime;
                    if (Trajectory.X < 0f)
                        Trajectory.X = 0f;
                }
                if (Trajectory.X < 0f)
                {
                    Trajectory.X += RuinExplorersMain.Friction * RuinExplorersMain.FrameTime;
                    if (Trajectory.X > 0f)
                        Trajectory.X = 0f;
                }
            }

            Location.X += Trajectory.X * RuinExplorersMain.FrameTime;
            Location.X += CollisionMove * RuinExplorersMain.FrameTime;

            if (State == CharacterState.Air)
            {
                Location.Y += Trajectory.Y * RuinExplorersMain.FrameTime;
            }
            #endregion

            #region Collision detection
            if (State == CharacterState.Air)
            {
                #region Air State
                if (floating)
                {
                    Trajectory.Y += RuinExplorersMain.FrameTime * RuinExplorersMain.Gravity * 0.5f;
                    if (Trajectory.Y > 100f) Trajectory.Y = 100f;
                    if (Trajectory.Y < -100f) Trajectory.Y = -100f;

                }
                else
                    Trajectory.Y += RuinExplorersMain.FrameTime * RuinExplorersMain.Gravity;

                CheckXCollision(map, previousLocation);

                #region Land on ledge
                if (Trajectory.Y > 0.0f)
                {
                    for (int i = 0; i < 16; i++)
                    {
                        if (map.Legdes[i].TotalNodes > 1)
                        {

                            int ts = map.GetLedgeSection(i, previousLocation.X);
                            int s = map.GetLedgeSection(i, Location.X);
                            float fY;
                            float tfY;
                            if (s > -1 && ts > -1)
                            {

                                tfY = map.GetLedgeYLocation(i, s, previousLocation.X);
                                fY = map.GetLedgeYLocation(i, s, Location.X);
                                if (previousLocation.Y <= tfY && Location.Y >= fY)
                                {
                                    if (Trajectory.Y > 0.0f)
                                    {

                                        Location.Y = fY;
                                        ledgeAttach = i;
                                        Land();
                                    }
                                }
                                else

                                    if (map.Legdes[i].isHardLedge == (int)LedgeFlags.Solid
                                        &&
                                        Location.Y >= fY)
                                    {
                                        Location.Y = fY;
                                        ledgeAttach = i;
                                        Land();
                                    }
                            }

                        }
                    }
                }
                #endregion

                #region Land on col
                if (State == CharacterState.Air)
                {
                    if (Trajectory.Y > 0f)
                    {
                        if (map.CheckCollision(new Vector2(Location.X, Location.Y + 15f)))
                        {
                            Location.Y = (float)((int)((Location.Y + 15f) / 64f) * 64);
                            Land();
                        }
                    }
                }
                #endregion

                #endregion
            }
            else if (State == CharacterState.Ground)
            {
                #region Grounded State

                if (ledgeAttach > -1)
                {
                    if (map.GetLedgeSection(ledgeAttach, Location.X) == -1)
                    {
                        FallOff();
                    }
                    else
                    {
                        Location.Y = map.GetLedgeYLocation(ledgeAttach,
                            map.GetLedgeSection(ledgeAttach, Location.X), Location.X);
                    }
                }
                else
                {
                    if (!map.CheckCollision(new Vector2(Location.X, Location.Y + 15f)))
                        FallOff();
                }

                CheckXCollision(map, previousLocation);

                #endregion
            }
            #endregion

            #region Key input
            if (AnimationName == "idle" || AnimationName == "run" ||
                (State == CharacterState.Ground && CanCancel))
            {
                if (AnimationName == "idle" || AnimationName == "run")
                {
                    if (keyLeft)
                    {
                        SetAnim("run");
                        Trajectory.X = -Speed;
                        Face = CharacterDirection.Left;
                    }
                    else if (keyRight)
                    {
                        SetAnim("run");
                        Trajectory.X = Speed;
                        Face = CharacterDirection.Right;
                    }
                    else
                    {
                        SetAnim("idle");
                    }
                }
                if (keyAttack)
                {
                    SetAnim("attack");
                }
                if (keySecondary)
                {
                    SetAnim("second");
                }
                if (keyJump)
                {
                    SetAnim("jump");
                }
                if (RightAnalog.X > 0.2f || RightAnalog.X < -0.2f)
                {
                    SetAnim("roll");
                    if (AnimationName == "roll")
                    {
                        if (RightAnalog.X > 0f)
                            Face = CharacterDirection.Right;
                        else
                            Face = CharacterDirection.Left;
                    }
                }
            }

            if (AnimationName == "fly" ||
                (State == CharacterState.Air && CanCancel))
            {
                if (keyLeft)
                {
                    Face = CharacterDirection.Left;
                    if (Trajectory.X > -Speed)
                        Trajectory.X -= 500f * RuinExplorersMain.FrameTime;
                }
                if (keyRight)
                {
                    Face = CharacterDirection.Right;
                    if (Trajectory.X < Speed)
                        Trajectory.X += 500f * RuinExplorersMain.FrameTime;
                }
                if (keySecondary)
                {
                    SetAnim("fsecond");
                }
                if (keyAttack)
                {
                    SetAnim("fattack");
                }
            }

            #endregion
        }
Exemplo n.º 8
0
 /// <summary>
 /// Checks for x-based collisions.
 /// This method has been verified!
 /// </summary>
 /// <param name="map">The map.</param>
 /// <param name="pLoc">The previous location.</param>
 public void CheckXCollision(Map map, Vector2 pLocation)
 {
     if (Trajectory.X + CollisionMove > 0f)
         if (map.CheckCollision(new Vector2(Location.X + 25f, Location.Y - 15f)))
             Location.X = pLocation.X;
     if (Trajectory.X + CollisionMove < 0f)
         if (map.CheckCollision(new Vector2(Location.X - 25f, Location.Y - 15f)))
             Location.X = pLocation.X;
 }
Exemplo n.º 9
0
 /// <summary>
 /// Updates all active particles.
 /// </summary>
 /// <param name="frameTime">The frame time - time delta that has elapsed since the last update.</param>
 /// <param name="map">The current map.</param>
 /// <param name="characters">The characters array.</param>
 public void UpdateParticles(float frameTime, Map map, Character[] characters)
 {
     for (int i = 0; i < particles.Length; i++)
     {
         if (particles[i] != null)
         {
             particles[i].Update(frameTime, map, this, characters);
             if (!particles[i].Exists)
                 particles[i] = null;
         }
     }
 }
Exemplo n.º 10
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            map = new Map();

            characterDefinitions[(int)CharacterType.Player1] = new CharacterDefinition("player",CharacterType.Player1);
            characterDefinitions[(int)CharacterType.Zombie] = new CharacterDefinition("zombie",CharacterType.Zombie);

            Sound.Initialize();
            Music.Initialize();

            QuakeManager.Init();

            base.Initialize();

            // override menu for debugging!
            //NewGame();
        }
Exemplo n.º 11
0
 public MapScript(Map _map)
 {
     this.map = _map;
     Flags = new MapFlags(32);
     Lines = new MapScriptLine[128];
 }