コード例 #1
0
ファイル: DeadState.cs プロジェクト: ray476/GameDesignProject
 public DeadState(AbsAvatarObject avatar)
     : base(avatar)
 {
     avatar.Velocity = new Vector2(0, -1f);
     avatar.Hitbox   = new BoundingBox(new Vector3(0), new Vector3(0));
     updateTilRez    = 0;
 }
コード例 #2
0
 public RightFallingState(AbsAvatarObject avatar)
     : base(avatar)
 {
     Console.WriteLine("rght falling");
     avatar._velocity.X = 1.25f;
     avatar.isGrounded  = false;
 }
コード例 #3
0
 public LeftIdleFallingState(AbsAvatarObject avatar)
     : base(avatar)
 {
     Console.WriteLine("left idle falling");
     avatar._velocity.X = 0;
     avatar.isGrounded  = false;
 }
コード例 #4
0
 public RightWalkingState(AbsAvatarObject avatar)
     : base(avatar)
 {
     Console.WriteLine("right walking");
     avatar.isGrounded  = true;
     avatar._velocity.X = 1.25f;
     avatar._velocity.Y = 0;
 }
コード例 #5
0
 public RightIdleState(AbsAvatarObject avatar)
     : base(avatar)
 {
     Console.WriteLine("right idle");
     avatar.isGrounded  = true;
     avatar._velocity.X = 0;
     avatar._velocity.Y = 0;
 }
コード例 #6
0
 public LeftJumpingIdleState(AbsAvatarObject avatar)
     : base(avatar)
 {
     // Console.WriteLine("left idle jumping");
     avatar._velocity.X = 0;
     if (avatar.isGrounded)
         avatar._velocity.Y = -2.6f;
     avatar.isGrounded = false;
 }
コード例 #7
0
 public Level_Generator(ContentManager manager, Camera camera, AbsAvatarObject avatar, AudioManager audio)
 {
     content             = manager;
     screen_dimensions.X = camera.Viewport.Width;
     screen_dimensions.Y = camera.Viewport.Height;
     camera_position     = camera.Position;
     current_density     = starting_density;
     avatarObject        = avatar;
     this.audio          = audio;
 }
コード例 #8
0
 public RightJumpingState(AbsAvatarObject avatar)
     : base(avatar)
 {
     //Console.WriteLine("right jumping");
     avatar._velocity.X = 1.25f;
     if (avatar.isGrounded)
     {
         avatar._velocity.Y = -2.6f;
     }
     avatar.isGrounded = false;
 }
コード例 #9
0
        private static void TopCollide(AbsAvatarObject avatar, AbsObject obj, bool[] directionsBlocked)
        {
            if (obj is BlockObject || obj is PlatformObject)
            {
                avatar._velocity.Y = 0;
                avatar.Displace(0, 0.5f);
                directionsBlocked[0] = true;
            }
            else if (obj is EnemyObject)
            {
                avatar.TakeDamage();
                avatar.ObjectsToNotCollide.Add(obj);
            }
            else if (obj is ItemObject)
            {
                switch (((ItemObject)obj).State)
                {
                case "super":
                    avatar.Super();
                    avatar.hud.ChangeScore(1000);
                    break;

                case "fire":
                    avatar.Fire();
                    avatar.hud.ChangeScore(1000);
                    break;

                case "coin":
                    avatar.hud.GetCoin();
                    break;

                case "star":
                    avatar.hud.ChangeScore(1000);
                    break;

                case "1up":
                    avatar.hud.ChangeLife(1);
                    break;

                default:
                    break;
                }
            }
            else
            {
                avatar.ObjectsToNotCollide.Add(obj);
            }
        }
