public void Should_return_null_if_there_are_no_enemies_in_range() { var bottomLeft = new HexCoords(0, 0); var stats = new StatsComponent(); var team = Guid.NewGuid(); var entity1 = new Entity( new LocationComponent() { StartingCoords = bottomLeft }, new MovementComponent(new PubSub.Hub(), stats), new TeamComponent() { Team = team }, stats ); var list1 = new List <Entity>() { entity1 }; var list2 = new List <Entity>(); var battlefield = new Board(list1, list2); var actual = battlefield.FindEnemyInRange(bottomLeft, 1, team); Assert.AreEqual(null, actual); }
public TeleportAroundTargetLogic(AroundTargetMode info, Character caster, Environment environment, Skill skill) { this.info = info; this.caster = caster; this.environment = environment; this.skill = skill; Entity entity = caster.GameObject().GetComponent <EntityReference>().Entity; movementComponent = entity.GetComponent <MovementComponent>(); StatsComponent statsComponent = entity.GetComponent <StatsComponent>(); invisibleStats = statsComponent.CharacterStats.FindStats(StatsType.Invisible); gameObjectComponent = (GameObjectComponent)entity.GetComponent <EntityGameObjectComponent>(); FrameAndSecondsConverter fasc = FrameAndSecondsConverter._30Fps; delay = fasc.FramesToSeconds(info.delay); prepareDelay = fasc.FramesToSeconds(info.prepareDelay); prepareEndDelay = delay + info.duration - fasc.FramesToSeconds(info.endPreceding); if (delay == 0) { skill.TriggerEventWithId(info.prepareEventId); Perform(); isPrepareEventDispatched = true; prepareDispatchCount++; } if (prepareDelay == 0 && prepareDispatchCount < info.count) { skill.TriggerEventWithId(info.prepareEventId); isPrepareEventDispatched = true; prepareDispatchCount++; } }
public static void CalculateStats(StatsComponent statsComponent) { statsComponent.Range = statsComponent.Dexterity + Helpers.RandomNumbersHelper.ReturnRandomNumber(statsComponent.Dexterity); statsComponent.Damage = (statsComponent.Strength * 2) + Helpers.RandomNumbersHelper.ReturnRandomNumber(statsComponent.Strength); statsComponent.CurrentHP = statsComponent.HP = (statsComponent.Constitution * 3) + Helpers.RandomNumbersHelper.ReturnRandomNumber(statsComponent.Constitution); statsComponent.IntervalModifier = Constants.Stats.INTERVAL_MODIFIER_CONSTANT * statsComponent.Dexterity; }
private static Entity CreateEntity(Guid team, HexCoords coords, int attackPower = 1) { var state = new StateComponent() { CanAct = true }; var stats = new StatsComponent() { Health = 10, AttackRange = 1, AttackSpeed = 100, AttackPower = attackPower, MovementSpeed = 100 }; return(new Entity( new TeamComponent() { Team = team }, new LocationComponent() { StartingCoords = coords }, state, new AttackComponent(new PubSub.Hub(), state, stats), new MovementComponent(new PubSub.Hub(), stats), new SpellComponent(), stats )); }
private StatsComponent stats; //Статы врага void Start() { agent = GetComponent <NavMeshAgent>(); player = Camera.main.GetComponent <CameraAndInventoryBehavior>().player; //Получение данных о игроке, нам понадобится его позиция playerStats = Camera.main.GetComponent <PlayerStats>(); //Получение статов игрока stats = GetComponent <StatsComponent>(); //Получение статов текущего врага }
public void Update(GameTime gameTime) { ComponentManager cm = ComponentManager.GetInstance(); //Update all stats for entities with StatsComponent foreach (var entity in cm.GetComponentsOfType <StatsComponent>()) { StatsComponent stats = (StatsComponent)entity.Value; //See if there is any stats to remove if (stats.RemoveStats > 0) { UpdateEntityStatsFromHistory(entity.Key); } //see if there is any stats to gain if (stats.AddStr > 0) { UpdateEntityStrength(entity.Key); } if (stats.AddAgi > 0) { UpdateEntityAgillity(entity.Key); } if (stats.AddSta > 0) { UpdateEntityStamina(entity.Key); } if (stats.AddInt > 0) { UpdateEntityIntellect(entity.Key); } } }
public void Attack(StatsComponent target) { if (Information.SkillSet != null && Information.SkillSet.SkillTable.Count > 0) { Information.SkillSet.SkillTable["Unique"]?.StartCasting(Stats, target); } }
public static Entity ConstructEntityFromCharacterData(HexCoords position, StarEntity character, Guid playerId, Hub simulationHub) { var state = new StateComponent(); var stats = new StatsComponent() { Health = character.Health, AttackRange = character.AttackRange, Armor = character.Armor, MagicArmor = character.MagicResist, AttackSpeed = character.AttackSpeed, MovementSpeed = character.Movespeed, AttackPower = character.AttackDamage, Name = character.Name, StarLevel = character.StarLevel }; return(new Entity( new LocationComponent() { StartingCoords = position }, new TeamComponent() { Team = playerId }, stats, new SpellComponent(), new MovementComponent(simulationHub, stats), new AttackComponent(simulationHub, state, stats), state )); }
private void OnWallCollision(object sender, WallCollisionEventArgs e) { if (!info.EnableWallHit) { return; } if (state != State.Peaking) { return; } if (!isWallHit) { isWallHit = true; bool found; StatsComponent casterStatsComponent = casterEntity.GetComponent <StatsComponent>(); Stats casterAtkStats = casterStatsComponent.CharacterStats.FindStats(StatsType.RawAtk, out found); DamageFromAttack dfa = new DamageFromAttack( new SourceHistory(Source.FromSkill(info.ShowParentSkill(), skillId)), wallHitConfig.damageScale * damageScale, false, 1, 1, caster.Id, targetCharacter.Position(), targetCharacter.Position(), casterStatsComponent.CharacterStats ); for (int kIndex = 0; kIndex < wallHitConfig.modifiers.Count; kIndex++) { dfa.AddModifierInfo( CastProjectileAction.OnHitPhase.Damaged, ((DefaultSkillCharacter)targetCharacter).CreateModifierInfo( info.ShowParentSkill(), wallHitConfig.modifiers[kIndex] ) ); } targetEntity.GetComponent <HealthComponent>().ReceiveDamage(dfa); } }
public void Should_return_an_enemy_when_there_are_multiple_allies() { var bottomLeft = new HexCoords(0, 0); var bottom = new HexCoords(0, 1); var coordInRange = new HexCoords(1, 0); var team1 = Guid.NewGuid(); var stats = new StatsComponent(); var entity1 = new Entity( new LocationComponent() { StartingCoords = bottomLeft }, new MovementComponent(new PubSub.Hub(), stats), new TeamComponent() { Team = team1 }, stats ); var friendly1 = new Entity( new LocationComponent() { StartingCoords = bottom }, new MovementComponent(new PubSub.Hub(), stats), new TeamComponent() { Team = team1 }, stats ); var entity2 = new Entity( new LocationComponent() { StartingCoords = coordInRange }, new MovementComponent(new PubSub.Hub(), stats), new TeamComponent() { Team = Guid.NewGuid() }, stats ); var list1 = new List <Entity>() { entity1, friendly1, entity2 }; var list2 = new List <Entity>() { }; var battlefield = new Board(list1, list2); var actual = battlefield.FindEnemyInRange(bottomLeft, 1, team1); Assert.AreEqual(entity2, actual); }
public void Should_correctly_populate_the_battlefield() { var bottomLeft = new HexCoords(0, 0); var bottomRight = new HexCoords(7, 0); var topLeft = new HexCoords(-1, 3); var topRight = new HexCoords(6, 3); var stats = new StatsComponent(); var entity1 = new Entity( new LocationComponent() { StartingCoords = bottomLeft }, new MovementComponent(new PubSub.Hub(), stats), new StatsComponent() ); var entity2 = new Entity( new LocationComponent() { StartingCoords = bottomRight }, new MovementComponent(new PubSub.Hub(), stats), new StatsComponent() ); var entity3 = new Entity( new LocationComponent() { StartingCoords = topLeft }, new MovementComponent(new PubSub.Hub(), stats), new StatsComponent() ); var entity4 = new Entity( new LocationComponent() { StartingCoords = topRight }, new MovementComponent(new PubSub.Hub(), stats), new StatsComponent() ); var player = new List <Entity>() { entity1, entity2, entity3, entity4 }; var battlefield = new Board(player, player); Assert.IsTrue(battlefield.Contains(entity1, bottomLeft)); Assert.IsTrue(battlefield.Contains(entity2, bottomRight)); Assert.IsTrue(battlefield.Contains(entity3, topLeft)); Assert.IsTrue(battlefield.Contains(entity4, topRight)); Assert.IsTrue(battlefield.Contains(entity4, new HexCoords(-2, 4))); Assert.IsTrue(battlefield.Contains(entity3, new HexCoords(5, 4))); Assert.IsTrue(battlefield.Contains(entity2, new HexCoords(-3, 7))); Assert.IsTrue(battlefield.Contains(entity1, new HexCoords(4, 7))); }
public ViewManagerTest() { statsComponent = new StatsComponent(new SimpleEventQueue()); tagsComponent = new TagsComponent(); tagger = tagsComponent.Tagger; viewManager = statsComponent.ViewManager; statsRecorder = statsComponent.StatsRecorder; }
public Unit(HealthComponent health, AttackComponent attack, MovementComponent movement, TargetComponent target, AiComponent ai, StatsComponent stats) { this.health = health; this.attack = attack; this.movement = movement; this.target = target; this.ai = ai; this.stats = stats; }
public BleedModifier(ModifierInfo info, Entity casterEntity, Entity targetEntity, Environment environment, CollectionOfInteractions modifierInteractionCollection) : base(info, casterEntity, targetEntity, environment, modifierInteractionCollection) { this.casterEntity = casterEntity; this.info = (BleedInfo)info; this.environment = environment; targetHealthComponent = targetEntity.GetComponent <HealthComponent>(); StatsComponent casterStats = casterEntity.GetComponent <StatsComponent>(); characterStats = casterStats.CharacterStats; }
public override void Execute(Entity entity) { StatsComponent stats = entity.statsComponent; IController controller = entity.controller; float speed = stats.GetTotalStat(StatID.MoveSpeed); Vector2 motion = controller.motion; entity.MoveAndSlide(motion * speed); }
public override void ActivateOnTarget(StatsComponent user, StatsComponent target) { if (target.CompareTag("Enemy")) { user.RecoverHealth(RecoveryPoints); } else { target.RecoverHealth(RecoveryPoints); } }
void Start() { rb = GetComponent <Rigidbody2D>(); animator = GetComponent <Animator>(); playerStats = GetComponent <StatsComponent>(); animatorOverrideController = new AnimatorOverrideController(animator.runtimeAnimatorController); animator.runtimeAnimatorController = animatorOverrideController; rb.freezeRotation = true; }
public static void ApplyBonuses(StatsComponent statsComponent) { statsComponent.Strength += statsComponent.ItemStrength; statsComponent.Dexterity += statsComponent.ItemDexterity; statsComponent.Intelligence += statsComponent.ItemIntelligence; statsComponent.Constitution += statsComponent.ItemConstitution; statsComponent.Spirit += statsComponent.ItemSpirit; statsComponent.Damage += statsComponent.ItemDamage; statsComponent.HP += statsComponent.ItemHp; statsComponent.Range += statsComponent.ItemRange; }
public WeakArmorModifier(ModifierInfo info, Entity casterEntity, Entity targetEntity, Environment environment, CollectionOfInteractions modifierInteractionCollection) : base(info, casterEntity, targetEntity, environment, modifierInteractionCollection) { this.info = (WeakArmorInfo)info; targetStatsComponent = targetEntity.GetComponent <StatsComponent>(); bool found; knockbackWeightStats = targetStatsComponent.CharacterStats.FindStats(StatsType.KnockbackWeight, out found); knockdownWeightStats = targetStatsComponent.CharacterStats.FindStats(StatsType.KnockdownWeight, out found); }
public static void RemoveBonuses(StatsComponent statsComponent) { statsComponent.Strength -= statsComponent.ItemStrength; statsComponent.Dexterity -= statsComponent.ItemDexterity; statsComponent.Intelligence -= statsComponent.ItemIntelligence; statsComponent.Constitution -= statsComponent.ItemConstitution; statsComponent.Spirit -= statsComponent.ItemSpirit; statsComponent.Damage -= statsComponent.ItemDamage; statsComponent.HP -= statsComponent.ItemHp; statsComponent.Range -= statsComponent.ItemRange; }
public ViewManagerTest() { clock = TestClock.Create(); statsComponent = new StatsComponent(new SimpleEventQueue(), clock); tagsComponent = new TagsComponent(); tagger = tagsComponent.Tagger; viewManager = statsComponent.ViewManager; statsRecorder = statsComponent.StatsRecorder; }
public ImmuneModifier(ModifierInfo info, Entity casterEntity, Entity targetEntity, Environment environment, CollectionOfInteractions modifierInteractionCollection) : base(info, casterEntity, targetEntity, environment, modifierInteractionCollection) { this.info = (ImmuneInfo)info; StatsComponent sc = targetEntity.GetComponent <StatsComponent>(); bool found; immuneStats = sc.CharacterStats.FindStats(StatsType.Immune, out found); }
public StaticModifier(ModifierInfo info, Entity casterEntity, Entity targetEntity, Environment environment, CollectionOfInteractions modifierInteractionCollection) : base(info, casterEntity, targetEntity, environment, modifierInteractionCollection) { this.info = (StaticInfo)info; this.environment = environment; caster = casterEntity.GetComponent <SkillComponent>().Character; target = targetEntity.GetComponent <SkillComponent>().Character; targetHealthComponent = targetEntity.GetComponent <HealthComponent>(); casterStatsComponent = casterEntity.GetComponent <StatsComponent>(); targetStatsComponent = targetEntity.GetComponent <StatsComponent>(); duration = this.info.Smc.ShowDurationInSeconds(); }
public StatsModifier(ModifierInfo info, Entity casterEntity, Entity targetEntity, Environment environment, CollectionOfInteractions modifierInteractionCollection, SkillCastingSource src) : base(info, casterEntity, targetEntity, environment, modifierInteractionCollection) { this.src = src; this.info = (StatsInfo)info; targetStatsComponent = targetEntity.GetComponent <StatsComponent>(); targetHealthComponent = targetEntity.GetComponent <HealthComponent>(); statsType = this.info.Smc.ShowStatsType(); targetHero = (DefaultHero)targetEntity.GetComponent <HeroStateMachineComponent>().StateMachineHero; }
public InvisibleModifier(ModifierInfo info, Entity casterEntity, Entity targetEntity, Environment environment, CollectionOfInteractions modifierInteractionCollection) : base(info, casterEntity, targetEntity, environment, modifierInteractionCollection) { this.targetEntity = targetEntity; this.info = (InvisibleInfo)info; StatsComponent targetStatsComponent = targetEntity.GetComponent <StatsComponent>(); bool found; invisibleStats = targetStatsComponent.CharacterStats.FindStats(StatsType.Invisible, out found); gameObjectComponent = (GameObjectComponent)targetEntity.GetComponent <EntityGameObjectComponent>(); }
public IncreaseLyingDuration(UnpredictableDurationLifetime subLifetime, float duration, Entity targetEntity) { this.subLifetime = subLifetime; this.duration = duration; StatsComponent sc = targetEntity.GetComponent <StatsComponent>(); bool found; extraLying = sc.CharacterStats.FindStats(StatsType.ExtraLyingDuration, out found); if (found) { vm = extraLying.AddModifier(StatsModifierOperator.Addition, duration); } }
public GameObject() { PhysicsComponent = new PhysicsComponent(); StatsComponent = new StatsComponent(); SpriteComponent = new SpriteComponent(); SkillSet = new List <ISkill>() { new MeleeSkill(), new RangedSkill() }; Inventory = new List <ItemComponent>() { }; }
private void DealDamageToSelf() { Entity casterEntity = caster.GameObject().GetComponent <EntityReference>().Entity; HealthComponent hc = casterEntity.GetComponent <HealthComponent>(); StatsComponent sc = casterEntity.GetComponent <StatsComponent>(); DamageFromAttack damage = new DamageFromAttack( new SourceHistory(Source.FromSkill(skill, skillId)), config.damageScale, config.isHpPercent, 1, 1, caster.Id(), caster.Position(), caster.Position(), sc.CharacterStats, false, config.ShowDeathBehavior() ); damage.SetTriggerHud(config.hud); hc.ReceiveDamage(damage); }
public override void Process(Entity entity) { if (!ccBreakEventConfig.enable) { return; } StatsComponent statsComponent = entity.GetComponent <StatsComponent>(); if (statsComponent.BasicStatsFromConfig.ShowRole() != EntityRole.Hero) { return; } JustCreatedModifiersComponent justCreatedModifiers = entity.GetComponent <JustCreatedModifiersComponent>(); bool found = false; Modifier triggerModifier = null; foreach (Modifier modifier in justCreatedModifiers.modifiers) { if (!CcBreakByInputModifier.interested.Contains(modifier.Type())) { continue; } triggerModifier = modifier; found = true; break; } if (!found) { return; } EquippedSkillsComponent equippedSkills = entity.GetComponent <EquippedSkillsComponent>(); if (!equippedSkills.EquippedSkills.IsPassiveRecovery2Equipped()) { return; } SkillComponent skillComponent = entity.GetComponent <SkillComponent>(); CcBreakByInputInfo info = new CcBreakByInputInfo(Target.Target, modifierConfig, null); Character character = skillComponent.Character; character.AddModifier(new CcBreakByInputModifier( info, entity, entity, triggerModifier, ccBreakEventConfig, environment, modifierInteractionCollection )); }
// Use this for initialization void Awake() { Movement = GetComponent <MovementComponent>(); Shot = GetComponent <ShotComponent>(); Stats = GetComponent <StatsComponent>(); StatsComponent[] characters = FindObjectsOfType <StatsComponent>(); if (characters[0] != Stats) { OtherStats = characters[0]; } else { OtherStats = characters[1]; } }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { AggregateFactory = new AggregateFactory(this); WeaponFactory = new WeaponFactory(this); DoorFactory = new DoorFactory(this); RoomFactory = new RoomFactory(this); CollectableFactory = new CollectibleFactory(this); WallFactory = new WallFactory(this); EnemyFactory = new EnemyFactory(this); SkillEntityFactory = new SkillEntityFactory(this); NPCFactory = new NPCFactory(this); // Initialize Components PlayerComponent = new PlayerComponent(); LocalComponent = new LocalComponent(); RemoteComponent = new RemoteComponent(); PositionComponent = new PositionComponent(); MovementComponent = new MovementComponent(); MovementSpriteComponent = new MovementSpriteComponent(); SpriteComponent = new SpriteComponent(); DoorComponent = new DoorComponent(); RoomComponent = new RoomComponent(); HUDSpriteComponent = new HUDSpriteComponent(); HUDComponent = new HUDComponent(); InventoryComponent = new InventoryComponent(); InventorySpriteComponent = new InventorySpriteComponent(); ContinueNewGameScreen = new ContinueNewGameScreen(graphics, this); EquipmentComponent = new EquipmentComponent(); WeaponComponent = new WeaponComponent(); BulletComponent = new BulletComponent(); PlayerInfoComponent = new PlayerInfoComponent(); WeaponSpriteComponent = new WeaponSpriteComponent(); StatsComponent = new StatsComponent(); EnemyAIComponent = new EnemyAIComponent(); NpcAIComponent = new NpcAIComponent(); CollectibleComponent = new CollectibleComponent(); CollisionComponent = new CollisionComponent(); TriggerComponent = new TriggerComponent(); EnemyComponent = new EnemyComponent(); NPCComponent = new NPCComponent(); //QuestComponent = new QuestComponent(); LevelManager = new LevelManager(this); SpriteAnimationComponent = new SpriteAnimationComponent(); SkillProjectileComponent = new SkillProjectileComponent(); SkillAoEComponent = new SkillAoEComponent(); SkillDeployableComponent = new SkillDeployableComponent(); SoundComponent = new SoundComponent(); ActorTextComponent = new ActorTextComponent(); TurretComponent = new TurretComponent(); TrapComponent = new TrapComponent(); ExplodingDroidComponent = new ExplodingDroidComponent(); HealingStationComponent = new HealingStationComponent(); PortableShieldComponent = new PortableShieldComponent(); PortableStoreComponent = new PortableStoreComponent(); ActiveSkillComponent = new ActiveSkillComponent(); PlayerSkillInfoComponent = new PlayerSkillInfoComponent(); Quests = new List<Quest>(); #region Initialize Effect Components AgroDropComponent = new AgroDropComponent(); AgroGainComponent = new AgroGainComponent(); BuffComponent = new BuffComponent(); ChanceToSucceedComponent = new ChanceToSucceedComponent(); ChangeVisibilityComponent = new ChangeVisibilityComponent(); CoolDownComponent = new CoolDownComponent(); DamageOverTimeComponent = new DamageOverTimeComponent(); DirectDamageComponent = new DirectDamageComponent(); DirectHealComponent = new DirectHealComponent(); FearComponent = new FearComponent(); HealOverTimeComponent = new HealOverTimeComponent(); InstantEffectComponent = new InstantEffectComponent(); KnockBackComponent = new KnockBackComponent(); TargetedKnockBackComponent = new TargetedKnockBackComponent(); ReduceAgroRangeComponent = new ReduceAgroRangeComponent(); ResurrectComponent = new ResurrectComponent(); StunComponent = new StunComponent(); TimedEffectComponent = new TimedEffectComponent(); EnslaveComponent = new EnslaveComponent(); CloakComponent = new CloakComponent(); #endregion base.Initialize(); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { AggregateFactory = new AggregateFactory(this); WeaponFactory = new WeaponFactory(this); DoorFactory = new DoorFactory(this); RoomFactory = new RoomFactory(this); CollectableFactory = new CollectibleFactory(this); WallFactory = new WallFactory(this); EnemyFactory = new EnemyFactory(this); // Initialize Components PlayerComponent = new PlayerComponent(); LocalComponent = new LocalComponent(); RemoteComponent = new RemoteComponent(); PositionComponent = new PositionComponent(); MovementComponent = new MovementComponent(); MovementSpriteComponent = new MovementSpriteComponent(); SpriteComponent = new SpriteComponent(); DoorComponent = new DoorComponent(); RoomComponent = new RoomComponent(); HUDSpriteComponent = new HUDSpriteComponent(); HUDComponent = new HUDComponent(); InventoryComponent = new InventoryComponent(); InventorySpriteComponent = new InventorySpriteComponent(); ContinueNewGameScreen = new ContinueNewGameScreen(graphics, this); EquipmentComponent = new EquipmentComponent(); WeaponComponent = new WeaponComponent(); BulletComponent = new BulletComponent(); PlayerInfoComponent = new PlayerInfoComponent(); WeaponSpriteComponent = new WeaponSpriteComponent(); StatsComponent = new StatsComponent(); EnemyAIComponent = new EnemyAIComponent(); CollectibleComponent = new CollectibleComponent(); CollisionComponent = new CollisionComponent(); TriggerComponent = new TriggerComponent(); EnemyComponent = new EnemyComponent(); QuestComponent = new QuestComponent(); LevelManager = new LevelManager(this); SpriteAnimationComponent = new SpriteAnimationComponent(); SkillProjectileComponent = new SkillProjectileComponent(); SkillAoEComponent = new SkillAoEComponent(); SkillDeployableComponent = new SkillDeployableComponent(); //TurretComponent = new TurretComponent(); //TrapComponent = new TrapComponent(); //PortableShopComponent = new PortableShopComponent(); //PortableShieldComponent = new PortableShieldComponent(); //MotivateComponent = new MotivateComponent(); //FallbackComponent = new FallbackComponent(); //ChargeComponent = new ChargeComponent(); //HealingStationComponent = new HealingStationComponent(); //ExplodingDroidComponent = new ExplodingDroidComponent(); base.Initialize(); }