protected override int ValueProviderEnemy(EnemyAIComponent context) { Vector2 targetPosition; if (context.EnemyAgent.TargetTransform != null) { targetPosition = context.EnemyAgent.TargetTransform.position; Vector2 position = context.EnemyAgent.transform.position; Vector2 attackingZoneSize = context.EnemyAgent.AttackingZoneSize; if (targetPosition.x < position.x + attackingZoneSize.x && targetPosition.x > position.x - attackingZoneSize.x) { if (targetPosition.y < position.y + attackingZoneSize.y && targetPosition.y > position.y - attackingZoneSize.y) { context.EnemyAgent.UpdateFlip(); return(1); } else { return(0); } } else { return(0); } } else { context.EnemyAgent.Reload(); return(0); } }
// PUBLIC STATIC // PRIVATE // PRIVATE STATIC // PRIVATE COROUTINE // PRIVATE INVOKE //-------------------------------------- // Events //-------------------------------------- /// <summary> /// Raises the trigger enter2 d event. /// </summary> /// <param name="collider2D">Collider2 d.</param> public void OnTriggerEnter2D(Collider2D collider2D) { //NOTE: CURRENTLY ALL WALL TYPES 'KILL' YOU. //TODO: Perhaps make only BOTTOM kill and the rest just do nothing (bounce player via physics if (_boundaryType == BoundaryType.TOP || _boundaryType == BoundaryType.BOTTOM || _boundaryType == BoundaryType.LEFT || _boundaryType == BoundaryType.RIGHT) { // if (collider2D.gameObject.tag == MainConstants.PLAYER_TAG) { if (!_wasTriggered) { _wasTriggered = true; Invoke("doRefreshBoundary", 1f); PlayerInputComponent playerInputComponent = collider2D.gameObject.GetComponent <PlayerInputComponent>(); playerInputComponent.onBoundaryHit(); } } else if (collider2D.gameObject.tag == MainConstants.ENEMY_TAG) { EnemyAIComponent enemyAIComponent = collider2D.gameObject.GetComponent <EnemyAIComponent>(); enemyAIComponent.onBoundaryHit(); } } }
/// <summary> /// Interpret and execute command /// </summary> public string HandleCommand(string input) { JsonEnemyCommandStructure command = JsonConvert.DeserializeObject <JsonEnemyCommandStructure>(input); Enemy enemy = PersonController.instance.GetEnemyById(command.EnemyID); if (enemy == null) { return("Failed: No such enemy"); } EnemyAIComponent aIComponent = enemy.GetComponent <EnemyAIComponent>(); switch (command.Method) { case "GetEnvironmentData": return(aIComponent.GetEnvironmentData()); case "SetDestination": JsonFloatPositionStructure structure = command.Destination; Vector2 destination = new Vector2(structure.x, structure.y); aIComponent.SetDestination(destination, (float)command.Velocity); break; case "SetRotation": aIComponent.SetRotation((float)command.Rotation); break; case "Interact": aIComponent.Interact(command.InteractableID); break; case "FireWeapon": aIComponent.FireWeapon(); break; case "DropWeapon": aIComponent.DropWeapon(); break; case "CloseCombatAttack": aIComponent.CloseCombatAttack(); break; case "StopOverride": aIComponent.StopOverride(); break; default: return("Failed: No such command"); } return(null); }
protected override int ValueProviderEnemy(EnemyAIComponent context) { if (context.EnemyAgent.TargetTransform != null) { Vector2 targetPosition = context.EnemyAgent.TargetTransform.position; Vector2 position = context.EnemyAgent.transform.position; float returnValue = Vector2.Distance(targetPosition, position); returnValue *= 100; return((int)returnValue); } else { return(0); } }
protected override int ValueProviderEnemy(EnemyAIComponent context) { if (context.EnemyAgent.TargetTransform != null) { Vector2 targetPosition = context.EnemyAgent.TargetTransform.position; Vector2 position = context.EnemyAgent.transform.position; Vector2 attackingZoneSize = context.EnemyAgent.AttackingZoneSize; float returnValue; if (targetPosition.x > position.x + attackingZoneSize.x) { returnValue = Vector2.Distance(position + attackingZoneSize, position); } else if (targetPosition.x < position.x - attackingZoneSize.x) { returnValue = Vector2.Distance(position - attackingZoneSize, position); } else if (targetPosition.x < position.x + attackingZoneSize.x && targetPosition.x > position.x) { returnValue = Vector2.Distance(position + attackingZoneSize, position); } else if (targetPosition.x > position.x - attackingZoneSize.x && targetPosition.x < position.x) { returnValue = Vector2.Distance(position + attackingZoneSize, position); } else { returnValue = 0; } returnValue *= 100; return((int)returnValue); } else { return(0); } }
protected override void ExecuteEnemyAction(EnemyAIComponent context, AIData aiData) { context.EnemyAgent.Idle(); }
protected override int ValueProviderEnemy(EnemyAIComponent context) { return(context.EnemyAgent.Energy >= context.EnemyAgent.MaxEnergy ? 1 : 0); }
/// <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(); MatchingPuzzleComponent = new MatchingPuzzleComponent(); pI = new PlayerInfo(); 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(); PsiOrFatigueRegenComponent = new PsiOrFatigueRegenComponent(); 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(); }
protected override void ExecuteEnemyAction(EnemyAIComponent context, AIData aiData) { context.EnemyAgent.AttackSuper(); context.EnemyAgent.IsAction = true; }
protected abstract int ValueProviderEnemy(EnemyAIComponent context);
protected override int ValueProvider(AbstractAIComponent context) { EnemyAIComponent enemyAIComponent = context as EnemyAIComponent; return(ValueProviderEnemy(enemyAIComponent)); }
protected override int ValueProviderEnemy(EnemyAIComponent context) { return(context.EnemyAgent.IsTargetVisible ? 1 : 0); }
/// <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(); }
protected abstract void ExecuteEnemyAction(EnemyAIComponent context, AIData aiData);
public override void Execute(AbstractAIComponent context, AIData aiData) { EnemyAIComponent enemyAIComponent = context as EnemyAIComponent; ExecuteEnemyAction(enemyAIComponent, aiData); }
/// <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(); }
protected override int ValueProviderEnemy(EnemyAIComponent context) { return(context.EnemyAgent.MoveToDirection == Vector2.zero ? 0 : 1); }
protected override int ValueProviderEnemy(EnemyAIComponent context) { return(context.EnemyAgent.IsAction ? 1 : 0); }
protected override int ValueProviderEnemy(EnemyAIComponent context) { return(0); }