Exemple #1
0
        public virtual Boolean hitByEnemy(KeyboardState keyState, HitInfo hitInfo, Rectangle collisionZone)
        {
            //Check if blocked or not
            //int hitStun, int blockStun, Hitzone hitzone, float? xVel, float? yVel
            if (!hitInfo.Unblockable && (Sprite.CurrentMoveAnimation.CharacterState != CharacterState.HIT || Sprite.CurrentAnimation.Contains("block")) &&
                !Sprite.CurrentMoveAnimation.IsAttack && isAttackBlocked(keyState, hitInfo.Hitzone))
            {
                if (Sprite.CurrentMoveAnimation.CharacterState == CharacterState.AIRBORNE)
                {
                    Sprite.CurrentAnimation = "airblock";
                }
                else if (Sprite.CurrentMoveAnimation.CharacterState == CharacterState.CROUCHING)
                {
                    Sprite.CurrentAnimation = "crouchblock";
                }
                else
                {
                    Sprite.CurrentAnimation = "block";
                }

                HitAnimation block = (HitAnimation)Sprite.CurrentMoveAnimation;
                Console.WriteLine("DID A BLOCK!");
                block.reset();
                block.HitStunCounter = hitInfo.Blockstun;
                Console.WriteLine(block.HitStunCounter);
                ProjectileManager.createHitparticle(collisionZone, HitType.BLOCK);
                return(false);
            }
            else
            {
                ProjectileManager.createHitparticle(collisionZone, hitInfo.HitType);
                // So many different ways to get hit
                //
                if (Sprite.CurrentMoveAnimation.CharacterState == CharacterState.CROUCHING)
                {
                    Sprite.CurrentAnimation = "crouchhit";
                }
                else if (hitInfo.Hitzone == Hitzone.LOW)
                {
                    Sprite.CurrentAnimation = "lowhit";
                }
                else
                {
                    Sprite.CurrentAnimation = "hit";
                }



                Sprite.CurrentMoveAnimation.CurrentFrame = Sprite.CurrentMoveAnimation.StartFrame;
                CurrentHealth -= ComboManager.calculateProratedDamage(hitInfo);

                if (hitInfo.FreezeOpponent)
                {
                    Sprite.CurrentAnimation = "freeze";
                }
                else
                {
                    // Not sure if this a bad idea memory wise
                    //
                    HitAnimation hit = (HitAnimation)Sprite.CurrentMoveAnimation;
                    hit.HitStunCounter = ComboManager.calculateProratedHitStun(hitInfo);
                    hit.reset();
                    if (CurrentHealth <= 0)
                    {
                        hitInfo = new HitInfo(100, 10, Hitzone.MID);
                        hitInfo.AirXVelocity = 300;
                        hitInfo.AirYVelocity = -100;
                    }
                    if (IsAirborne || hitInfo.ForceAirborne || CurrentHealth <= 0)
                    {
                        untechTime = hitInfo.AirUntechTime;
                        Sprite.CurrentAnimation = "falldown";
                        Position += new Vector2(0, -10);
                        if (hitInfo.AirXVelocity != null && hitInfo.AirYVelocity != null)
                        {
                            if (directionFacing == Direction.Right)
                            {
                                CurrentVelocity = new Vector2((float)-hitInfo.AirXVelocity, (float)hitInfo.AirYVelocity);
                            }
                            else
                            {
                                CurrentVelocity = new Vector2((float)hitInfo.AirXVelocity, (float)hitInfo.AirYVelocity);
                            }
                        }
                    }
                    else
                    {
                        GivePlayerMomentum(5, 4, false);
                        if (hitInfo.IsHardKnockDown)
                        {
                            // Make em HARD DOWN
                            //
                            Sprite.CurrentAnimation = "knockdown";
                        }
                    }
                }

                ComboManager.registerHit(hitInfo);
                return(true);
            }
        }
