예제 #1
0
        protected override List <Object> CollectionProvider(AbstractAIComponent context)
        {
            TankAIComponent tankAiComponent = (TankAIComponent)context;

            return(new List <Object>(tankAiComponent.TankEntity.BonusReference.Value
                                     .Select(entity => entity.gameObject)));
        }
예제 #2
0
        protected override int ValueProvider(AbstractAIComponent context)
        {
            TankAIComponent tankAiComponent = (TankAIComponent)context;
            GameObject      target          = GetData <GameObject>();

            return((int)Vector3.Distance(tankAiComponent.gameObject.transform.position, target.transform.position));
        }
예제 #3
0
        protected override int ValueProvider(AbstractAIComponent context)
        {
            TankAIComponent   tankAiComponent     = (TankAIComponent)context;
            List <GameObject> waypointGameObjects = tankAiComponent.TankEntity.SeekWaypointInRadius();
            float             distance            = 0;

            if (DistanceSorter == DistanceSorter.Nearest)
            {
                distance = Mathf.Infinity;
                if (waypointGameObjects.Count == 0)
                {
                    return((int)distance);
                }
                distance = waypointGameObjects
                           .Select(waypoint => Vector3.Distance(waypoint.transform.position, tankAiComponent.transform.position))
                           .Concat(new[] { distance })
                           .Min();
            }
            if (DistanceSorter == DistanceSorter.Farthest)
            {
                distance = Mathf.NegativeInfinity;
                if (waypointGameObjects.Count == 0)
                {
                    return((int)distance);
                }
                distance = waypointGameObjects
                           .Select(waypoint => Vector3.Distance(waypoint.transform.position, tankAiComponent.transform.position))
                           .Concat(new[] { distance })
                           .Max();
            }
            return((int)distance);
        }
예제 #4
0
 public override void Execute(AbstractAIComponent context, AIData aiData)
 {
     foreach (KeyValuePair <string, Object> keyValuePair in aiData)
     {
         context.ClearFromMemory(keyValuePair.Key);
     }
 }
예제 #5
0
        protected override int ValueProvider(AbstractAIComponent context)
        {
            TankAIComponent tankAiComponent = (TankAIComponent)context;
            GameObject      data            = GetData <GameObject>();

            return(tankAiComponent.TankEntity.Aggressors.Contains(data) ? 1 : 0);
        }
예제 #6
0
        protected override int ValueProvider(AbstractAIComponent context)
        {
            TankAIComponent   tankAiComponent = (TankAIComponent)context;
            List <GameObject> bonusEntities   = tankAiComponent.TankEntity.BonusReference.Value;
            float             distance        = 0;

            if (DistanceSorter == DistanceSorter.Nearest)
            {
                distance = Mathf.Infinity;
                if (bonusEntities.Count == 0)
                {
                    return((int)distance);
                }
                distance = bonusEntities
                           .Select(bonusEntity =>
                                   Vector3.Distance(bonusEntity.transform.position, tankAiComponent.transform.position))
                           .Concat(new[] { distance })
                           .Min();
            }
            if (DistanceSorter == DistanceSorter.Farthest)
            {
                distance = Mathf.NegativeInfinity;
                if (bonusEntities.Count == 0)
                {
                    return((int)distance);
                }
                distance = bonusEntities
                           .Select(bonus => Vector3.Distance(bonus.transform.position, tankAiComponent.transform.position))
                           .Concat(new[] { distance })
                           .Max();
            }
            return((int)distance);
        }
예제 #7
0
        protected override List <Object> CollectionProvider(AbstractAIComponent context)
        {
            TankAIComponent tankAiComponent = (TankAIComponent)context;

            return(new List <Object>(tankAiComponent.TankEntity.SeekWaypointInRadius()
                                     .Select(entity => entity.gameObject)));
        }
예제 #8
0
        protected override int ValueProvider(AbstractAIComponent context)
        {
            TankAIComponent tankAiComponent = (TankAIComponent)context;
            GameObject      data            = GetData <GameObject>();

            return(data.transform.InLineOfView(tankAiComponent.transform, tankAiComponent.TankEntity.Aggressors
                                               .Select(go => go.transform).ToList(), tankAiComponent.TankEntity.CoverLayer).Count);
        }
