public void Move(GameTime gameTime, bool notRunning = true) //SAFE TO ASSUME DOESN'T WORK. WASN'T TESTED WITH NPC { bool hPass = false; //Console.WriteLine("HSTATE: " + curStateH); //Console.WriteLine("VSTATE: " + curStateV); //Console.WriteLine(timer); timer += gameTime.ElapsedGameTime.TotalSeconds; if (timer > animSpeed) { if (notRunning) { walkDown.advanceFrame(); } timer = 0; } if (curStateH == HorizontalState.Right) // && body.LinearVelocity.X > 0) { if (body.LinearVelocity.X > 0) { hPass = true; flipped = false; //SetStateH(HorizontalState.Right); //curAnim = walkRight; offsetX = 9; //offsetY = 25; //animIndex = (int)State.Left; animIndex = walkDown.getFrame(); } } else if (curStateH == HorizontalState.Left) // && body.LinearVelocity.X < 0) { if (body.LinearVelocity.X < 0) { hPass = true; flipped = true; //SetStateH(HorizontalState.Left); //curAnim = walkRight; offsetX = 9; //offsetY = 25; //animIndex = (int)State.Left; animIndex = walkDown.getFrame(); } } else if (moveTimer == 0) //Resets direction when movement begins { offsetX = 0; } if (curStateV == VerticalState.Up) // && body.LinearVelocity.Y < 0) { if (body.LinearVelocity.Y < 0) { flipped = false; //SetStateV(VerticalState.Up); //curAnim = walkUp; //offsetX = 0; offsetY = 54; //animIndex = (int)State.Left; animIndex = walkDown.getFrame(); } } else if (curStateV == VerticalState.Down) // && body.LinearVelocity.Y > 0) { if (body.LinearVelocity.Y > 0) { flipped = false; //SetStateV(VerticalState.Down); //curAnim = walkDown; //offsetX = 0; offsetY = 0; //animIndex = (int)State.Left; animIndex = walkDown.getFrame(); } } else { if (moveTimer == 0) //Resets direction when movement begins { offsetY = 27; } if (!hPass) { SetStandingAnim(); } } }
private void advanceBattle(GameTime gameTime, KeyboardState prevStateKb, MouseState prevStateM) { //Console.WriteLine("Calling advance!"); switch (curPhase) { case Phase.IntroPhase: if (text.messageComplete()) { curPhase = Phase.PlayerPhase; } break; case Phase.PlayerPhase: if (waiter == null) { options.Update(prevStateKb, prevStateM); //selector.Update(prevState); } if ((Keyboard.GetState().IsKeyDown(Keys.Space) && prevStateKb.IsKeyUp(Keys.Space)) || (prevStateM.LeftButton == ButtonState.Pressed && Mouse.GetState().LeftButton == ButtonState.Released)) { switch (options.GetMagic()) { //Earth case "Earth": //playerMove = 0; playerMove = 1; magic = content.Load <Texture2D>("Battle/Effects/PkFireA_GRN"); toReturn = 254; magicColor = Color.Purple; curPhase = Phase.EnemyPhase; break; //Fire case "Fire": playerMove = 1; magic = content.Load <Texture2D>("Battle/Effects/PkFireA_GRN"); toReturn = 254; magicColor = Color.White; curPhase = Phase.EnemyPhase; break; //Water case "Water": playerMove = 1; magic = content.Load <Texture2D>("Battle/Effects/PkFireA_GRN"); toReturn = 254; magicColor = Color.LightGray; curPhase = Phase.EnemyPhase; break; } } break; case Phase.EnemyPhase: enemyMove = 0; curPhase = Phase.AttackPhase; break; case Phase.AttackPhase: if (enemy.health <= 0) { if (enemyType == 0 && magicColor.Equals(Color.White) || enemyType == 1 && magicColor.Equals(Color.Purple) || enemyType == 2 && magicColor.Equals(Color.LightGray)) { deathMessageDisplayed = false; curPhase = Phase.EnemyDeathPhase; flasher = enemy; enemy.ChangeToWhite(); flashTimer = -0.5; flashCounter = 1; timerMult = 0.5f; } else { toReturn = 2; } //text = new Hud(new string[] { "@The enemy dissipates into hollow armor." }, content, 30, 2, posY: 3, canClose: true); } else if (playerMove != -1) { if (playerMove == 0) { enemy.attacked = false; //text = new Hud(new string[] { "@Travis's attack!" }, content, 30, 2, posY: 3, canClose: true); //enemy.TakeDamage(1, combatTimer); waiter = enemy; //playerMove = -1; } else if (playerMove == 1) { //text = new Hud(new string[] { "@Travis tried PK Fire [!" }, content, 30, 2, posY: 3, canClose: true); //text.finishText(); Console.WriteLine("GetFrame: " + magicAnim.getFrame()); magicAnim.resetStart(); darkenTimer = 1; curPhase = Phase.AnimPhase; //if (magicAnim.getFrame() == 25) //playerMove = -1; //playerMove = -1; //TODO: Something enemy.DecreaseHealth(5); } playerMove = -1; } else if (enemyMove == 0) { flasher = enemy; flashTimer = 0; travis.attacked = false; text = new Hud(new string[] { "@enemy's attack!" }, content, 30, 2, posY: 3, canClose: true); //travis.TakeDamage(1, combatTimer); waiter = travis; enemyMove = -1; timerMult = 1; //flashCounter = 1; //flashTimer = 0; } else { curPhase = Phase.PlayerPhase; } break; case Phase.EnemyDeathPhase: //Refer to the if statement in the Update() function break; case Phase.AnimPhase: Console.WriteLine("anim"); if (magicAnim.getFrame() == magicAnim.frameCount) { Console.WriteLine("Skadoosh"); if (darkenTimer < 1) { darkenTimer += gameTime.ElapsedGameTime.TotalSeconds * 4; } else //end phase { //curPhase = Phase.AttackPhase; //magic.Dispose(); curPhase = Phase.BlinkPhase; enemyDraw = false; magicAnim.resetStart(); animTimer = 0; } } else { if (darkenTimer > 0.5) { darkenTimer -= gameTime.ElapsedGameTime.TotalSeconds * 5; } animTimer += gameTime.ElapsedGameTime.TotalSeconds; if (animTimer > 0.05) { animTimer -= 0.05; magicAnim.advanceFrame(); } } break; case Phase.BlinkPhase: animTimer += gameTime.ElapsedGameTime.TotalSeconds; if (animTimer > 0.07) { flashCount++; animTimer -= 0.07; if (flashCount < 11) { enemyDraw = !enemyDraw; } } if (flashCount == 11) { //flashCount = 0; enemyDraw = true; //curPhase = Phase.AttackPhase; } else if (flashCount == 17) { flashCount = 0; curPhase = Phase.AttackPhase; } break; default: break; } }