コード例 #10
0
 public MiscObject(Vector2 startPos, ContentManager content, string type)
 {
     _opacity             = 1.0f;
     isVisible            = true;
     deleteThis           = false;
     HiddenObject         = null;
     WarpDestination      = null;
     inRange              = false;
     isTouching           = false;
     _type                = type;
     _mario               = null;
     _hiddenObj           = null;
     _spriteFactory       = new MiscSpriteFactory(content);
     _sprite              = _spriteFactory.build(type);
     _hitbox              = GetHitbox(type, startPos);
     _position            = startPos;
     _velocity            = new Vector2(0);
     _acceleration        = new Vector2(0);
     _objectsToNotCollide = new List <AbsObject>();
     _objectsToAdd        = new List <AbsObject>();
 }
コード例 #11
0
 public StandardCommand(AbsAvatarObject recieve)
 {
     this.recievier = recieve;
 }
コード例 #12
0
 public TakeDamageCommand(AbsAvatarObject recieve)
 {
     this.recievier = recieve;
 }
コード例 #13
0
 public AbsMovementState(AbsAvatarObject avatar)
 {
     this.avatar   = avatar;
     factory       = new MetaFactory(avatar.powerUpState, avatar.content);
     avatar.Sprite = factory.build(this);
 }
コード例 #14
0
 public DownCommand(AbsAvatarObject recieve)
 {
     this.recievier = recieve;
 }
コード例 #15
0
 public AbsPowerState(AbsAvatarObject avatar)
 {
     this.avatar   = avatar;
     factory       = new MetaFactory(this, avatar.content);
     avatar.Sprite = factory.build(avatar.movementState);
 }
コード例 #16
0
 public SuperState(AbsAvatarObject avatar)
     : base(avatar)
 {
     avatar.Hitbox = new BoundingBox(new Vector3(avatar.Position.X, avatar.Position.Y, 0),
                                     new Vector3(avatar.Position.X + 16, avatar.Position.Y + 32, 0));
 }
コード例 #17
0
 public SmallState(AbsAvatarObject avatar)
     : base(avatar)
 {
     avatar.Hitbox = new BoundingBox(new Vector3(avatar.Position.X + 2, avatar.Position.Y, 0),
                                     new Vector3(avatar.Position.X + 14, avatar.Position.Y + 16, 0));
 }
コード例 #18
0
 public WarpUpState(AbsAvatarObject avatar) : base(avatar)
 {
 }
コード例 #19
0
        private static void BottomCollide(AbsAvatarObject avatar, AbsObject obj, bool[] directionsBlocked)
        {
            if (obj is BlockObject || obj is PlatformObject)
            {
                avatar._velocity.Y   = 0;
                directionsBlocked[2] = true;
                avatar.isGrounded    = true;

                if (avatar.movementState is LeftJumpingIdleState || avatar.movementState is LeftJumpingState)
                {
                    avatar.movementState = new LeftIdleState(avatar);
                }
                else if (avatar.movementState is RightJumpingIdleState || avatar.movementState is RightJumpingState)
                {
                    avatar.movementState = new RightIdleState(avatar);
                }
            }
            else if (obj is EnemyObject)
            {
                avatar._velocity.Y = -2;
                avatar.hud.ChangeScore(100);
            }
            else if (obj is ItemObject)
            {
                switch (((ItemObject)obj).State)
                {
                case "super":
                    avatar.Super();
                    avatar.hud.ChangeScore(1000);
                    break;

                case "fire":
                    avatar.Fire();
                    avatar.hud.ChangeScore(1000);
                    break;

                case "coin":
                    avatar.hud.GetCoin();
                    break;

                case "star":
                    avatar.hud.ChangeScore(1000);
                    break;

                case "1up":
                    avatar.hud.ChangeLife(1);
                    break;

                default:
                    break;
                }
            }
            else if (obj is MiscObject)
            {
                if (((MiscObject)obj).Type == "pipe_head")
                {
                    avatar._velocity.Y   = 0;
                    avatar.PipeContacted = (MiscObject)obj;
                    directionsBlocked[2] = true;
                    avatar.isGrounded    = true;

                    if (avatar.movementState is LeftJumpingIdleState || avatar.movementState is LeftJumpingState)
                    {
                        avatar.movementState = new LeftIdleState(avatar);
                    }
                    else if (avatar.movementState is RightJumpingIdleState || avatar.movementState is RightJumpingState)
                    {
                        avatar.movementState = new RightIdleState(avatar);
                    }
                }
                else
                {
                    avatar.ObjectsToNotCollide.Add(obj);
                }
            }
            else
            {
                avatar.ObjectsToNotCollide.Add(obj);
            }
        }
