/// <summary>
        /// This find out 
        /// </summary>
        /// <param name="order">A subdelegate has taken the order</param>
        /// <returns></returns>
        public bool AskTeam(DelegateOrder order)
        {
            float bid = 0;
            EntityAgent d = null;

            foreach (var e in _subs)
            {
                float tmp = 0;

                if (e.Order != null && e.Order.IsDuplicate(order)) // order exist already
                {
                    return false;
                }

                if (e.TryOrder(order, out tmp))
                {
                    if (d == null || tmp < bid)
                    {
                        d = e;
                        bid = tmp;
                    }
                }
            }

            if (d != null)
            {
                d.SetOrder(order);
                return true;
            }

            return false;
        }
        public override bool TryOrder(DelegateOrder order, out float cost)
        {
            //deny attack orders, as a seeker cannot attack
            if (order.Type == OrderType.Attack
                || !order.IsValid())
            {
                cost = 0;
                return false;
            }

            cost = 0;

            //The cost is: What my opinion is of what it weights, plus how much i like what im doing
            switch (order.Type)
            {
                case OrderType.Move:
                    cost = order.Weight * 1.0f * order.DistanceToTargetSquared(Entity.Position)
                         + CurrentJobCost; //Likes to Trail Targets
                    return true;
                case OrderType.Defend:
                    cost = order.Weight * 1.2f * order.DistanceToTargetSquared(Entity.Position)
                        + CurrentJobCost; //Seekers great at watching stuff
                    return true;
                case OrderType.Follow:
                    cost = order.Weight * 0.8f * order.DistanceToTargetSquared(Entity.Position)
                        + CurrentJobCost; //Seekers arent very good at defending by themselves.  So it will only defend if it's must
                    return true;
            }

            return false;
        }
        public override void SetOrder(DelegateOrder order)
        {
            base.SetOrder(order);

            Path = null;
            _dirty = true;

            CurrentJobCost = float.MaxValue;
        }
        public override bool TryOrder(DelegateOrder order, out float cost)
        {
            //deny attack orders, as a seeker cannot attack
            if (order.Type == OrderType.Attack
                && order.IsValid())
            {
                cost = order.Weight * 1.0f * order.DistanceToTargetSquared(Entity.Position)
                     + CurrentJobCost;
                return Order == null
                    || (order.DistanceToTargetSquared(Entity.Position) < Order.DistanceToTargetSquared(Entity.Position)
                        && TeamDelegate.Report.TimeStamp - TeamDelegate.FactSheet.GetLastSightingTime(Order.TargetAsEntity) > 2);
            }

            cost = 0;
            return false;
        }
 public virtual bool TryOrder(DelegateOrder order, out float cost)
 {
     cost = 0;
     return false;
 }
 public virtual void SetOrder(DelegateOrder order)
 {
     Order = order;
 }
Exemple #7
0
        public bool IsDuplicate(DelegateOrder order)
        {
            if (order.Type == this.Type)
            {
                if (IsTargetEntity && order.IsTargetEntity)
                    return TargetAsEntity.id == order.TargetAsEntity.id;

                if (IsTargetRectange && order.IsTargetRectange)
                    return TargetAsRectangle == order.TargetAsRectangle;

                if (IsTargetVector2 && order.IsTargetVector2)
                    return TargetAsVector2 == order.TargetAsVector2;

            }
            return false;
        }