コード例 #1
0
ファイル: Slime.cs プロジェクト: Babelz/jamipeli
            public Spit(Player target, Vector2 position)
            {
                Size    = new Size(64, 32);
                random  = new Random();
                texture = Game.Instance.Content.Load <Texture2D>("spit");

                body = BodyFactory.CreateRectangle(Game.Instance.World,
                                                   ConvertUnits.ToSimUnits(texture.Height),
                                                   ConvertUnits.ToSimUnits(texture.Width), 1f, this);

                body.Friction      = 0f;
                body.BodyType      = BodyType.Dynamic;
                body.Restitution   = 0f;
                body.LinearDamping = 5f;
                body.Mass          = 1f;
                Position           = new Vector2(position.X, position.Y + Size.Height);

                aliveTime = 1250;

                body.OnCollision += new OnCollisionEventHandler(body_OnCollision);

                targetinComponent = new TargetingComponent <Player>(this);
                targetinComponent.ChangeTarget(target);

                direction = new Vector2(targetinComponent.VelocityToTarget.X * 25, 0);
            }
コード例 #2
0
        private void FindPlayer(ref NodeStatus status)
        {
            TargetingComponent targetingComponent = Owner.FirstComponentOfType <TargetingComponent>();

            if (targetingComponent.HasTarget && targetingComponent.Target.Name.Contains("Player"))
            {
                Owner.Body.Velocity = Vector2.Zero;

                steeringComponent.Disable();

                status = NodeStatus.Success;
            }
            else
            {
                GameObject player = Owner.Game.FindGameObject(o => o.Name.Contains("Player"));

                if (player == null)
                {
                    return;
                }

                steeringComponent.Enable();

                steeringComponent.ChangeActiveBehavior(typeof(SeekBehavior));
                steeringComponent.Current.TargetX = player.Position.X;
                steeringComponent.Current.TargetY = player.Position.Y;

                spriterComponent.FlipX = Owner.Body.Velocity.X < 0f;

                status = NodeStatus.Running;
            }
        }
コード例 #3
0
ファイル: WeaponComponent.cs プロジェクト: Jntz/jamipeli
        public WeaponComponent(TargetingComponent<Monster> targetingComponent, Weapon startWeapon)
        {
            this.targetingComponent = targetingComponent;

            currentWeapon = startWeapon;
            effectDrawers = new List<EffectDrawer>();
            spriteFont = Game.Instance.Content.Load<SpriteFont>("default");
            weaponSound = Game.Instance.Content.Load<SoundEffect>("music\\baseballbat");
        }
コード例 #4
0
ファイル: Monster.cs プロジェクト: Jntz/jamipeli
        public Monster()
        {
            random = new Random();

            components.Add(timerWrapper = new TimerWrapper());
            timerWrapper.AutoCreateTimers = true;

            components.Add(brain = new FiniteStateMachine());
            components.Add(targetComponent = new TargetingComponent<Player>(this));
        }
コード例 #5
0
ファイル: Monster.cs プロジェクト: Babelz/jamipeli
        public Monster()
        {
            random = new Random();

            components.Add(timerWrapper   = new TimerWrapper());
            timerWrapper.AutoCreateTimers = true;

            components.Add(brain           = new FiniteStateMachine());
            components.Add(targetComponent = new TargetingComponent <Player>(this));
        }
コード例 #6
0
ファイル: Crawler.cs プロジェクト: siquel/BeatEmUp
        private void Attack(ref NodeStatus status)
        {
            TargetingComponent targetingComponent = Owner.FirstComponentOfType <TargetingComponent>();
            SkillRotation      rotation           = Owner.FirstComponentOfType <SkillRotation>();

            if (targetingComponent.HasTarget && targetingComponent.Target.Name.StartsWith("Player"))
            {
                status = NodeStatus.Running;

                rotation.Enable();
            }
            else
            {
                status = NodeStatus.Failed;

                rotation.Disable();
            }
        }
コード例 #7
0
ファイル: Blob.cs プロジェクト: siquel/BeatEmUp
        protected override void OnInitialize()
        {
            MonsterBuilder builder = new BlobBuilder();

            builder.Build(Owner);

            Tree tree = CreateTree();

            tree.Initialize();

            Owner.AddComponent(tree);

            spriterComponent = new SpriterComponent <Texture2D>(Owner, @"Animations\Boss\Boss");
            spriterComponent.Initialize();
            spriterComponent.ChangeAnimation("Walk");
            spriterComponent.Scale = 0.75f;

            Owner.AddComponent(spriterComponent);

            steeringComponent = Owner.FirstComponentOfType <SteeringComponent>();

            SteeringBehavior seek = new SeekBehavior()
            {
                DesiredVelocity = new Vector2(1.25f),
                MaxSpeed        = 1.25f
            };

            steeringComponent.AddBehavior(seek);

            steeringComponent.ChangeActiveBehavior(typeof(SeekBehavior));

            rotation           = Owner.FirstComponentOfType <SkillRotation>();
            targetingComponent = Owner.FirstComponentOfType <TargetingComponent>();

            BossHealthComponent c = new BossHealthComponent(Owner);

            c.Initialize();
            Owner.AddComponent(c);

            rotation.Enable();
        }
コード例 #8
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;
        }
コード例 #9
0
ファイル: Player.cs プロジェクト: khvdev/jamipeli
        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;
        }
コード例 #10
0
ファイル: Slime.cs プロジェクト: Jntz/jamipeli
            public Spit(Player target, Vector2 position)
            {
                Size = new Size(64, 32);
                random = new Random();
                texture = Game.Instance.Content.Load<Texture2D>("spit");

                body = BodyFactory.CreateRectangle(Game.Instance.World,
                     ConvertUnits.ToSimUnits(texture.Height),
                     ConvertUnits.ToSimUnits(texture.Width), 1f, this);

                body.Friction = 0f;
                body.BodyType = BodyType.Dynamic;
                body.Restitution = 0f;
                body.LinearDamping = 5f;
                body.Mass = 1f;
                Position = new Vector2(position.X, position.Y + Size.Height);

                aliveTime = 1250;

                body.OnCollision += new OnCollisionEventHandler(body_OnCollision);

                targetinComponent = new TargetingComponent<Player>(this);
                targetinComponent.ChangeTarget(target);

                direction = new Vector2(targetinComponent.VelocityToTarget.X * 25, 0);
            }