예제 #9
0
        protected override int ValueProvider(AbstractAIComponent context)
        {
            CubeAIComponent cubeAiComponent = (CubeAIComponent)context;

            if (cubeAiComponent.CubeEntity.Target == null)
            {
                return(0);
            }
            return(cubeAiComponent.CubeEntity.Target.GetComponent <CubeEntity>().IsDead ? 0 : 1);
        }
예제 #10
0
        protected override int ValueProvider(AbstractAIComponent context)
        {
            TankAIComponent tankAiComponent = (TankAIComponent)context;

            if (FactionType == FactionType.All)
            {
                return(tankAiComponent.TankEntity.TanksReference.Value.Count);
            }
            return(tankAiComponent.TankEntity.TanksReference.Value
                   .Count(o => o.GetComponent <TankEntity>().GetFaction(tankAiComponent.TankEntity) == FactionType));
        }
예제 #11
0
        protected override int ValueProvider(AbstractAIComponent context)
        {
            TankAIComponent tankAiComponent = (TankAIComponent)context;
            GameObject      data            = GetData <GameObject>();

            return(data.transform.InLineOfView(tankAiComponent.transform,
                                               tankAiComponent.TankEntity.TanksReference.Value
                                               .Select(o => o.GetComponent <TankEntity>())
                                               .Where(entity => entity.gameObject == tankAiComponent.TankEntity.Target)
                                               .Select(entity => entity.transform)
                                               .ToList(), tankAiComponent.TankEntity.CoverLayer).Count == 0 ? 1 : 0);
        }
예제 #12
0
        protected override List <Object> CollectionProvider(AbstractAIComponent context)
        {
            TankAIComponent   tankAiComponent = (TankAIComponent)context;
            List <GameObject> tanks           = tankAiComponent.TankEntity.TanksReference.Value.ToList();

            tanks.Remove(tankAiComponent.gameObject);
            if (Faction != FactionType.All)
            {
                tanks.RemoveAll(o => o.GetComponent <TankEntity>().GetFaction(tankAiComponent.TankEntity) != Faction);
            }
            return(new List <Object>(tanks.Where(go => go != null)
                                     .Select(entity => entity.gameObject)));
        }
예제 #13
0
        protected override int ValueProvider(AbstractAIComponent context)
        {
            TankAIComponent tankAiComponent = (TankAIComponent)context;

            if (FactionType == FactionType.All)
            {
                return(tankAiComponent.TankEntity.TankInRay() ? 1 : 0);
            }
            GameObject tankInRay = tankAiComponent.TankEntity.TankInRay();

            if (tankInRay != null && tankInRay.GetComponent <TankEntity>().GetFaction(tankAiComponent.TankEntity) == FactionType)
            {
                return(1);
            }
            return(0);
        }
예제 #14
0
        protected override int ValueProvider(AbstractAIComponent context)
        {
            TankAIComponent tankAiComponent = (TankAIComponent)context;
            GameObject      data            = GetData <GameObject>();

            if (FactionType == FactionType.All)
            {
                return(data.transform.InLineOfView(tankAiComponent.transform,
                                                   tankAiComponent.TankEntity.TanksReference.Value
                                                   .Select(o => o.GetComponent <TankEntity>())
                                                   .Where(entity => entity != tankAiComponent.TankEntity)
                                                   .Select(entity => entity.transform).ToList(), tankAiComponent.TankEntity.CoverLayer).Count);
            }
            return(data.transform.InLineOfView(tankAiComponent.transform,
                                               tankAiComponent.TankEntity.TanksReference.Value
                                               .Select(o => o.GetComponent <TankEntity>())
                                               .Where(entity => entity != tankAiComponent.TankEntity && tankAiComponent.TankEntity.GetFaction(entity) == FactionType)
                                               .Select(entity => entity.transform).ToList(), tankAiComponent.TankEntity.CoverLayer).Count);
        }
