Exemplo n.º 1
0
        public Rock(Vector3 spawnPosition, Environment environment)
            : base(new Box(spawnPosition, 1, 1, 1, MASS))
        {
            this.environment = environment;

            // Create the rendering component. Since the cube model is 1x1x1,
            // it needs to be scaled to match the size of each individual box.
            Matrix scaling = Matrix.CreateScale(1, 1, 1);
            BasicModelComponent drawComponent = new CubeRenderComponent(this, scaling);
            this.AttachComponent(drawComponent);

            grabbable = new GrabbableComponent(this, 0, 100);
            grabbable.OnThrow += OnRockThrow;
            this.AttachComponent(grabbable);
        }
Exemplo n.º 2
0
        public IceCream(Vector3 spawnPosition, float healAmount, float healTime, Environment environment)
            : base(new Box(spawnPosition, 1, 1, 1, .01f))
        {
            this.healAmount = healAmount;
            this.healTime = healTime;
            this.environment = environment;

            // Create the rendering component. Since the cube model is 1x1x1,
            // it needs to be scaled to match the size of each individual box.
            Matrix scaling = Matrix.CreateScale(1f, 1f, 1f);
            BasicModelComponent drawComponent = new IceCreamRenderComponent(this, scaling);
            this.AttachComponent(drawComponent);

            grabbable = new GrabbableComponent(this, 0, 100);
            grabbable.OnGrab += OnPopsiclePickup;
            this.AttachComponent(grabbable);
        }
Exemplo n.º 3
0
        public FightingRobot(int lives, Vector3 spawnPosition, PlayerIndex controllingPlayer, int team, Environment environment, Color color)
            : base("FightingRobot", lives, new Box(spawnPosition, BEPU_PHYSICS_WIDTH, BEPU_PHYSICS_HEIGHT, BEPU_PHYSICS_DEPTH, MASS), 
            controllingPlayer, team, environment, color)
        {
            grabbableComponent = new GrabbableComponent(this, THROW_MIN_FLINCH, THROW_MAX_FLINCH);
            this.AttachComponent(grabbableComponent);

            BasicModelComponent drawComponent = new RobotRenderComponent(this, BEPU_PHYSICS_HEIGHT, SCALE, color);
            this.AttachComponent(drawComponent);

            //BasicModelComponent drawComponent2 = new CubeRenderComponent(this, Matrix.CreateScale(BEPU_PHYSICS_WIDTH, BEPU_PHYSICS_HEIGHT, BEPU_PHYSICS_WIDTH));
            //this.AttachComponent(drawComponent2);

            JumpComponent jumpComponent = new JumpComponent(this, JUMP_HEIGHT, MAX_JUMPS, environment);
            this.AttachComponent(jumpComponent);

            MoveComponent moveComponent = new MoveComponent(this, SPEED);
            this.AttachComponent(moveComponent);

            grabComponent = new GrabComponent(this, environment, THROW_BASE_DAMAGE, THROW_MAX_DAMAGE);
            this.AttachComponent(grabComponent);

            punchComponent = new PunchComponent(this, environment, PUNCH_SPEED, PUNCH_BASE_DAMAGE, PUNCH_MAX_DAMAGE, PUNCH_MIN_FLINCH, PUNCH_MAX_FLINCH);
            this.AttachComponent(punchComponent);

            FireProjectileComponent fireProjectileComponent = new FireProjectileComponent(this, FIRE_SPEED, FIRE_VELOCITY, environment, FIRE_BASE_DAMAGE, FIRE_MAX_DAMAGE, FIRE_MIN_FLINCH, FIRE_MAX_FLINCH);
            this.AttachComponent(fireProjectileComponent);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Forces this entity to lose grip of the grabbed object
 /// </summary>
 public void LoseGrip()
 {
     this.grabbedObject = null;
 }
Exemplo n.º 5
0
        public override void Update(GameTime gameTime)
        {
            if (!IsGrabbingObject)
            {
                // Do a grab if nothing is currently grabbed.
                if (GameplayBindings.IsGrab(controllingPlayer))
                {
                    // Get all the grabbable components available in this frame.
                    List<GrabbableComponent> grabbables = environment.GetEntitiesWithComponent<GrabbableComponent>("GrabbableComponent");

                    // Get all the entities colliding with the hitbox
                    EntityCollidableCollection overlappedCollideables = bepuPhysicsComponent.Box.CollisionInformation.OverlappedEntities;

                    // Iterate through the colliding entities and Grab any entity if it is grabbable.
                    EntityCollidableCollection.Enumerator enumerator = overlappedCollideables.GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        BEPUphysics.Entities.Entity collidingEntity = enumerator.Current;
                        // Check if the entity is equal to any of the grabbables.
                        for (int i = 0; i < grabbables.Count; i++)
                        {
                            if (collidingEntity == grabbables[i].GetGrabbableBox())
                            {
                                bool success = grabbables[i].Grab(this);
                                if (success)
                                {
                                    grabbedObject = grabbables[i];
                                    break;
                                }
                            }
                        }
                        if (IsGrabbingObject)
                        {
                            break;
                        }
                    }

                }
            }
            else
            {
                // Do a throw if something is currently being grabbed.
                if (GameplayBindings.IsThrow(controllingPlayer))
                {
                    // Do a throw in the direction of the left analog stick
                    Vector2 direction = InputState.GetLeftAnalogStick(controllingPlayer);

                    // Determine how much damage to do. This will scale linearly
                    float rage = this.health.RageMeter;
                    float damage = baseDamage + ((maxDamage - baseDamage) / 99) * (100 - rage);
                    if (rage == 0)
                    {
                        damage *= 2; // DOUBLE DAMAGE! RAAAAAAAAAGE MODE.
                    }

                    grabbedObject.Throw(direction, damage);
                    this.grabbedObject = null; // Let go!
                }
            }
        }