コード例 #20
0
 public LeftCrouchingState(AbsAvatarObject avatar)
     : base(avatar)
 {
     avatar._velocity.X = 0;
     avatar._velocity.Y = 1;
 }
コード例 #21
0
 public LeftCommand(AbsAvatarObject recieve)
 {
     this.reciever = recieve;
 }
コード例 #22
0
 public RightCommand(AbsAvatarObject recieve)
 {
     this.recievier = recieve;
 }
コード例 #23
0
        private static void SideCollide(AbsAvatarObject avatar, AbsObject obj, bool[] directionsBlocked)
        {
            if (obj is BlockObject || obj is PlatformObject)
            {
                avatar._velocity.X = 0;
                if (Collision.GetCollisionType(avatar, obj) == Collision.CollisionType.RSide)
                {
                    directionsBlocked[1] = true;
                }
                else
                {
                    directionsBlocked[3] = true;
                }
                if (avatar.movementState is LeftWalkingState)
                {
                    avatar.movementState = new LeftIdleState(avatar);
                }
                else if (avatar.movementState is RightWalkingState)
                {
                    avatar.movementState = new RightIdleState(avatar);
                }
                else if (avatar.movementState is LeftJumpingState)
                {
                    avatar.movementState = new LeftJumpingIdleState(avatar);
                }
                else if (avatar.movementState is RightJumpingState)
                {
                    avatar.movementState = new RightJumpingIdleState(avatar);
                }
            }
            else if (obj is EnemyObject)
            {
                avatar.TakeDamage();
                avatar.ObjectsToNotCollide.Add(obj);
            }
            else if (obj is ItemObject)
            {
                switch (((ItemObject)obj).State)
                {
                case "super":
                    avatar.Super();
                    avatar.hud.ChangeScore(1000);
                    break;

                case "fire":
                    avatar.Fire();
                    avatar.hud.ChangeScore(1000);
                    break;

                case "coin":
                    avatar.hud.GetCoin();
                    break;

                case "star":
                    avatar.hud.ChangeScore(1000);
                    break;

                case "1up":
                    avatar.hud.ChangeLife(1);
                    break;

                default:
                    break;
                }
            }
            else if (obj is MiscObject)
            {
                if (((MiscObject)obj).Type == "pipe_head" || ((MiscObject)obj).Type == "pipe_section")
                {
                    avatar._velocity.X = 0;
                    if (Collision.GetCollisionType(avatar, obj) == Collision.CollisionType.RSide)
                    {
                        directionsBlocked[1] = true;
                    }
                    else
                    {
                        directionsBlocked[3] = true;
                    }
                    if (avatar.movementState is LeftWalkingState)
                    {
                        avatar.movementState = new LeftIdleState(avatar);
                    }
                    else if (avatar.movementState is RightWalkingState)
                    {
                        avatar.movementState = new RightIdleState(avatar);
                    }
                    else if (avatar.movementState is LeftJumpingState)
                    {
                        avatar.movementState = new LeftJumpingIdleState(avatar);
                    }
                    else if (avatar.movementState is RightJumpingState)
                    {
                        avatar.movementState = new RightJumpingIdleState(avatar);
                    }
                }
                else
                {
                    avatar.ObjectsToNotCollide.Add(obj);
                }
            }
            else
            {
                avatar.ObjectsToNotCollide.Add(obj);
            }
        }
コード例 #24
0
 public SuperCommand(AbsAvatarObject recieve)
 {
     this.recievier = recieve;
 }