Exemple #1
0
        /// <summary>
        /// Reserved for internal use.
        /// </summary>
        protected void SetLocationProperty(Action <LocationTarget> setAction)
        {
            if (Location == null)
            {
                Location = new LocationTarget();
            }

            setAction(Location);
        }
Exemple #2
0
    public override void RightClick(Vector2 position)
    {
        base.RightClick(position);
        if (SelectionManager.Instance.SelectedControlledAgents.Any())
        {
            Vector2i?pos = GetActualPosition(position);

            if (!pos.HasValue)
            {
                // Insantiate bad selection!
                return;
            }

            // Instantiate good selection!
            LocationTarget locationTarget = (LocationTarget)Object.Instantiate(AgentController.Instance.locationTargetPrefab, Vector2.one * -100, Quaternion.identity);
            locationTarget.transform.SetParent(SelectionManager.Instance.targetsParent);
            locationTarget.SetLocations(new[] { pos.Value });
            SelectionManager.Instance.SelectedControlledAgents.ForEach(a => a.Target = locationTarget);
        }
    }
        internal override void ReadRelatedDataFromStream(IBulkStreamReader reader)
        {
            var hasMoreRows = true;

            while (hasMoreRows)
            {
                BulkTargetBid bidRow;

                TIdentifier identifierRow;

                if (reader.TryRead(x => x.Identifier.Equals(_originalIdentifier), out bidRow))
                {
                    _bids.Add(bidRow);
                }
                else if (reader.TryRead(x => x.Equals(_originalIdentifier) && x.IsDeleteRow, out identifierRow))
                {
                    _deleteAllRows.Add(identifierRow);
                }
                else
                {
                    hasMoreRows = false;
                }

                // Delta download sends delete-all rows first, which don't have targetId. Have to look at all rows and set first non-null Id.
                if (Target.Id == null && bidRow != null && bidRow.TargetId != null)
                {
                    Target.Id = bidRow.TargetId;
                }
            }

            Status = _bids.Count > 0 ? V10.Bulk.Entities.Status.Active : V10.Bulk.Entities.Status.Deleted;

            var bidGroups = _bids.GroupBy(r => r.GetType()).ToDictionary(x => x.Key, x => x.ToList());

            var location = new LocationTarget();

            LocationTarget.Location         = location;
            NegativeLocationTarget.Location = location;
            RadiusTarget.Location           = location;

            PopulateChildTargetBids(LocationTarget, bidGroups);
            PopulateChildTargetBids(AgeTarget, bidGroups);
            PopulateChildTargetBids(GenderTarget, bidGroups);
            PopulateChildTargetBids(DayTimeTarget, bidGroups);
            PopulateChildTargetBids(DeviceOsTarget, bidGroups);
            PopulateChildTargetBids(NegativeLocationTarget, bidGroups);
            PopulateChildTargetBids(RadiusTarget, bidGroups);

            var deleteAllGroups = _deleteAllRows.GroupBy(r => r.TargetBidType).ToDictionary(x => x.Key, x => x.ToList());

            PopulateChildTargetIdentities(LocationTarget, deleteAllGroups);
            PopulateChildTargetIdentities(AgeTarget, deleteAllGroups);
            PopulateChildTargetIdentities(GenderTarget, deleteAllGroups);
            PopulateChildTargetIdentities(DayTimeTarget, deleteAllGroups);
            PopulateChildTargetIdentities(DeviceOsTarget, deleteAllGroups);
            PopulateChildTargetIdentities(NegativeLocationTarget, deleteAllGroups);
            PopulateChildTargetIdentities(RadiusTarget, deleteAllGroups);

            if (
                new object[]
            {
                location.CityTarget, location.MetroAreaTarget, location.StateTarget, location.CountryTarget,
                location.PostalCodeTarget, location.RadiusTarget
            }.Any(x => x != null))
            {
                Target.Location = location;
            }

            Target.Age      = AgeTarget.AgeTarget;
            Target.Gender   = GenderTarget.GenderTarget;
            Target.DayTime  = DayTimeTarget.DayTimeTarget;
            Target.DeviceOS = DeviceOsTarget.DeviceOsTarget;
        }
 /// <summary>
 /// Outputs the LocationTarget.
 /// </summary>
 protected void OutputLocationTarget(LocationTarget locationTarget)
 {
     if (locationTarget != null)
     {
         OutputStatusMessage(string.Format("IntentOption: {0}", locationTarget.IntentOption));
         if (locationTarget.CityTarget != null)
         {
             foreach (var bid in locationTarget.CityTarget.Bids)
             {
                 OutputCityTargetBid(bid);
             }
         }
         if (locationTarget.CountryTarget != null)
         {
             foreach (var bid in locationTarget.CountryTarget.Bids)
             {
                 OutputCountryTargetBid(bid);
             }
         }
         if (locationTarget.MetroAreaTarget != null)
         {
             foreach (var bid in locationTarget.MetroAreaTarget.Bids)
             {
                 OutputMetroAreaTargetBid(bid);
             }
         }
         if (locationTarget.PostalCodeTarget != null)
         {
             foreach (var bid in locationTarget.PostalCodeTarget.Bids)
             {
                 OutputPostalCodeTargetBid(bid);
             }
         }
         if (locationTarget.RadiusTarget != null)
         {
             foreach (var bid in locationTarget.RadiusTarget.Bids)
             {
                 OutputRadiusTargetBid(bid);
             }
         }
         if (locationTarget.StateTarget != null)
         {
             foreach (var bid in locationTarget.StateTarget.Bids)
             {
                 OutputStateTargetBid(bid);
             }
         }
     }
 }