示例#1
0
        public override void Run(Entity actor)
        {
            Entity entity = actor.Brain.Awareness.FindNearest();

            if (entity != null)
            {
                if (entity.DistanceTo(actor) < 1.5f)
                {
                    Debug.Log(entity.Name + " has been poked by " + actor.Name + " with " + Owner.Name + ".");
                }
                else
                {
                    Debug.Log("Nothing to poke.");
                }
            }
        }
示例#2
0
        public override void Update(float dt)
        {
            base.Update(dt);

            T     += dt * Speed;
            count += (Orbiting.Count - count) * dt * 4;

            if (Entity.DistanceTo(center) > 32f)
            {
                center = Entity.Center;
            }
            else
            {
                center += (Entity.Center - center) * (dt * 8);
            }

            for (var i = Orbiting.Count - 1; i >= 0; i--)
            {
                var e         = Orbiting[i];
                var component = e.GetComponent <OrbitalComponent>();
                var d         = component.Radius * RadiusMultiplier;
                var a         = i / count * Math.PI * 2 - T * 1.5f;

                if (e.Done)
                {
                    RemoveOrbiter(e);
                    continue;
                }

                component.CurrentAngle = (float)a;
                var target = center + new Vector2((float)Math.Cos(a) * d, (float)Math.Sin(a) * d);

                if (component.Lerp)
                {
                    e.Center += (target - e.Center) * (dt * 8);
                }
                else
                {
                    e.Center = target;
                }
            }
        }
示例#3
0
        public override void Run(Entity actor)
        {
            Entity entity = actor.Brain.Awareness.FindNearest();

            if (entity != null)
            {
                if (entity.DistanceTo(actor) < 1.5f)
                {
                    if (entity.Stats != null)
                    {
                        entity.Stats.Health.Modify(-15);

                        if (entity.Brain != null)
                        {
                            entity.Brain.Triggers.Set("Agressor", actor);
                        }
                    }
                }
            }
        }
        public override Command GetCommand()
        {
            var map = Program.Game.Map;

            if (map.FovMap.IsInFov(Entity.X, Entity.Y))
            {
                var player = Program.Game.Player;

                if (Entity.DistanceTo(player) >= 2)
                {
                    map.FovMap.SetCellProperties(Entity.X, Entity.Y, true, true);
                    map.FovMap.SetCellProperties(player.X, player.Y, true, true);

                    var  pathFinder = new PathFinder(map.FovMap);
                    Path path       = null;

                    try
                    {
                        path = pathFinder.ShortestPath(map.FovMap.GetCell(Entity.X, Entity.Y), map.FovMap.GetCell(player.X, player.Y));
                    }
                    catch (PathNotFoundException) { }

                    map.FovMap.SetCellProperties(Entity.X, Entity.Y, true, false);
                    map.FovMap.SetCellProperties(player.X, player.Y, true, false);

                    if (path != null)
                    {
                        var nextPosition = path.CurrentStep;
                        return(new MoveCommand(nextPosition.X - Entity.X, nextPosition.Y - Entity.Y));
                    }
                }
                else if (Entity.HasComponent <FighterComponent>() && player.GetComponent <FighterComponent>()?.Health.Value > 0)
                {
                    return(new AttackCommand(player));
                }
            }

            return(new RestCommand());
        }
示例#5
0
 private Vector2 PositionOf(Entity entity)
 {
     Vector2 position = transform.position;
     return position + entity.DistanceTo(position) * entity.DirectionFrom(position);
 }
示例#6
0
 private static double scoreEating(Entity currentChip, Entity entity, Entity[] myChips)
 {
     var score = Math.Pow(currentChip.Radius + entity.Radius, 2) - Math.Pow(currentChip.Radius, 2);
     if (entity.Player == currentChip.Player)
         score -= Math.Pow(entity.Radius, 2);
     return score / entity.DistanceTo(currentChip);
 }
示例#7
0
 private static Func <int, int, bool> CheckDistance(Entity entity)
 {
     return((x, y) => entity == null || entity.DistanceTo(new Vector2(x * 16, y * 16)) > 32);
 }