예제 #15
0
        protected override int ValueProvider(AbstractAIComponent context)
        {
            TankAIComponent   tankAiComponent = (TankAIComponent)context;
            List <GameObject> tankEntities    = tankAiComponent.TankEntity.TanksReference.Value.ToList();

            tankEntities.Remove(tankAiComponent.gameObject);
            if (FactionType != FactionType.All)
            {
                tankEntities.RemoveAll(o => o.GetComponent <TankEntity>().GetFaction(tankAiComponent.TankEntity) != FactionType);
            }
            float distance = 0;

            if (DistanceSorter == DistanceSorter.Nearest)
            {
                distance = Mathf.Infinity;
                if (tankEntities.Count == 0)
                {
                    return((int)distance);
                }
                distance = tankEntities
                           .Select(tankEntity => Vector3.Distance(tankEntity.transform.position, tankAiComponent.transform.position))
                           .Concat(new[] { distance })
                           .Min();
            }
            if (DistanceSorter == DistanceSorter.Farthest)
            {
                distance = Mathf.NegativeInfinity;
                if (tankEntities.Count == 0)
                {
                    return((int)distance);
                }
                distance = tankEntities
                           .Where(go => go != tankAiComponent.gameObject)
                           .Select(tankEntity => Vector3.Distance(tankEntity.transform.position, tankAiComponent.transform.position))
                           .Concat(new[] { distance })
                           .Max();
            }
            return((int)distance);
        }
예제 #16
0
        public override void Execute(AbstractAIComponent context, AIData aiData)
        {
            CubeAIComponent cubeAiComponent = (CubeAIComponent)context;

            cubeAiComponent.CubeEntity.Target = aiData.GetData <GameObject>();
        }
예제 #17
0
 protected override int ValueProvider(AbstractAIComponent context)
 {
     return(GetData <GameObject>().GetComponent <CubeEntity>().IsDead ? 0 : 1);
 }
예제 #18
0
 public void ExecuteActions(AbstractAIComponent context)
 {
     AiActions = AiActions.OrderBy(action => action.Order).ToList();
     AiActions.ForEach(action => action.Action.Invoke(context, action.AiData));
 }
예제 #19
0
 public void SetContext(AbstractAIComponent context)
 {
     _context = context;
 }
예제 #20
0
 public abstract void Execute(AbstractAIComponent context, AIData aiData);
예제 #21
0
        protected override int ValueProvider(AbstractAIComponent context)
        {
            TankAIComponent tankAiComponent = (TankAIComponent)context;

            return(tankAiComponent.TankEntity.Aggressors.Count);
        }
예제 #22
0
        protected override int ValueProvider(AbstractAIComponent context)
        {
            TankAIComponent tankAiComponent = (TankAIComponent)context;

            return(tankAiComponent.TankEntity.CurrentHP);
        }
예제 #23
0
 protected abstract int ValueProvider(AbstractAIComponent context);
예제 #24
0
        public override void Execute(AbstractAIComponent context, AIData aiData)
        {
            KeyValuePair <string, Object> firstData = aiData.GetFirstData();

            context.SaveToMemory(firstData.Key, firstData.Value);
        }
예제 #25
0
 protected override int ValueProvider(AbstractAIComponent context)
 {
     return(GetData <Object>() != null ? 1 : 0);
 }
예제 #26
0
        protected override int ValueProvider(AbstractAIComponent context)
        {
            CubeAIComponent cubeAiComponent = (CubeAIComponent)context;

            return(cubeAiComponent.CubeEntity.CurrentHp);
        }
예제 #27
0
        protected override int ValueProvider(AbstractAIComponent context)
        {
            TankAIComponent tankAiComponent = (TankAIComponent)context;

            return(tankAiComponent.TankEntity.BonusReference.Value.Count > 0 ? 1 : 0);
        }
예제 #28
0
        protected override int ValueProvider(AbstractAIComponent context)
        {
            TankAIComponent tankAiComponent = (TankAIComponent)context;

            return(tankAiComponent.TankEntity.TankInRay() == tankAiComponent.TankEntity.Target ? 1 : 0);
        }
예제 #29
0
 protected abstract List <Object> CollectionProvider(AbstractAIComponent context);
예제 #30
0
        public override void Execute(AbstractAIComponent context, AIData aiData)
        {
            TankAIComponent tankAiComponent = (TankAIComponent)context;

            tankAiComponent.TankEntity.Target = aiData.GetData <GameObject>();
        }