Example #1
0
        public Shoemon()
            : base()
        {
            Animation = Game.Instance.Content.Load<CharacterModel>("monsters\\shoemon").CreateAnimator("Shoemon");
               // Animation.ChangeAnimation("attack");
            Animation.Scale = 0.27f;

            Animation.AnimationEnded += animation_Finished;

            body = BodyFactory.CreateRectangle(Game.Instance.World,
                ConvertUnits.ToSimUnits(256*Animation.Scale),
                ConvertUnits.ToSimUnits(256*Animation.Scale), 1f, this);

            body.Friction = 0f;
            body.BodyType = BodyType.Dynamic;
            body.Restitution = 0f;
            body.LinearDamping = 5f;
            body.Mass = 1f;
            Position = Vector2.Zero;

            GameplayState gameplayState = Game.Instance.GameStateManager.States
                .FirstOrDefault(s => s is GameplayState)
                as GameplayState;

            body.IgnoreCollisionWith(gameplayState.RightWall.Body);
            body.IgnoreCollisionWith(gameplayState.LeftWall.Body);
            body.OnCollision += new OnCollisionEventHandler(body_OnCollision);
            body.UserData = this;

            components.Add(Health = new HealthComponent(50, 75));

            brain.PushState(MoveToArea);

            if (sound == null && soundInstance == null)
            {
                sound = Game.Instance.Content.Load<SoundEffect>("music\\tomps");
                soundInstance = sound.CreateInstance();
            }
        }
Example #2
0
        public Player(World world)
        {
            Size = new Size(100, 100);
            Velocity = new Vector2(Speed, 0);

            // Inputin alustus.
            defaultSetup = new InputControlSetup();
            controller = new InputController(Game.Instance.InputManager);
            controller.ChangeSetup(defaultSetup);

            Game.Instance.MapManager.OnMapChanged += new MapManagerEventHandler(MapManager_OnMapChanged);
            animator = Game.Instance.Content.Load<CharacterModel>("playeri\\plaery").CreateAnimator("player");
            animator.ChangeAnimation("attack");
            animator.Scale = 0.35f;

            // Colliderin alustus.
            body = BodyFactory.CreateRectangle(world, ConvertUnits.ToSimUnits(100), ConvertUnits.ToSimUnits(100), 1.0f);
            body.Friction = 0f;
            body.BodyType = BodyType.Dynamic;
            body.Restitution = 0f;
            body.LinearDamping = 5f;
            body.UserData = this;
            Position = Vector2.Zero;
            Size = new Size(100, 100);

            HealthComponent health = new HealthComponent(100);
            // Komponentti alustus.
            components.Add(targetingComponent = new TargetingComponent<Monster>(this));
            components.Add(directionalArrow = new DirectionalArrow());
            components.Add(weaponComponent = new WeaponComponent(targetingComponent, new BaseballBat()));
            components.Add(health);

            Game.Instance.MapManager.OnMapChanged += new MapManagerEventHandler(MapManager_OnMapChanged);
               // weaponSound = Game.Instance.Content.Load<SoundEffect>("music\\baseballbat");
            Speed = 15f;
        }
Example #3
0
        public Slime()
            : base()
        {
            Animation = Game.Instance.Content.Load<CharacterModel>("monsters\\blob").CreateAnimator("blob");

            Animation.Scale = 0.60f;
            Animation.AnimationEnded +=Animation_AnimationEnded;
            body = BodyFactory.CreateRectangle(Game.Instance.World,
                ConvertUnits.ToSimUnits(256 * Animation.Scale),
                ConvertUnits.ToSimUnits(256 * Animation.Scale), 1f, this);

            body.Friction = 0f;
            body.BodyType = BodyType.Dynamic;
            body.Restitution = 0f;
            body.LinearDamping = 5f;
            body.Mass = 1f;
            Position = Vector2.Zero;

            GameplayState gameplayState = Game.Instance.GameStateManager.States
                 .FirstOrDefault(s => s is GameplayState)
                 as GameplayState;

            body.IgnoreCollisionWith(gameplayState.RightWall.Body);
            body.IgnoreCollisionWith(gameplayState.LeftWall.Body);
            body.UserData = this;

            components.Add(Health = new HealthComponent(random.Next(250, 300)));

            brain.PushState(MoveToArea);

            if (sound == null && soundInstance == null)
            {
                sound = Game.Instance.Content.Load<SoundEffect>("music\\slime2");
                soundInstance = sound.CreateInstance();
            }
        }
Example #4
0
        public Megablob()
            : base()
        {
            Animation = Game.Instance.Content.Load<CharacterModel>("monsters\\bossi").CreateAnimator("boss");

            Animation.Scale = 0.75f;

            body = BodyFactory.CreateRectangle(Game.Instance.World,
                ConvertUnits.ToSimUnits(256 * Animation.Scale / 2),
                ConvertUnits.ToSimUnits(256 * Animation.Scale / 2), 1f, this);

            body.Friction = 0f;
            body.BodyType = BodyType.Dynamic;
            body.Restitution = 0f;
            body.LinearDamping = 5f;
            body.Mass = 2.5f;
            Position = Vector2.Zero;

            GameplayState gameplayState = Game.Instance.GameStateManager.States
                 .FirstOrDefault(s => s is GameplayState)
                 as GameplayState;

            body.IgnoreCollisionWith(gameplayState.RightWall.Body);
            body.IgnoreCollisionWith(gameplayState.LeftWall.Body);
            body.UserData = this;

            body.OnCollision += new OnCollisionEventHandler(body_OnCollision);

            components.Add(Health = new HealthComponent(3500));

            brain.PushState(MoveToArea);

            timerWrapper.AddTimer("player", 0);

            spits = new List<BossSpit>();

            if (idleSound == null && idleSoundInstance == null)
            {
                idleSound = Game.Instance.Content.Load<SoundEffect>("music\\weird_monster");
                idleSoundInstance = idleSound.CreateInstance();
            }

            if (randomHampaat == null && randomHampaatInstance == null)
            {
                randomHampaat = Game.Instance.Content.Load<SoundEffect>("music\\randomhampaat");
                randomHampaatInstance = randomHampaat.CreateInstance();
            }
        }
Example #5
0
 public void ClearTarget()
 {
     TargetHealthComponent = null;
     Target = null;
 }