Exemple #2
0
        protected void moveParse(ContentManager content, String character, Player player, Dictionary <String, Object> moveInfo, Dictionary <String, Texture2D> spriteTextures, Dictionary <String, MoveInput> moveInputList)
        {
            String name = (String)moveInfo["name"];

            Texture2D texture = null;

            if (!spriteTextures.TryGetValue((String)moveInfo["sprite"], out texture))
            {
                texture = content.Load <Texture2D>(character + "/" + (String)moveInfo["sprite"]);
                spriteTextures.Add((String)moveInfo["sprite"], texture);
            }

            CharacterState moveState;

            Enum.TryParse((String)moveInfo["CharacterState"], true, out moveState);

            Move newMove;

            if (moveState == CharacterState.HIT || moveState == CharacterState.BLOCK)
            {
                newMove = new HitAnimation(
                    texture,
                    int.Parse((String)moveInfo["XImageStart"]),
                    int.Parse((String)moveInfo["YImageStart"]),
                    int.Parse((String)moveInfo["Width"]),
                    int.Parse((String)moveInfo["Height"]),
                    int.Parse((String)moveInfo["FrameCount"]),
                    int.Parse((String)moveInfo["Columns"]),
                    float.Parse((String)moveInfo["FrameLength"]),
                    moveState
                    );
            }
            else
            {
                newMove = new Move(
                    texture,
                    int.Parse((String)moveInfo["XImageStart"]),
                    int.Parse((String)moveInfo["YImageStart"]),
                    int.Parse((String)moveInfo["Width"]),
                    int.Parse((String)moveInfo["Height"]),
                    int.Parse((String)moveInfo["FrameCount"]),
                    int.Parse((String)moveInfo["Columns"]),
                    float.Parse((String)moveInfo["FrameLength"]),
                    moveState
                    );
            }

            if (moveInfo.ContainsKey("IsAttack"))
            {
                newMove.IsAttack = Boolean.Parse((String)moveInfo["IsAttack"]);
            }

            if (moveInfo.ContainsKey("BackupMove"))
            {
                newMove.BackupMove = (String)moveInfo["BackupMove"];
            }

            if (moveInfo.ContainsKey("LoopCount"))
            {
                newMove.LoopCount = int.Parse((String)moveInfo["LoopCount"]);
            }

            if (moveInfo.ContainsKey("FrameLengthInfo"))
            {
                String        framelengthString  = (String)moveInfo["FrameLengthInfo"];
                List <String> frameLengthList    = new List <String>(framelengthString.Split(','));
                List <int>    frameLengthIntList = frameLengthList.ConvertAll(s => Int32.Parse(s));
                int[]         frameLengthInfo    = frameLengthIntList.ToArray();

                newMove.SetFrameLengthInfo(frameLengthInfo);
            }

            if (moveInfo.ContainsKey("StartFrame"))
            {
                newMove.StartFrame = int.Parse((String)moveInfo["StartFrame"]);
            }


            if (moveInfo.ContainsKey("XMovement"))
            {
                String        xMovementString  = (String)moveInfo["XMovement"];
                List <String> xMovementList    = new List <String>(xMovementString.Split(','));
                List <int>    xMovementIntList = xMovementList.ConvertAll(s => Int32.Parse(s));
                int[]         xMovementInfo    = xMovementIntList.ToArray();

                newMove.SetXMovementInfo(xMovementInfo);
            }

            if (moveInfo.ContainsKey("Hitbox"))
            {
                List <String> hitInfo = (List <String>)moveInfo["Hitbox"];
                foreach (String hitBox in hitInfo)
                {
                    String[] hitBoxData = hitBox.Split(';');
                    // Console.WriteLine(int.Parse(hurtBoxData[0]));
                    if (hitBoxData.Count() > 1)
                    {
                        newMove.AddHitboxInfo(int.Parse(hitBoxData[0]),
                                              new Hitbox(hitBoxData[1], hitBoxData[2], hitBoxData[3], hitBoxData[4]));
                    }
                }
            }


            if (moveInfo.ContainsKey("Hurtbox"))
            {
                List <String> hurtInfo = (List <String>)moveInfo["Hurtbox"];
                foreach (String hurtBox in hurtInfo)
                {
                    if (hurtBox.Length > 0)
                    {
                        String[] hurtBoxData = hurtBox.Split(';');
                        // Console.WriteLine(int.Parse(hurtBoxData[0]));
                        newMove.AddHurtboxInfo(int.Parse(hurtBoxData[0]),
                                               new Hitbox(hurtBoxData[1], hurtBoxData[2], hurtBoxData[3], hurtBoxData[4]));
                    }
                }
            }

            Hitzone hitZone;

            //int test = (int)moveInfo["Blockstun"];

            if (moveInfo.ContainsKey("Hitzone") && moveInfo.ContainsKey("Hitstun") && moveInfo.ContainsKey("Blockstun"))
            {
                Enum.TryParse((String)moveInfo["Hitzone"], true, out hitZone);
                HitInfo hitMoveInfo = new HitInfo(int.Parse((String)moveInfo["Hitstun"]), int.Parse((String)moveInfo["Blockstun"]), hitZone);
                hitMoveInfo.Damage          = int.Parse((String)moveInfo["Damage"]);
                hitMoveInfo.IsHardKnockDown = Boolean.Parse((String)moveInfo["IsHardKnockDown"]);
                hitMoveInfo.AirUntechTime   = int.Parse((String)moveInfo["AirUntechTime"]);
                hitMoveInfo.AirYVelocity    = int.Parse((String)moveInfo["AirYVelocity"]);
                hitMoveInfo.AirXVelocity    = int.Parse((String)moveInfo["AirXVelocity"]);
                if (moveInfo.ContainsKey("ResetHitInfo"))
                {
                    String        resetHitInfoString = (String)moveInfo["ResetHitInfo"];
                    List <String> resetHitInfoList   = new List <String>(resetHitInfoString.Split(','));
                    List <int>    resetInfoIntList   = resetHitInfoList.ConvertAll(s => Int32.Parse(s));
                    foreach (int resetSpot in resetInfoIntList)
                    {
                        newMove.AddResetInfo(resetSpot, true);
                    }
                }
                if (moveInfo.ContainsKey("ForceAirborne"))
                {
                    hitMoveInfo.ForceAirborne = Boolean.Parse((String)moveInfo["ForceAirborne"]);
                }
                if (moveInfo.ContainsKey("FreezeMove"))
                {
                    hitMoveInfo.FreezeOpponent = Boolean.Parse((String)moveInfo["FreezeMove"]);
                }
                if (moveInfo.ContainsKey("Unblockable"))
                {
                    hitMoveInfo.Unblockable = Boolean.Parse((String)moveInfo["Unblockable"]);
                }

                if (moveInfo.ContainsKey("HitType"))
                {
                    HitType hitType;
                    Enum.TryParse((String)moveInfo["HitType"], true, out hitType);
                    hitMoveInfo.HitType = hitType;
                }
                newMove.HitInfo = hitMoveInfo;
            }
            if (moveInfo.ContainsKey("NextAnimation"))
            {
                newMove.NextAnimation = (String)moveInfo["NextAnimation"];
            }
            if (moveInfo.ContainsKey("ProjectileCreationFrame"))
            {
                newMove.ProjectileCreationFrame = int.Parse((String)moveInfo["ProjectileCreationFrame"]);
            }

            if (moveInfo.ContainsKey("Input"))
            {
                String        moveInput = (String)moveInfo["Input"];
                String[]      inputs    = moveInput.Split(';');
                List <String> inputList = new List <String>(inputs);
                moveInputList.Add(name, new MoveInput(name, inputList));
            }
            player.Sprite.AddAnimation(name, newMove);
        }