protected void ResetStateTime(GameTime gameTime, BipedWeapon weapon, WeaponFunctions input) { TimeSpan extraTime = TimeSpan.FromTicks(weapon.TimeInState.Ticks - mDurationTicks); weapon.TimeInState = extraTime; weapon.CurrentState.Update(new GameTime(gameTime.TotalGameTime, extraTime, gameTime.IsRunningSlowly), weapon, input); }
public override void Update(GameTime gameTime, BipedWeapon weapon, WeaponFunctions input) { if (weapon.TimeInState.Ticks >= mDurationTicks) { weapon.CurrentState = BashSkill.ReadyState; ResetStateTime(gameTime, weapon, WeaponFunctions.Neutral); } }
public override void Update(GameTime gameTime, BipedWeapon weapon, WeaponFunctions input) { if (input == WeaponFunctions.TriggerPulled) { weapon.Fire(); weapon.CurrentState = BashSkill.SwingingState; } }
public override void Update(GameTime gameTime, BipedWeapon weapon, WeaponFunctions input) { if (weapon.TimeInState.Ticks >= mDurationTicks) { weapon.CurrentState = MachineGunSkill.ReadyState; ResetStateTime(gameTime, weapon, WeaponFunctions.Neutral); } }
public override void Update(GameTime gameTime, BipedWeapon weapon, WeaponFunctions input) { if (input == WeaponFunctions.TriggerPulled) { weapon.Fire(); weapon.CurrentState = BashSkill.SwingingState; } }
public override void Initialize(ContentManager contentLoader, ComponentManifest manifest) { string skillAssetName = (string)(manifest.Properties[ManifestKeys.RANGED_SKILL_ASSET_NAME]); ComponentManifest weaponManifest = contentLoader.Load <ComponentManifest>(Path.Combine("skills", skillAssetName)); Type weaponType = Type.GetType(weaponManifest.TypeFullName); object[] basicCtorParams = new object[] { Owner.Id }; RangedSkill = Activator.CreateInstance(weaponType, basicCtorParams) as BipedWeapon; RangedSkill.Initialize(contentLoader, weaponManifest); skillAssetName = (string)(manifest.Properties[ManifestKeys.MELEE_SKILL_ASSET_NAME]); weaponManifest = contentLoader.Load <ComponentManifest>(Path.Combine("skills", skillAssetName)); weaponType = Type.GetType(weaponManifest.TypeFullName); MeleeSkill = Activator.CreateInstance(weaponType, basicCtorParams) as BipedWeapon; MeleeSkill.Initialize(contentLoader, weaponManifest); }
public override void Update(GameTime gameTime, BipedWeapon weapon, WeaponFunctions input) { if (input == WeaponFunctions.TriggerPulled) { Actor owner = GameResources.ActorManager.GetActorById(weapon.OwnerActorId); WeaponResource wr = owner.GetBehavior <WeaponResource>(); if (wr.Value >= weapon.ResourceCostToUse) { weapon.Fire(); weapon.CurrentState = BlasterRifleSkill.FiringState; } else { weapon.DryFire(); weapon.CurrentState = BlasterRifleSkill.DryFireState; } } }
protected void ResetStateTime(GameTime gameTime, BipedWeapon weapon, WeaponFunctions input) { TimeSpan extraTime = TimeSpan.FromTicks(weapon.TimeInState.Ticks - mDurationTicks); weapon.TimeInState = extraTime; weapon.CurrentState.Update(new GameTime(gameTime.TotalGameTime, extraTime, gameTime.IsRunningSlowly), weapon, input); }
public virtual void Update(GameTime gameTime, BipedWeapon weapon, WeaponFunctions input) { }
public override void Update(GameTime gameTime, BipedWeapon weapon, WeaponFunctions input) { if (input == WeaponFunctions.TriggerPulled) { Actor owner = GameResources.ActorManager.GetActorById(weapon.OwnerActorId); WeaponResource wr = owner.GetBehavior<WeaponResource>(); if (wr.Value >= weapon.ResourceCostToUse) { weapon.Fire(); weapon.CurrentState = MachineGunSkill.FiringState; } else { weapon.DryFire(); weapon.CurrentState = MachineGunSkill.DryFireState; } } }
public override void Update(/* inout */ SteeringBlender steering, Actor owner, IAgentStateManager agent) { if (!agent.HasProperty(AgentPropertyName.ActiveOpponent)) { ZombieWaitState zws = new ZombieWaitState(6.0f); agent.CurrentState = zws; return; } Actor opponent = GameResources.ActorManager.GetActorById(agent.GetProperty <int>(AgentPropertyName.ActiveOpponent)); BipedControllerComponent opponentBcc = opponent.GetComponent <BipedControllerComponent>(ActorComponent.ComponentType.Control); steering.Target = BepuConverter.Convert(opponentBcc.Controller.Body.Position); BipedControllerComponent bcc = owner.GetComponent <BipedControllerComponent>(ActorComponent.ComponentType.Control); BepuVec3 toOpponent = opponentBcc.Controller.Body.Position - bcc.Controller.Body.Position; float distance = toOpponent.Length(); ZombieSkillSet zss = owner.GetBehaviorThatImplementsType <ZombieSkillSet>(); BipedWeapon chosenAttack = distance <= zss.MeleeSkill.EffectiveRangeMax ? zss.MeleeSkill : zss.RangedSkill; Matrix attackTransform = Matrix.CreateTranslation(chosenAttack.MuzzleOffset) * Matrix.CreateWorld( BepuConverter.Convert(bcc.Controller.Body.Position), BepuConverter.Convert(bcc.Controller.ViewDirection), Vector3.Up); BepuVec3 bulletPath = opponentBcc.Controller.Body.Position - BepuConverter.Convert(attackTransform.Translation); // If we don't have a shot, we need to specify what kind of movement we need to remedy that. ZombieTacticalMovementState.MovementType movement = ZombieTacticalMovementState.MovementType.None; if (distance < chosenAttack.EffectiveRangeMin) { movement = ZombieTacticalMovementState.MovementType.Retreat; } else if (distance > chosenAttack.EffectiveRangeMax) { movement = ZombieTacticalMovementState.MovementType.Close; } else { BepuRay loeRay = new BepuRay(BepuConverter.Convert(attackTransform.Translation), bulletPath); LOSFilter filter = new LOSFilter(bcc.Controller.Body.CollisionInformation, opponentBcc.Controller.Body.CollisionInformation); RayCastResult loeResult; GameResources.ActorManager.SimSpace.RayCast(loeRay, chosenAttack.EffectiveRangeMax * 1.5f, filter.Test, out loeResult); EntityCollidable otherEntityCollidable = loeResult.HitObject as EntityCollidable; if (otherEntityCollidable != null && otherEntityCollidable.Entity != null && otherEntityCollidable.Entity.Tag != null && (int)(otherEntityCollidable.Entity.Tag) == opponent.Id) { toOpponent.Y = 0.0f; toOpponent.Normalize(); float aimTheta = (float)(Math.Acos(MathHelper.Clamp(BepuVec3.Dot(toOpponent, bcc.Controller.ViewDirection), 0.0f, 1.0f))); const float AIM_CONE_RADIANS = MathHelper.Pi / 12.0f; if (aimTheta <= AIM_CONE_RADIANS) { // TODO: P2: Add some wander to this value: bcc.WorldAim = BepuConverter.Convert(bulletPath); //chosenAttack.CurrentOperation = WeaponFunctions.TriggerPulled; BipedWeapon otherAttack = chosenAttack == zss.MeleeSkill ? zss.RangedSkill : zss.MeleeSkill; otherAttack.UpdateInputState(false, bcc); chosenAttack.UpdateInputState(true, bcc); return; } } else { movement = ZombieTacticalMovementState.MovementType.Lateral; } } if (movement != ZombieTacticalMovementState.MovementType.None) { ZombieTacticalMovementState ztms = new ZombieTacticalMovementState(movement); agent.CurrentState = ztms; } }
public virtual void Update(GameTime gameTime, BipedWeapon weapon, WeaponFunctions input) { }
public ZombieSkillSet(Actor owner) : base(owner) { RangedSkill = null; MeleeSkill = null; }