//GameObject otherName;
 void Awake()
 {
     cameraScript = GetComponent<ThirdPersonCameraNET>();
     controllerScript = GetComponent<ThirdPersonControllerNET>();
     targetScript = GetComponent<Targeting> ();
     playerScript = GetComponent<myCharacterScript> ();
 }
Exemplo n.º 2
0
    public static Targeting SquashTarget()
    {
        var targeting = new Targeting();
        targeting.TargetGroup = Const.SkillTargetGroup.Opponent;
        targeting.TargetType = Const.SkillTargetType.Unit;
        targeting.TargetSearchRule = Const.TargetSearchRule.SelectedTarget;

        targeting.Pattern = Pattern.WholeGrid();
        return targeting;
    }
Exemplo n.º 3
0
    public static Targeting SingleTarget()
    {
        var targeting = new Targeting();
        targeting.TargetGroup = Const.SkillTargetGroup.All;
        targeting.TargetType = Const.SkillTargetType.Unit;
        targeting.TargetSearchRule = Const.TargetSearchRule.SelectedTarget;

        targeting.Pattern = Pattern.Single();
        return targeting;
    }
Exemplo n.º 4
0
    public static Targeting ChainLightningSecondary()
    {
        var targeting = new Targeting();
        targeting.TargetGroup = Const.SkillTargetGroup.Opponent;
        targeting.TargetType = Const.SkillTargetType.Unit;
        targeting.TargetSearchRule = Const.TargetSearchRule.Nearest;

        targeting.Pattern = Pattern.Single();
        return targeting;
    }
Exemplo n.º 5
0
    void Start () {
        rc = FindObjectOfType<RadarController>();
        sp = FindObjectOfType<ShipPanel>();
        Player = GameObject.FindGameObjectWithTag("Player");
        tc = FindObjectOfType<TestCamera>();
        HUD = FindObjectOfType<playerHUD>();
        tg = FindObjectOfType<Targeting>();
        pm = FindObjectOfType<PhysicsMovement>();
        mycontrol = GetComponent<dfControl>();
        mycontrol.CanFocus = true;
        mainCamera = Camera.main;           
	}
Exemplo n.º 6
0
        public override void OnEnable()
        {
            if (_initialized) return;
            Log.Info("Storing current targeting instance.");
            _previousTargetMethod = Targeting.Instance;
            Log.Info("Creating our targeting instance.");
            _thisTargetMethod = new Target();

            Log.Info("IWantMovement2 Initialized [ {0}]", SvnRevision.Replace("$", ""));
            Log.Info("-- Originally by Millz");
            Log.Info("~ Continued by Lbniese");
            _initialized = true;

            base.OnEnable();
        }
Exemplo n.º 7
0
 new ActionSetPoi(true, ret => new BotPoi(Targeting.Instance.FirstUnit, PoiType.Kill)))),
Exemplo n.º 8
0
 public static CastResultInfo CastBishopGreaterHeal(string target)
 {
     World.Player.PrintMessage("GHeal [Bsp]", Game.Val_Green);
     return(CastBishopGreaterHeal(true, Targeting.GetTarget(target), true));
 }
Exemplo n.º 9
0
    public static Targeting HealTargetArea()
    {
        var targeting = new Targeting();
        targeting.TargetGroup = Const.SkillTargetGroup.All;
        targeting.TargetType = Const.SkillTargetType.Tile;

        targeting.Pattern = Pattern.Cross();
        return targeting;
    }
        /// <summary>
        /// Run the code example.
        /// </summary>
        public void Run(DfpUser user)
        {
            using (LineItemService lineItemService =
                       (LineItemService)user.GetService(DfpService.v201805.LineItemService)) {
                // Set the order that all created line items will belong to and the
                // video ad unit ID to target.
                long   orderId = long.Parse(_T("INSERT_ORDER_ID_HERE"));
                string targetedVideoAdUnitId = _T("INSERT_TARGETED_VIDEO_AD_UNIT_ID_HERE");

                // Set the custom targeting value ID representing the metadata
                // on the content to target. This would typically be from a key representing
                // a "genre" and a value representing something like "comedy". The value must
                // be from a key in a content metadata key hierarchy.
                long contentCustomTargetingValueId =
                    long.Parse(_T("INSERT_CONTENT_CUSTOM_TARGETING_VALUE_ID_HERE"));

                // Create content targeting.
                ContentMetadataKeyHierarchyTargeting contentMetadataTargeting =
                    new ContentMetadataKeyHierarchyTargeting();
                contentMetadataTargeting.customTargetingValueIds =
                    new long[] { contentCustomTargetingValueId };

                ContentTargeting contentTargeting = new ContentTargeting();
                contentTargeting.targetedContentMetadata =
                    new ContentMetadataKeyHierarchyTargeting[] { contentMetadataTargeting };

                // Create inventory targeting.
                InventoryTargeting inventoryTargeting = new InventoryTargeting();
                AdUnitTargeting    adUnitTargeting    = new AdUnitTargeting();
                adUnitTargeting.adUnitId           = targetedVideoAdUnitId;
                adUnitTargeting.includeDescendants = true;
                inventoryTargeting.targetedAdUnits = new AdUnitTargeting[] { adUnitTargeting };

                // Create video position targeting.
                VideoPosition videoPosition = new VideoPosition();
                videoPosition.positionType = VideoPositionType.PREROLL;
                VideoPositionTarget videoPositionTarget = new VideoPositionTarget();
                videoPositionTarget.videoPosition = videoPosition;
                VideoPositionTargeting videoPositionTargeting = new VideoPositionTargeting();
                videoPositionTargeting.targetedPositions =
                    new VideoPositionTarget[] { videoPositionTarget };

                // Create targeting.
                Targeting targeting = new Targeting();
                targeting.contentTargeting       = contentTargeting;
                targeting.inventoryTargeting     = inventoryTargeting;
                targeting.videoPositionTargeting = videoPositionTargeting;

                // Create local line item object.
                LineItem lineItem = new LineItem();
                lineItem.name          = "Video line item - " + this.GetTimeStamp();
                lineItem.orderId       = orderId;
                lineItem.targeting     = targeting;
                lineItem.lineItemType  = LineItemType.SPONSORSHIP;
                lineItem.allowOverbook = true;

                // Set the environment type to video.
                lineItem.environmentType = EnvironmentType.VIDEO_PLAYER;

                // Set the creative rotation type to optimized.
                lineItem.creativeRotationType = CreativeRotationType.OPTIMIZED;

                // Create the master creative placeholder.
                CreativePlaceholder creativeMasterPlaceholder = new CreativePlaceholder();
                Size size1 = new Size();
                size1.width                    = 400;
                size1.height                   = 300;
                size1.isAspectRatio            = false;
                creativeMasterPlaceholder.size = size1;

                // Create companion creative placeholders.
                CreativePlaceholder companionCreativePlaceholder1 = new CreativePlaceholder();
                Size size2 = new Size();
                size2.width         = 300;
                size2.height        = 250;
                size2.isAspectRatio = false;
                companionCreativePlaceholder1.size = size2;

                CreativePlaceholder companionCreativePlaceholder2 = new CreativePlaceholder();
                Size size3 = new Size();
                size3.width         = 728;
                size3.height        = 90;
                size3.isAspectRatio = false;
                companionCreativePlaceholder2.size = size3;

                // Set companion creative placeholders.
                creativeMasterPlaceholder.companions = new CreativePlaceholder[] {
                    companionCreativePlaceholder1, companionCreativePlaceholder2
                };

                // Set the size of creatives that can be associated with this line item.
                lineItem.creativePlaceholders = new CreativePlaceholder[] { creativeMasterPlaceholder };

                // Set delivery of video companions to optional.
                lineItem.companionDeliveryOption = CompanionDeliveryOption.OPTIONAL;

                // Set the line item to run for one month.
                lineItem.startDateTimeType = StartDateTimeType.IMMEDIATELY;
                lineItem.endDateTime       =
                    DateTimeUtilities.FromDateTime(System.DateTime.Now.AddMonths(1), "America/New_York");

                // Set the cost per day to $1.
                lineItem.costType = CostType.CPD;
                Money money = new Money();
                money.currencyCode   = "USD";
                money.microAmount    = 1000000L;
                lineItem.costPerUnit = money;

                // Set the percentage to be 100%.
                Goal goal = new Goal();
                goal.goalType        = GoalType.DAILY;
                goal.unitType        = UnitType.IMPRESSIONS;
                goal.units           = 100;
                lineItem.primaryGoal = goal;

                try {
                    // Create the line item on the server.
                    LineItem[] createdLineItems = lineItemService.createLineItems(
                        new LineItem[] { lineItem });

                    foreach (LineItem createdLineItem in createdLineItems)
                    {
                        Console.WriteLine("A line item with ID \"{0}\", belonging to order ID \"{1}\", and " +
                                          "named \"{2}\" was created.", createdLineItem.id, createdLineItem.orderId,
                                          createdLineItem.name);
                    }
                } catch (Exception e) {
                    Console.WriteLine("Failed to create line items. Exception says \"{0}\"",
                                      e.Message);
                }
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Run the code examples.
        /// </summary>
        public void Run(DfpUser user)
        {
            using (ProductTemplateService productTemplateService =
                       (ProductTemplateService)user.GetService(DfpService.v201802
                                                               .ProductTemplateService))

                using (NetworkService networkService =
                           (NetworkService)user.GetService(DfpService.v201802.NetworkService))
                {
                    // Create a product template.
                    ProductTemplate productTemplate = new ProductTemplate();
                    productTemplate.name        = "Product template #" + new Random().Next(int.MaxValue);
                    productTemplate.description = "This product template creates standard " +
                                                  "proposal line items targeting Chrome browsers with product segmentation " +
                                                  "on ad units and geo targeting.";

                    // Set the name macro which will be used to generate the names of the products.
                    // This will create a segmentation based on the line item type, ad unit, and
                    // location.
                    productTemplate.nameMacro =
                        "<line-item-type> - <ad-unit> - <template-name> - <location>";

                    // Set the product type so the created proposal line items will be trafficked
                    // in DFP.
                    productTemplate.productType = ProductType.DFP;

                    // Set rate type to create CPM priced proposal line items.
                    productTemplate.rateType = RateType.CPM;

                    // Optionally set the creative rotation of the product to serve one or more
                    // creatives.
                    productTemplate.roadblockingType = RoadblockingType.ONE_OR_MORE;
                    productTemplate.deliveryRateType = DeliveryRateType.AS_FAST_AS_POSSIBLE;

                    // Create the master creative placeholder.
                    CreativePlaceholder creativeMasterPlaceholder = new CreativePlaceholder();
                    creativeMasterPlaceholder.size = new Size()
                    {
                        width         = 728,
                        height        = 90,
                        isAspectRatio = false
                    };

                    // Create companion creative placeholders.
                    CreativePlaceholder companionCreativePlaceholder = new CreativePlaceholder();
                    companionCreativePlaceholder.size = new Size()
                    {
                        width         = 300,
                        height        = 250,
                        isAspectRatio = false
                    };

                    // Set the size of creatives that can be associated with the product template.
                    productTemplate.creativePlaceholders = new CreativePlaceholder[]
                    {
                        creativeMasterPlaceholder,
                        companionCreativePlaceholder
                    };

                    // Set the type of proposal line item to be created from the product template.
                    productTemplate.lineItemType = LineItemType.STANDARD;

                    // Get the root ad unit ID used to target the whole site.
                    String rootAdUnitId = networkService.getCurrentNetwork().effectiveRootAdUnitId;

                    // Create ad unit targeting for the root ad unit (i.e. the whole network).
                    AdUnitTargeting adUnitTargeting = new AdUnitTargeting();
                    adUnitTargeting.adUnitId           = rootAdUnitId;
                    adUnitTargeting.includeDescendants = true;

                    // Create geo targeting for the US.
                    Location countryLocation = new Location();
                    countryLocation.id = 2840L;

                    // Create geo targeting for Hong Kong.
                    Location regionLocation = new Location();
                    regionLocation.id = 2344L;

                    GeoTargeting geoTargeting = new GeoTargeting();
                    geoTargeting.targetedLocations = new Location[]
                    {
                        countryLocation,
                        regionLocation
                    };

                    // Add browser targeting to Chrome on the product template distinct from product
                    // segmentation.
                    Browser chromeBrowser = new Browser();
                    chromeBrowser.id = 500072L;

                    BrowserTargeting browserTargeting = new BrowserTargeting();
                    browserTargeting.browsers = new Browser[]
                    {
                        chromeBrowser
                    };

                    TechnologyTargeting technologyTargeting = new TechnologyTargeting();
                    technologyTargeting.browserTargeting = browserTargeting;

                    Targeting productTemplateTargeting = new Targeting();
                    productTemplateTargeting.technologyTargeting = technologyTargeting;

                    productTemplate.builtInTargeting = productTemplateTargeting;

                    productTemplate.customizableAttributes = new CustomizableAttributes()
                    {
                        allowPlacementTargetingCustomization = true
                    };

                    // Add inventory and geo targeting as product segmentation.
                    ProductSegmentation productSegmentation = new ProductSegmentation();
                    productSegmentation.adUnitSegments = new AdUnitTargeting[]
                    {
                        adUnitTargeting
                    };
                    productSegmentation.geoSegment = geoTargeting;

                    productTemplate.productSegmentation = productSegmentation;

                    try
                    {
                        // Create the product template on the server.
                        ProductTemplate[] productTemplates =
                            productTemplateService.createProductTemplates(new ProductTemplate[]
                        {
                            productTemplate
                        });

                        foreach (ProductTemplate createdProductTemplate in productTemplates)
                        {
                            Console.WriteLine(
                                "A product template with ID \"{0}\" and name \"{1}\" was created.",
                                createdProductTemplate.id, createdProductTemplate.name);
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(
                            "Failed to create product templates. Exception says \"{0}\"",
                            e.Message);
                    }
                }
        }
Exemplo n.º 12
0
        public override void OnButtonPress(int num)
        {
            ConfigItem item = listBox.SelectedItem as ConfigItem;

            if (item == null)
            {
                return;
            }
            if (item.Value is string)
            {
                if (InputBox.Show("Input string") && !string.IsNullOrEmpty(InputBox.GetString()))
                {
                    item.Value = InputBox.GetString();
                }
            }
            else if (item.Value is bool)
            {
                item.Value = !(bool)item.Value;
            }
            else if (item.Value is uint)
            {
                Targeting.OneTimeTarget((l, s, p, g) =>
                {
                    item.Value = s == World.Player.Serial ? 0 : s.Value;
                    listBox.Items[listBox.SelectedIndex] = item;
                });
            }
            else if (item.Value is byte)
            {
                if (InputBox.Show("Input value") && (InputBox.GetInt(-1) >= 0 || InputBox.GetInt(-1) <= 100))
                {
                    item.Value = (byte)InputBox.GetInt(-1);
                }
            }
            else if (item.Value is ushort)
            {
                HueEntry hueEntry = new HueEntry((ushort)item.Value);
                if (hueEntry.ShowDialog(Engine.MainWindow) == DialogResult.OK)
                {
                    item.Value = (ushort)hueEntry.Hue;
                }
            }
            else if (item.Value.GetType().IsEnum)
            {
                Type type  = item.Value.GetType();
                int  value = (int)item.Value;
                while (!Enum.IsDefined(type, ++value))
                {
                    if (value >= Enum.GetValues(type).Length)
                    {
                        value = -1;
                    }
                }
                item.Value = Enum.ToObject(type, value);
            }
            else
            {
                throw new NotImplementedException();
            }
            listBox.Items[listBox.SelectedIndex] = item;
        }
Exemplo n.º 13
0
        private void Run()
        {
            #region local variables
            Walker walker = new Walker(this);
            Targeting targeting = new Targeting(this);
            Looter looter = new Looter(this);
            List<Objects.Location> corpseLocations = new List<Objects.Location>();
            Objects.Location currentCorpseLocation = Objects.Location.Invalid;
            Waypoint currentWaypoint = null;
            bool cleanupCalled = false;
            Map.TileCollection tileCollection = null;

            #region events
            // create anonymous methods and reference them
            // because we want to unsub them later
            TargetHandler anonTargetKilled = delegate(Target t)
            {
                if (t == null || t.Creature == null) return;
                if (!t.DoLoot) return;
                if (!this.Client.Player.Location.IsOnScreen(t.Creature.Location)) return;
                if (!corpseLocations.Contains(t.Creature.Location)) corpseLocations.Add(t.Creature.Location);
            };
            Targeting.CreatureDiedHandler anonCreatureDied = delegate(Objects.Creature c)
            {
                string name = c.Name.ToLower();
                foreach (Target t in this.GetTargets())
                {
                    if (t.Name.ToLower() == name)
                    {
                        if (!t.DoLoot) break;
                        if (!corpseLocations.Contains(c.Location)) corpseLocations.Add(c.Location);
                        break;
                    }
                }
            };
            Walker.WaypointHandler anonWaypointExecutedEnd = delegate(Waypoint waypoint, bool success)
            {
                if (this.Waypoints.Count == 0) return;
                this.CurrentWaypointIndex++;
            };
            Looter.CorpseOpenedHandler anonCorpseOpened = delegate(Objects.Container container)
            {
                looter.LootItems(container, this.GetLoot(), true);
            };
            Looter.LootingFinishedHandler anonLootingFinished = delegate(Objects.Container container)
            {
                if (this.Waypoints.Count == 0) return;

                if (container.IsOpen) container.Close();
                corpseLocations.Remove(currentCorpseLocation);
                currentCorpseLocation = Objects.Location.Invalid;
            };
            Targeting.ErrorHandler anonTargetingError = delegate(Exception ex)
            {
                DateTime dt = DateTime.Now;
                string dtString = dt.Year + "-" + dt.Month + "-" + dt.Day + " " + dt.Hour + ":" + dt.Minute + ":" + dt.Second;
                File.AppendAllText("cavebot-debug.txt", "[" + dtString + "] Targeting:\n" + ex.Message + "\n" + ex.StackTrace + "\n");
            };
            Walker.ErrorHandler anonWalkerError = delegate(Exception ex)
            {
                DateTime dt = DateTime.Now;
                string dtString = dt.Year + "-" + dt.Month + "-" + dt.Day + " " + dt.Hour + ":" + dt.Minute + ":" + dt.Second;
                File.AppendAllText("cavebot-debug.txt", "[" + dtString + "] Waypoints:\n" + ex.Message + "\n" + ex.StackTrace + "\n");
            };
            Looter.ErrorOccurredHandler anonLooterError = delegate(Exception ex)
            {
                DateTime dt = DateTime.Now;
                string dtString = dt.Year + "-" + dt.Month + "-" + dt.Day + " " + dt.Hour + ":" + dt.Minute + ":" + dt.Second;
                File.AppendAllText("cavebot-debug.txt", "[" + dtString + "] Looter:\n" + ex.Message + "\n" + ex.StackTrace + "\n");
            };
            CleanupHandler anonCleanup = delegate()
            {
                this.TargetKilled -= anonTargetKilled;
                walker.WaypointExecutedEnd -= anonWaypointExecutedEnd;
                looter.CorpseOpened -= anonCorpseOpened;
                looter.LootingFinished -= anonLootingFinished;
                targeting.CreatureDied -= anonCreatureDied;
                targeting.ErrorOccurred -= anonTargetingError;
                walker.ErrorOccurred -= anonWalkerError;
                looter.ErrorOccurred -= anonLooterError;
                cleanupCalled = true;
            };
            // subscribe to events
            this.TargetKilled += anonTargetKilled;
            walker.WaypointExecutedEnd += anonWaypointExecutedEnd;
            looter.CorpseOpened += anonCorpseOpened;
            looter.LootingFinished += anonLootingFinished;
            targeting.CreatureDied += anonCreatureDied;
            targeting.ErrorOccurred += anonTargetingError;
            walker.ErrorOccurred += anonWalkerError;
            looter.ErrorOccurred += anonLooterError;
            // subscribe to cleanup, as we need to unsub before exiting
            this.CleanupCalled += anonCleanup;
            #endregion
            #endregion

            while (this.IsRunning)
            {
                try
                {
                    Thread.Sleep(500);

                    // check if IsRunning changed or cleanup called while thread was sleeping
                    if (!this.IsRunning || cleanupCalled) break;

                    if (!this.Client.Player.Connected) continue;

                    // check if a script waypoint is currently running
                    if (walker.IsRunning &&
                        currentWaypoint != null &&
                        currentWaypoint.Type == Waypoint.Types.Script)
                    {
                        continue;
                    }

                    Objects.Location playerLoc = this.Client.Player.Location;
                    IEnumerable<Objects.Creature> creatures = this.Client.BattleList.GetCreatures(false, true),
                        visiblePlayers = this.Client.BattleList.GetPlayers(true, true);
                    List<Objects.Creature> visibleCreatures = new List<Objects.Creature>();
                    foreach (Objects.Creature c in creatures)
                    {
                        if (c.IsVisible) visibleCreatures.Add(c);
                    }

                    foreach (Objects.Creature c in targeting.GetKilledCreatures(creatures))
                    {
                        string name = c.Name.ToLower();
                        foreach (Target t in this.GetTargets())
                        {
                            if (t.Name.ToLower() != name) continue;
                            if (!corpseLocations.Contains(c.Location)) corpseLocations.Add(c.Location);
                            break;
                        }
                    }

                    #region targeting
                    if (targeting.IsRunning)
                    {
                        targeting.UpdateCache(tileCollection, visibleCreatures, visiblePlayers);
                        continue;
                    }
                    else if (this.CurrentSettings.KillBeforeLooting || corpseLocations.Count == 0)
                    {
                        Target t = this.GetBestTarget(tileCollection, creatures, this.Client.BattleList.GetPlayers(true, true), true);
                        if (t != null)
                        {
                            if (this.CurrentSettings.KillBeforeLooting && looter.IsRunning) looter.CancelExecution();
                            if (this.Client.TibiaVersion < 810) this.StopwatchExhaust.Restart(); // restart to avoid instant attack->spell/rune
                            targeting.ExecuteTarget(t, tileCollection, visibleCreatures, visiblePlayers);
                            continue;
                        }
                    }
                    #endregion

                    #region looting
                    if (looter.IsRunning)
                    {
                        looter.UpdateCache(tileCollection);
                        continue;
                    }
                    // loot always if there are no waypoints
                    if (this.Waypoints.Count == 0)
                    {
                        List<ushort> ids = new List<ushort>();
                        foreach (Loot loot in this.GetLoot())
                        {
                            ids.Add(loot.ID);
                        }
                        foreach (Objects.Container c in this.Client.Inventory.GetContainers(1))
                        {
                            if (c.Name.Contains("Backpack")) continue;
                            if (c.GetItems(ids).ToArray().Length == 0) continue;

                            looter.LootItems(c, this.GetLoot(), false);
                        }
                    }
                    // check loot locations
                    else if (corpseLocations.Count > 0)
                    {
                        if (this.Client.Player.IsWalking) continue;

                        // find new corpse location
                        if (!currentCorpseLocation.IsValid() || !playerLoc.IsInRange(currentCorpseLocation))
                        {
                            int distance = int.MaxValue;
                            Objects.Location bestLoc = Objects.Location.Invalid;
                            foreach (Objects.Location loc in corpseLocations)
                            {
                                if (!playerLoc.IsInRange(loc)) continue;

                                int corpseDistance = 0;
                                if (playerLoc.IsOnScreen(loc))
                                {
                                    Map.Tile tile = tileCollection.GetTile(loc);
                                    if (tile == null) continue;
                                    Map.TileObject topItem = tile.GetTopUseItem(false);
                                    if (!topItem.HasFlag(Enums.ObjectPropertiesFlags.IsContainer)) continue;

                                    var tilesToLoc = playerLoc.GetTilesToLocation(this.Client, loc,
                                        tileCollection, this.PathFinder, true, true).ToArray();
                                    if (tilesToLoc.Length == 0) continue;

                                    corpseDistance = tilesToLoc.Length - 1;
                                }
                                else corpseDistance = (int)playerLoc.DistanceTo(loc) + 20;

                                if (corpseDistance < distance)
                                {
                                    distance = corpseDistance;
                                    bestLoc = loc;
                                }
                            }
                            if (bestLoc.IsValid()) currentCorpseLocation = bestLoc;
                        }

                        // move to loot location
                        if (currentCorpseLocation.IsValid() && playerLoc.IsInRange(currentCorpseLocation))
                        {
                            if (this.Client.Window.StatusBar.GetText() == Enums.StatusBar.ThereIsNoWay)
                            {
                                corpseLocations.Remove(currentCorpseLocation);
                                currentCorpseLocation = Objects.Location.Invalid;
                                this.Client.Window.StatusBar.SetText(string.Empty);
                                continue;
                            }

                            if (playerLoc.IsOnScreen(currentCorpseLocation))
                            {
                                Map.Tile tile = tileCollection.GetTile(currentCorpseLocation);
                                if (tile == null)
                                {
                                    corpseLocations.Remove(currentCorpseLocation);
                                    currentCorpseLocation = Objects.Location.Invalid;
                                    continue;
                                }
                                Map.TileObject topItem = tile.GetTopUseItem(false);
                                if (!topItem.HasFlag(Enums.ObjectPropertiesFlags.IsContainer))
                                {
                                    corpseLocations.Remove(currentCorpseLocation);
                                    currentCorpseLocation = Objects.Location.Invalid;
                                    continue;
                                }

                                if (playerLoc.DistanceTo(currentCorpseLocation) >= 2)
                                {
                                    Map.TileCollection adjTiles = tileCollection.GetAdjacentTileCollection(tile);
                                    int adjDistance = playerLoc.GetTilesToLocation(this.Client,
                                        tile.WorldLocation, tileCollection, this.PathFinder, true).ToArray().Length;
                                    Objects.Location adjLoc = Objects.Location.Invalid;
                                    foreach (Map.Tile adjTile in adjTiles.GetTiles())
                                    {
                                        if (!adjTile.IsWalkable()) continue;

                                        var tilesToCorpse = playerLoc.GetTilesToLocation(this.Client,
                                            adjTile.WorldLocation, tileCollection, this.PathFinder, true).ToArray();
                                        if (tilesToCorpse.Length == 0) continue;

                                        int dist = tilesToCorpse.Length - 1;
                                        if (dist < adjDistance)
                                        {
                                            adjDistance = dist;
                                            adjLoc = adjTile.WorldLocation;
                                        }
                                    }

                                    if (adjLoc.IsValid())
                                    {
                                        this.Client.Player.GoTo = adjLoc;
                                        continue;
                                    }

                                    corpseLocations.Remove(currentCorpseLocation);
                                    currentCorpseLocation = Objects.Location.Invalid;
                                    continue;
                                }

                                // we're in range to open the corpse, so let's open it
                                looter.OpenCorpse(tileCollection, tile);
                                continue;
                            }
                            else
                            {
                                this.Client.Player.GoTo = currentCorpseLocation;
                                continue;
                            }
                        }
                        else currentCorpseLocation = Objects.Location.Invalid;
                    }
                    #endregion

                    #region waypoints
                    if (walker.IsRunning)
                    {
                        walker.UpdateCache(tileCollection);
                        continue;
                    }
                    else if (this.Waypoints.Count > 0)
                    {
                        // check if this is the first time we're running the walker
                        // and if waypoint index wasn't set by user
                        // if so, find the closest waypoint
                        if (currentWaypoint == null && this.CurrentWaypointIndex == 0)
                        {
                            int distance = 200;
                            Waypoint closestWaypoint = null;
                            foreach (Waypoint wp in this.GetWaypoints())
                            {
                                if (!playerLoc.IsInRange(wp.Location)) continue;
                                int wpDist = (int)playerLoc.DistanceTo(wp.Location);
                                if (distance > wpDist)
                                {
                                    distance = wpDist;
                                    closestWaypoint = wp;
                                }
                            }
                            if (closestWaypoint == null) continue;
                            currentWaypoint = closestWaypoint;
                        }
                        else currentWaypoint = this.Waypoints[this.CurrentWaypointIndex];

                        walker.ExecuteWaypoint(currentWaypoint, tileCollection);
                    }
                    #endregion
                }
                catch (Exception ex)
                {

                }
            }

            this.CleanupCalled -= anonCleanup;
        }
Exemplo n.º 14
0
        //=====================================================================
        // HandleInput
        //
        // Called by Update. Checks for input events and operates the Builder
        // accordingly
        //=====================================================================
        private void HandleInput()
        {
            if (this.handleInputFrame == Time.frameCount)
            {
                return;
            }
            this.handleInputFrame = Time.frameCount;
            if (Builder.isPlacing || !AvatarInputHandler.main.IsEnabled())
            {
                return;
            }
            Targeting.AddToIgnoreList(Player.main.gameObject);
            GameObject gameObject;
            float      num;

            // Range increased to 40 to give the seamoth more room
            Targeting.GetTarget(hitRange, out gameObject, out num, null);
            if (gameObject == null)
            {
                return;
            }
            // Bring up the construct menu on alt tool use
            //      (because the seamoth has lights bound to right hand)
            if (GameInput.GetButtonDown(GameInput.Button.AltTool))
            {
                uGUI_BuilderMenu.Show();
                return;
            }
            bool          constructHeld   = GameInput.GetButtonHeld(GameInput.Button.LeftHand);
            bool          deconstructDown = GameInput.GetButtonDown(GameInput.Button.Deconstruct);
            bool          deconstructHeld = GameInput.GetButtonHeld(GameInput.Button.Deconstruct);
            Constructable constructable   = gameObject.GetComponentInParent <Constructable>();

            if (constructable != null && num > constructable.placeMaxDistance)
            {
                constructable = null;
            }
            if (constructable != null)
            {
                this.OnHover(constructable);
                string text;
                if (constructHeld)
                {
                    this.Construct(constructable, true);
                }
                else if (constructable.DeconstructionAllowed(out text))
                {
                    if (deconstructHeld)
                    {
                        if (constructable.constructed)
                        {
                            constructable.SetState(false, false);
                        }
                        else
                        {
                            this.Construct(constructable, false);
                        }
                    }
                }
                else if (deconstructDown && !string.IsNullOrEmpty(text))
                {
                    ErrorMessage.AddMessage(text);
                }
            }
            else
            {
                BaseDeconstructable baseDeconstructable = gameObject.GetComponentInParent <BaseDeconstructable>();
                if (baseDeconstructable == null)
                {
                    BaseExplicitFace componentInParent = gameObject.GetComponentInParent <BaseExplicitFace>();
                    if (componentInParent != null)
                    {
                        baseDeconstructable = componentInParent.parent;
                    }
                }
                if (baseDeconstructable != null)
                {
                    string text;
                    if (baseDeconstructable.DeconstructionAllowed(out text))
                    {
                        this.OnHover(baseDeconstructable);
                        if (deconstructDown)
                        {
                            baseDeconstructable.Deconstruct();
                        }
                    }
                    else if (deconstructDown && !string.IsNullOrEmpty(text))
                    {
                        ErrorMessage.AddMessage(text);
                    }
                }
            }
        }
Exemplo n.º 15
0
 public static void OnTargetAddFriend(FriendGroup group)
 {
     World.Player.SendMessage(MsgLevel.Friend, LocString.TargFriendAdd);
     Targeting.OneTimeTarget(group.OnAddFriendTarget);
 }
        /// <summary>
        /// Run the code example.
        /// </summary>
        public void Run(AdManagerUser user)
        {
            using (ProductTemplateService productTemplateService =
                       user.GetService <ProductTemplateService>())
            {
                // Set the ID of the product template.
                long productTemplateId = long.Parse(_T("INSERT_PRODUCT_TEMPLATE_ID_HERE"));

                // Create a statement to get the product template.
                StatementBuilder statementBuilder = new StatementBuilder()
                                                    .Where("id = :id")
                                                    .OrderBy("id ASC")
                                                    .Limit(1)
                                                    .AddValue("id", productTemplateId);

                try
                {
                    // Get product templates by statement.
                    ProductTemplatePage page =
                        productTemplateService.getProductTemplatesByStatement(
                            statementBuilder.ToStatement());

                    ProductTemplate productTemplate = page.results[0];

                    // Add geo targeting for Canada to the product template.
                    Location countryLocation = new Location();
                    countryLocation.id = 2124L;

                    Targeting    productTemplateTargeting = productTemplate.builtInTargeting;
                    GeoTargeting geoTargeting             = productTemplateTargeting.geoTargeting;

                    List <Location> existingTargetedLocations = new List <Location>();

                    if (geoTargeting == null)
                    {
                        geoTargeting = new GeoTargeting();
                    }
                    else if (geoTargeting.targetedLocations != null)
                    {
                        existingTargetedLocations =
                            new List <Location>(geoTargeting.targetedLocations);
                    }

                    existingTargetedLocations.Add(countryLocation);

                    Location[] newTargetedLocations = new Location[existingTargetedLocations.Count];
                    existingTargetedLocations.CopyTo(newTargetedLocations);
                    geoTargeting.targetedLocations = newTargetedLocations;

                    productTemplateTargeting.geoTargeting = geoTargeting;
                    productTemplate.builtInTargeting      = productTemplateTargeting;

                    // Update the product template on the server.
                    ProductTemplate[] productTemplates =
                        productTemplateService.updateProductTemplates(new ProductTemplate[]
                    {
                        productTemplate
                    });

                    if (productTemplates != null)
                    {
                        foreach (ProductTemplate updatedProductTemplate in productTemplates)
                        {
                            Console.WriteLine(
                                "A product template with ID = '{0}' and name '{1}' was updated.",
                                updatedProductTemplate.id, updatedProductTemplate.name);
                        }
                    }
                    else
                    {
                        Console.WriteLine("No product templates updated.");
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("Failed to update product templates. Exception says \"{0}\"",
                                      e.Message);
                }
            }
        }
Exemplo n.º 17
0
        public TrinityPower OffensivePower()
        {
            Target = Targeting.BestAoeUnit(45f, true);
            if (Target == null)
            {
                return(null);
            }

            Vector3      location;
            TrinityActor target = Target;

            if (ShouldBloodRush(35f, out location))
            {
                return(Spells.BloodRush(Target.Position));
            }

            if (ShouldWalkToBuff(out location))
            {
                return(Walk(location, 3f));
            }

            if (Target.RadiusDistance < 50f)
            {
                if (ShouldBoneArmor())
                {
                    return(Spells.BoneArmor());
                }

                if (ShouldLandOfTheDead())
                {
                    return(Spells.LandOfTheDead());
                }

                if (ShouldSimulacrum())
                {
                    return(Spells.Simulacrum(Target.Position));
                }

                if (ShouldSkeletalMage())
                {
                    return(Spells.SkeletalMage(Target));
                }

                if (ShouldCommandSkeletons())
                {
                    return(Spells.CommandSkeletons(Target));
                }

                if (ShouldDevour())
                {
                    return(Spells.Devour());
                }

                if (ShouldFrailty(out target))
                {
                    return(Spells.Frailty(target));
                }

                if (ShouldDecrepify(out target))
                {
                    return(Spells.Decrepify(target));
                }

                if (ShouldCorpseExplosion())
                {
                    return(Spells.CorpseExplosion(Target.Position));
                }

                if (ShouldBoneSpikes())
                {
                    return(Spells.BoneSpikes(Target));
                }

                if (ShouldSiphonBlood())
                {
                    return(Spells.SiphonBlood(Target));
                }

                if (ShouldGrimScythe(out target))
                {
                    return(Spells.GrimScythe(target));
                }
            }
            if (ShouldWalk(out location))
            {
                return(Walk(location, 3f));
            }

            return(null);
        }
Exemplo n.º 18
0
        public static Composite CreateHolyHealOnlyBehavior(bool selfOnly, bool moveInRange)
        {
            HealerManager.NeedHealTargeting = true;
            WoWUnit healTarget = null;

            return(new
                   PrioritySelector(
                       ret => healTarget = selfOnly ? StyxWoW.Me : HealerManager.Instance.FirstUnit,
                       new Decorator(
                           ret => healTarget != null && (moveInRange || healTarget.InLineOfSpellSight && healTarget.DistanceSqr < 40 * 40),
                           new PrioritySelector(
                               Spell.WaitForCast(),
                               new Decorator(
                                   ret => moveInRange,
                                   Movement.CreateMoveToLosBehavior(ret => healTarget)),
                               // use fade to drop aggro.
                               Spell.Cast("Fade", ret => (StyxWoW.Me.GroupInfo.IsInParty || StyxWoW.Me.GroupInfo.IsInRaid) && StyxWoW.Me.CurrentMap.IsInstance && Targeting.GetAggroOnMeWithin(StyxWoW.Me.Location, 30) > 0),

                               Spell.Cast("Mindbender", ret => StyxWoW.Me.ManaPercent <= 80 && StyxWoW.Me.GotTarget),
                               Spell.Cast("Shadowfiend", ret => StyxWoW.Me.ManaPercent <= 80 && StyxWoW.Me.GotTarget),

                               Spell.BuffSelf("Desperate Prayer", ret => StyxWoW.Me.GetPredictedHealthPercent() <= 50),
                               Spell.BuffSelf("Hymn of Hope", ret => StyxWoW.Me.ManaPercent <= 15 && (!SpellManager.HasSpell("Shadowfiend") || SpellManager.Spells["Shadowfiend"].Cooldown)),
                               Spell.BuffSelf("Divine Hymn", ret => Unit.NearbyFriendlyPlayers.Count(p => p.GetPredictedHealthPercent() <= SingularSettings.Instance.Priest.DivineHymnHealth) >= SingularSettings.Instance.Priest.DivineHymnCount),

                               Spell.BuffSelf("Chakra: Sanctuary"), // all 3 are avail with a cd in holy - add them to the UI manager for holy priest - default Sanctuary
                               Spell.Cast(
                                   "Prayer of Mending",
                                   ret => healTarget,
                                   ret => ret is WoWPlayer && Group.Tanks.Contains((WoWPlayer)ret) && !((WoWUnit)ret).HasMyAura("Prayer of Mending", 3) &&
                                   Group.Tanks.Where(t => t != healTarget).All(p => !p.HasMyAura("Prayer of Mending"))),
                               Spell.Heal(
                                   "Renew",
                                   ret => healTarget,
                                   ret => healTarget is WoWPlayer && Group.Tanks.Contains(healTarget) && !healTarget.HasMyAura("Renew")),
                               Spell.Heal("Prayer of Healing",
                                          ret => healTarget,
                                          ret => StyxWoW.Me.HasAura("Serendipity", 2) && Unit.NearbyFriendlyPlayers.Count(p => p.GetPredictedHealthPercent() <= SingularSettings.Instance.Priest.PrayerOfHealingSerendipityHealth) >= SingularSettings.Instance.Priest.PrayerOfHealingSerendipityCount),
                               Spell.Heal("Circle of Healing",
                                          ret => healTarget,
                                          ret => Unit.NearbyFriendlyPlayers.Count(p => p.GetPredictedHealthPercent() <= SingularSettings.Instance.Priest.CircleOfHealingHealth) >= SingularSettings.Instance.Priest.CircleOfHealingCount),
                               Spell.CastOnGround(
                                   "Holy Word: Sanctuary",
                                   ret => Clusters.GetBestUnitForCluster(Unit.NearbyFriendlyPlayers.Select(p => p.ToUnit()), ClusterType.Radius, 10f).Location,
                                   ret => Clusters.GetClusterCount(healTarget,
                                                                   Unit.NearbyFriendlyPlayers.Select(p => p.ToUnit()),
                                                                   ClusterType.Radius, 10f) >= 4),
                               Spell.Heal(
                                   "Holy Word: Serenity",
                                   ret => healTarget,
                                   ret => ret is WoWPlayer && Group.Tanks.Contains(healTarget)),

                               Spell.Buff("Guardian Spirit",
                                          ret => healTarget,
                                          ret => healTarget.GetPredictedHealthPercent() <= 10),

                               Spell.CastOnGround("Lightwell", ret => WoWMathHelper.CalculatePointFrom(StyxWoW.Me.Location, healTarget.Location, 5f)),

                               Spell.Cast("Power Infusion", ret => healTarget.GetPredictedHealthPercent() < 40 || StyxWoW.Me.ManaPercent <= 20),
                               Spell.Heal(
                                   "Flash Heal",
                                   ret => healTarget,
                                   ret => StyxWoW.Me.HasAura("Surge of Light") && healTarget.GetPredictedHealthPercent() <= 90),
                               Spell.Heal(
                                   "Flash Heal",
                                   ret => healTarget,
                                   ret => healTarget.GetPredictedHealthPercent() < SingularSettings.Instance.Priest.HolyFlashHeal),
                               Spell.Heal(
                                   "Greater Heal",
                                   ret => healTarget,
                                   ret => healTarget.GetPredictedHealthPercent() < SingularSettings.Instance.Priest.HolyGreaterHeal),
                               Spell.Heal(
                                   "Heal",
                                   ret => healTarget,
                                   ret => healTarget.GetPredictedHealthPercent() < SingularSettings.Instance.Priest.HolyHeal),
                               new Decorator(
                                   ret => StyxWoW.Me.Combat && StyxWoW.Me.GotTarget && Unit.NearbyFriendlyPlayers.Count(u => u.IsInMyPartyOrRaid) == 0,
                                   new PrioritySelector(
                                       Movement.CreateMoveToLosBehavior(),
                                       Movement.CreateFaceTargetBehavior(),
                                       Helpers.Common.CreateInterruptSpellCast(ret => StyxWoW.Me.CurrentTarget),
                                       Spell.Cast("Shadow Word: Death", ret => StyxWoW.Me.CurrentTarget.GetPredictedHealthPercent() <= 20),
                                       Spell.Buff("Shadow Word: Pain", true, ret => SpellManager.HasSpell("Power Word: Solace")),
                                       Spell.Cast("Holy Word: Chastise"),
                                       Spell.Cast("Mindbender"),
                                       Spell.Cast("Holy Fire"),
                                       Spell.Cast("Power Word: Solace"),
                                       Spell.Cast("Smite", ret => !SpellManager.HasSpell("Power Word: Solace")),
                                       Spell.Cast("Mind Spike", ret => !SpellManager.HasSpell("Power Word: Solace")),
                                       Movement.CreateMoveToTargetBehavior(true, 35f)
                                       )),
                               new Decorator(
                                   ret => moveInRange,
                                   Movement.CreateMoveToTargetBehavior(true, 35f, ret => healTarget))

                               // Divine Hymn
                               // Desperate Prayer
                               // Prayer of Mending
                               // Prayer of Healing
                               // Power Word: Barrier
                               // TODO: Add smite healing. Only if Atonement is talented. (Its useless otherwise)
                               ))));
        }
Exemplo n.º 19
0
        internal static Packet MobileIncomingItemColorize(Packet p, Assistant.Mobile m, bool newmobincoming, Assistant.Item item = null)
        {
            int ltHue = Engine.MainWindow.LTHilight;

            if (newmobincoming)
            {
                if (ltHue != 0 && Targeting.IsLastTarget(m))
                {
                    p = RewriteColor(p, (ushort)ltHue);
                }
                else
                {
                    // Blocco Color Highlight flag
                    if ((m != World.Player && Engine.MainWindow.ColorFlagsHighlightCheckBox.Checked) || (m == World.Player && Engine.MainWindow.ColorFlagsSelfHighlightCheckBox.Checked))
                    {
                        if (m.Poisoned)
                        {
                            p = RewriteColor(p, (ushort)HighLightColor.Poison);
                        }

                        else if (m.Paralized)
                        {
                            p = RewriteColor(p, (ushort)HighLightColor.Paralized);
                        }

                        else if (m.Blessed)                         // Mortal
                        {
                            p = RewriteColor(p, (ushort)HighLightColor.Mortal);
                        }
                    }
                }
            }
            else
            {
                if (m.IsGhost)                 // Non eseguire azione se fantasma
                {
                    return(p);
                }

                if (ltHue != 0 && Targeting.IsLastTarget(m))
                {
                    Assistant.Client.Instance.SendToClient(new EquipmentItem(item, (ushort)(ltHue & 16383), m.Serial));
                }
                else
                {
                    int color = 0;
                    if (m.Poisoned)
                    {
                        color = (int)HighLightColor.Poison;
                    }
                    else if (m.Paralized)
                    {
                        color = (int)HighLightColor.Paralized;
                    }
                    else if (m.Blessed)                     // Mortal
                    {
                        color = (int)HighLightColor.Mortal;
                    }

                    if (color != 0)
                    {
                        Assistant.Client.Instance.SendToClient(new EquipmentItem(item, (ushort)color, m.Serial));
                    }
                }
            }
            return(p);
        }
Exemplo n.º 20
0
 public void OnAddToHotBag()
 {
     World.Player.SendMessage(MsgLevel.Force, LocString.TargItemAdd);
     Targeting.OneTimeTarget(new Targeting.TargetResponseCallback(OnTarget));
 }
Exemplo n.º 21
0
        private static Targeting ParseTargeting(Dictionary <string, object> data)
        {
            Targeting targeting = new Targeting();

            if (data.ContainsKey("id"))
            {
                targeting.Id = int.Parse(data["id"].ToString());
            }

            if (data.ContainsKey("method"))
            {
                targeting.Method = (TargetingMethod)Enum.Parse(
                    typeof(TargetingMethod), data["method"].ToString().Replace("_", ""), true);
            }

            if (data.ContainsKey("type"))
            {
                targeting.Type = (TargetingType)Enum.Parse(
                    typeof(TargetingType), data["type"].ToString().Replace("_", ""), true);
            }

            if (data.ContainsKey("time"))
            {
                targeting.Time = int.Parse(data["time"].ToString());
            }

            if (data.ContainsKey("startTime"))
            {
                targeting.StartTime = int.Parse(data["startTime"].ToString());
            }

            if (data.ContainsKey("endTime"))
            {
                targeting.EndTime = int.Parse(data["endTime"].ToString());
            }

            if (data.ContainsKey("interval"))
            {
                targeting.Interval = int.Parse(data["interval"].ToString());
            }

            if (data.ContainsKey("until"))
            {
                targeting.Until = int.Parse(data["until"].ToString());
            }

            //__value__

            targeting.AreaList = new List <TargetingArea>();

            if (data.ContainsKey("AreaList"))
            {
                foreach (var targetingAreaListData in (List <Dictionary <string, object> >)data["AreaList"])
                {
                    if (targetingAreaListData.Count < 1)
                    {
                        continue;
                    }

                    foreach (var targetingAreaData in (List <Dictionary <string, object> >)targetingAreaListData["Area"])
                    {
                        targeting.AreaList.Add(ParseTargetingArea(targetingAreaData));
                    }
                }
            }

            if (data.ContainsKey("Cost"))
            {
                foreach (var costData in (List <Dictionary <string, object> >)data["Cost"])
                {
                    targeting.Cost = new Cost();
                    if (costData.ContainsKey("hp"))
                    {
                        targeting.Cost.Hp = int.Parse(costData["hp"].ToString());
                    }
                    if (costData.ContainsKey("mp"))
                    {
                        targeting.Cost.Hp = int.Parse(costData["mp"].ToString());
                    }
                    break;
                }
            }

            targeting.ProjectileSkillList = new List <ProjectileSkill>();

            if (data.ContainsKey("ProjectileSkillList"))
            {
                foreach (var pslData in (List <Dictionary <string, object> >)data["ProjectileSkillList"])
                {
                    if (!pslData.ContainsKey("ProjectileSkill"))
                    {
                        continue;
                    }

                    foreach (var psData in (List <Dictionary <string, object> >)pslData["ProjectileSkill"])
                    {
                        targeting.ProjectileSkillList.Add(ParseProjectileSkill(psData));
                    }
                }
            }

            return(targeting);
        }
Exemplo n.º 22
0
 private void AddFriendToGroup()
 {
     World.Player.SendMessage(MsgLevel.Friend, $"Target friend to add to group '{GroupName}'");
     Targeting.OneTimeTarget(OnAddFriendTarget);
 }
    /// <summary>
    /// Run the code example.
    /// </summary>
    /// <param name="user">The DFP user object running the code example.</param>
    public override void Run(DfpUser user) {
      // Get the LineItemService.
      LineItemService lineItemService =
          (LineItemService) user.GetService(DfpService.v201508.LineItemService);

      // Set the order that all created line items will belong to and the
      // video ad unit ID to target.
      long orderId = long.Parse(_T("INSERT_ORDER_ID_HERE"));
      string targetedVideoAdUnitId = _T("INSERT_TARGETED_VIDEO_AD_UNIT_ID_HERE");

      // Set the custom targeting value ID representing the metadata
      // on the content to target. This would typically be from a key representing
      // a "genre" and a value representing something like "comedy". The value must
      // be from a key in a content metadata key hierarchy.
      long contentCustomTargetingValueId =
          long.Parse(_T("INSERT_CONTENT_CUSTOM_TARGETING_VALUE_ID_HERE"));

      // Create content targeting.
      ContentMetadataKeyHierarchyTargeting contentMetadataTargeting =
          new ContentMetadataKeyHierarchyTargeting();
      contentMetadataTargeting.customTargetingValueIds =
          new long[] {contentCustomTargetingValueId};

      ContentTargeting contentTargeting = new ContentTargeting();
      contentTargeting.targetedContentMetadata =
          new ContentMetadataKeyHierarchyTargeting[] {contentMetadataTargeting};

      // Create inventory targeting.
      InventoryTargeting inventoryTargeting = new InventoryTargeting();
      AdUnitTargeting adUnitTargeting = new AdUnitTargeting();
      adUnitTargeting.adUnitId = targetedVideoAdUnitId;
      adUnitTargeting.includeDescendants = true;
      inventoryTargeting.targetedAdUnits = new AdUnitTargeting[] {adUnitTargeting};

      // Create video position targeting.
      VideoPosition videoPosition = new VideoPosition();
      videoPosition.positionType = VideoPositionType.PREROLL;
      VideoPositionTarget videoPositionTarget = new VideoPositionTarget();
      videoPositionTarget.videoPosition = videoPosition;
      VideoPositionTargeting videoPositionTargeting = new VideoPositionTargeting();
      videoPositionTargeting.targetedPositions = new VideoPositionTarget[] {videoPositionTarget};

      // Create targeting.
      Targeting targeting = new Targeting();
      targeting.contentTargeting = contentTargeting;
      targeting.inventoryTargeting = inventoryTargeting;
      targeting.videoPositionTargeting = videoPositionTargeting;

      // Create local line item object.
      LineItem lineItem = new LineItem();
      lineItem.name = "Video line item - " + this.GetTimeStamp();
      lineItem.orderId = orderId;
      lineItem.targeting = targeting;
      lineItem.lineItemType = LineItemType.SPONSORSHIP;
      lineItem.allowOverbook = true;

      // Set the environment type to video.
      lineItem.environmentType = EnvironmentType.VIDEO_PLAYER;

      // Set the creative rotation type to optimized.
      lineItem.creativeRotationType = CreativeRotationType.OPTIMIZED;

      // Create the master creative placeholder.
      CreativePlaceholder creativeMasterPlaceholder = new CreativePlaceholder();
      Size size1 = new Size();
      size1.width = 400;
      size1.height = 300;
      size1.isAspectRatio = false;
      creativeMasterPlaceholder.size = size1;

      // Create companion creative placeholders.
      CreativePlaceholder companionCreativePlaceholder1 = new CreativePlaceholder();
      Size size2 = new Size();
      size2.width = 300;
      size2.height = 250;
      size2.isAspectRatio = false;
      companionCreativePlaceholder1.size = size2;

      CreativePlaceholder companionCreativePlaceholder2 = new CreativePlaceholder();
      Size size3 = new Size();
      size3.width = 728;
      size3.height = 90;
      size3.isAspectRatio = false;
      companionCreativePlaceholder2.size = size3;

      // Set companion creative placeholders.
      creativeMasterPlaceholder.companions = new CreativePlaceholder[] {
          companionCreativePlaceholder1, companionCreativePlaceholder2};

      // Set the size of creatives that can be associated with this line item.
      lineItem.creativePlaceholders = new CreativePlaceholder[] {creativeMasterPlaceholder};

      // Set delivery of video companions to optional.
      lineItem.companionDeliveryOption = CompanionDeliveryOption.OPTIONAL;

      // Set the line item to run for one month.
      lineItem.startDateTimeType = StartDateTimeType.IMMEDIATELY;
      lineItem.endDateTime =
          DateTimeUtilities.FromDateTime(System.DateTime.Now.AddMonths(1), "America/New_York");

      // Set the cost per day to $1.
      lineItem.costType = CostType.CPD;
      Money money = new Money();
      money.currencyCode = "USD";
      money.microAmount = 1000000L;
      lineItem.costPerUnit = money;

      // Set the percentage to be 100%.
      Goal goal = new Goal();
      goal.goalType = GoalType.DAILY;
      goal.unitType = UnitType.IMPRESSIONS;
      goal.units = 100;
      lineItem.primaryGoal = goal;

      try {
        // Create the line item on the server.
        LineItem[] createdLineItems = lineItemService.createLineItems(new LineItem[] {lineItem});

        foreach (LineItem createdLineItem in createdLineItems) {
          Console.WriteLine("A line item with ID \"{0}\", belonging to order ID \"{1}\", and " +
              "named \"{2}\" was created.", createdLineItem.id, createdLineItem.orderId,
              createdLineItem.name);
        }
      } catch (Exception e) {
        Console.WriteLine("Failed to create line items. Exception says \"{0}\"",
            e.Message);
      }
    }
        /// <summary>
        /// Run the code example.
        /// </summary>
        /// <param name="user">The DFP user object running the code example.</param>
        public override void Run(DfpUser user)
        {
            // Get the LineItemService.
            LineItemService lineItemService =
                (LineItemService)user.GetService(DfpService.v201403.LineItemService);

            // Set the order that all created line items will belong to and the
            // placement containing ad units with a mobile target platform.
            long orderId = long.Parse(_T("INSERT_ORDER_ID_HERE"));

            long[] targetedPlacementIds = new long[] { long.Parse(_T("INSERT_MOBILE_PLACEMENT_ID_HERE")) };

            // Create inventory targeting.
            InventoryTargeting inventoryTargeting = new InventoryTargeting();

            inventoryTargeting.targetedPlacementIds = targetedPlacementIds;

            // Create technology targeting.
            TechnologyTargeting technologyTargeting = new TechnologyTargeting();

            // Create device manufacturer targeting.
            DeviceManufacturerTargeting deviceManufacturerTargeting = new DeviceManufacturerTargeting();

            deviceManufacturerTargeting.isTargeted = true;

            // Target the Google device manufacturer (40100).
            Technology deviceManufacturerTechnology = new Technology();

            deviceManufacturerTechnology.id = 40100L;
            deviceManufacturerTargeting.deviceManufacturers =
                new Technology[] { deviceManufacturerTechnology };
            technologyTargeting.deviceManufacturerTargeting = deviceManufacturerTargeting;

            // Create mobile device targeting.
            MobileDeviceTargeting mobileDeviceTargeting = new MobileDeviceTargeting();

            // Exclude the Nexus One device (604046).
            Technology mobileDeviceTechnology = new Technology();

            mobileDeviceTechnology.id = 604046L;
            mobileDeviceTargeting.targetedMobileDevices = new Technology[] { mobileDeviceTechnology };
            technologyTargeting.mobileDeviceTargeting   = mobileDeviceTargeting;

            // Create mobile device submodel targeting.
            MobileDeviceSubmodelTargeting mobileDeviceSubmodelTargeting =
                new MobileDeviceSubmodelTargeting();

            // Target the iPhone 4 device submodel (640003).
            Technology mobileDeviceSubmodelTechnology = new Technology();

            mobileDeviceSubmodelTechnology.id = 640003L;
            mobileDeviceSubmodelTargeting.targetedMobileDeviceSubmodels =
                new Technology[] { mobileDeviceSubmodelTechnology };
            technologyTargeting.mobileDeviceSubmodelTargeting = mobileDeviceSubmodelTargeting;

            // Create targeting.
            Targeting targeting = new Targeting();

            targeting.inventoryTargeting  = inventoryTargeting;
            targeting.technologyTargeting = technologyTargeting;

            // Create local line item object.
            LineItem lineItem = new LineItem();

            lineItem.name          = "Mobile line item";
            lineItem.orderId       = orderId;
            lineItem.targeting     = targeting;
            lineItem.lineItemType  = LineItemType.STANDARD;
            lineItem.allowOverbook = true;

            // Set the target platform to mobile.
            lineItem.targetPlatform = TargetPlatform.MOBILE;

            // Set the creative rotation type to even.
            lineItem.creativeRotationType = CreativeRotationType.EVEN;

            // Create the creative placeholder.
            CreativePlaceholder creativePlaceholder = new CreativePlaceholder();
            Size size = new Size();

            size.width               = 300;
            size.height              = 250;
            size.isAspectRatio       = false;
            creativePlaceholder.size = size;

            // Set the size of creatives that can be associated with this line item.
            lineItem.creativePlaceholders = new CreativePlaceholder[] { creativePlaceholder };

            // Set the length of the line item to run.
            lineItem.startDateTimeType = StartDateTimeType.IMMEDIATELY;
            lineItem.endDateTime       = DateTimeUtilities.FromString("20120901 00:00:00");

            // Set the cost per unit to $2.
            lineItem.costType = CostType.CPM;
            Money money = new Money();

            money.currencyCode   = "USD";
            money.microAmount    = 2000000L;
            lineItem.costPerUnit = money;

            // Set the number of units bought to 500,000 so that the budget is
            // $1,000.
            lineItem.unitsBought = 500000L;
            lineItem.unitType    = UnitType.IMPRESSIONS;

            try {
                // Create the line item on the server.
                LineItem[] createdLineItems = lineItemService.createLineItems(new LineItem[] { lineItem });

                foreach (LineItem createdLineItem in createdLineItems)
                {
                    Console.WriteLine("A line item with ID \"{0}\", belonging to order ID \"{1}\", and " +
                                      "named \"{2}\" was created.", createdLineItem.id, createdLineItem.orderId,
                                      createdLineItem.name);
                }
            } catch (Exception ex) {
                Console.WriteLine("Failed to create line items. Exception says \"{0}\"",
                                  ex.Message);
            }
        }
Exemplo n.º 25
0
    // Use this for initialization
    void Start()
    {
        m_Targeting = GetComponent<Targeting>();
        selectedObjects = new List<GameObject>();

        musicSource = GetComponent<AudioSource> ();
    }
Exemplo n.º 26
0
 public void SetHotBag()
 {
     World.Player.SendMessage(MsgLevel.Force, LocString.TargCont);
     Targeting.OneTimeTarget(new Targeting.TargetResponseCallback(OnTargetBag));
 }
Exemplo n.º 27
0
        private static bool TargetType(string command, Argument[] args, bool quiet, bool force)
        {
            if (Targeting.FromGrabHotKey)
            {
                return(false);
            }

            if (args.Length < 1)
            {
                throw new RunTimeError(null, "Usage: targettype (graphic) OR ('name of item or mobile type') [inrangecheck]");
            }

            string gfxStr = args[0].AsString();
            Serial gfx    = Utility.ToUInt16(gfxStr, 0);

            bool inRangeCheck = false;

            if (args.Length == 2)
            {
                inRangeCheck = args[1].AsBool();
            }

            ArrayList list = new ArrayList();

            // No graphic id, maybe searching by name?
            if (gfx == 0)
            {
                List <Item> items = World.FindItemsByName(gfxStr);

                Item backItem = World.Player.Backpack.FindItemByName(gfxStr, true);

                if (backItem != null)
                {
                    items.Add(backItem);
                }

                if (items.Count > 0)
                {
                    list.AddRange(inRangeCheck
                        ? items.Where(i => Utility.InRange(World.Player.Position, i.Position, 2)).ToList()
                        : items);
                }
                else // try to find a mobile
                {
                    List <Mobile> mobiles = World.FindMobilesByName(gfxStr);

                    if (mobiles.Count > 0)
                    {
                        list.AddRange(inRangeCheck
                            ? mobiles.Where(m => Utility.InRange(World.Player.Position, m.Position, 2)).ToList()
                            : mobiles);
                    }
                }
            }
            else // check if they are mobile or an item
            {
                foreach (Mobile find in World.MobilesInRange())
                {
                    if (find.Body == gfx)
                    {
                        list.Add(find);
                    }
                }

                if (list.Count == 0)
                {
                    foreach (Item i in World.Items.Values)
                    {
                        if (i.ItemID == gfx && !i.IsInBank)
                        {
                            list.Add(i);
                        }
                    }
                }
            }

            if (list.Count > 0)
            {
                Targeting.Target(list[Utility.Random(list.Count)]);
            }
            else
            {
                World.Player.SendMessage(MsgLevel.Warning, LocString.NoItemOfType,
                                         gfx.IsMobile ? $"Character [{gfx}]" : ((ItemID)gfx.Value).ToString());
            }

            return(true);
        }
Exemplo n.º 28
0
        //private void AddCharms()
        //{
        //    var xml = XDocument.Load(RootFolder + _region + "/StrSheet_Charm.xml");
        //    var xml1 = XDocument.Load(RootFolder + _region + "/CharmIconData.xml");
        //    var charmList = (from item in xml.Root.Elements("String")
        //                     join icon in xml1.Root.Elements("Icon") on item.Attribute("id").Value equals icon.Attribute("charmId").Value
        //                     let id = item.Attribute("id").Value
        //                     let name = item.Attribute("string").Value
        //                     let tooltip = item.Attribute("tooltip").Value
        //                     let iconName = icon.Attribute("iconName").Value
        //                     select new HotDot(int.Parse(id), "Charm", 0, "0", 0, 0, name, "", "",tooltip, iconName, "Buff", true, true, iconName)).ToList();
        //    Dotlist = Dotlist.Union(charmList).ToList();
        //}
        private void RawExtract(DataCenter dc, List <Skill> skilllist, List <Template> templates)
        {
            var abnormalityDC = dc.Root.Children("Abnormality").SelectMany(x => x.Children("Abnormal"));
            //var interesting = new string[] {"1", "3", "4", "5", "6", "7", "8", "9", "18", "19","36", "20", "22", "24", "25", "27", "28", "30", "103", "104", "105", "108", "162", "167", "168", "203", "207", "210", "208", "221", "227", "229", "231", "235", "236", "237" , "249", "255","260", "283", "316" };
            //var notinteresting = new string[] {"8", "9", "18", "20", "27", "28", "103", "105", "108", "168", "221", "227" };
            var redirects_to_ignore = new int[] { 161, 182, 252, 264 };
            var redirects_to_follow = new int[] { 64, 161, 182, 223, 248, 252, 264, 271 };
            var Dots = (from item in abnormalityDC
                        let abnormalid = item["id", 0].ToInt32()
                                         let isShow = item["isShow", "False"].AsString != "False"
                                                      let property = item["property", 0].ToString()
                                                                     let isBuff = item["isBuff", true].ToBoolean()
                                                                                  let time = item["infinity", false].ToBoolean() ? "0" : item["time", "0"].AsString
                                                                                             from eff in item.Children("AbnormalityEffect").DefaultIfEmpty()
                                                                                             let type = eff?["type", 0].ToInt32() ?? 0
                                                                                                        let method = eff?["method", 0].ToInt32() ?? 0
                                                                                                                     let num = item.Children("AbnormalityEffect").TakeWhile(x => x != eff).Count() + 1
                                                                                                                               let amount = eff?["value", "0"].AsString ?? "0"
                                                                                                                                            let tick = eff?["tickInterval", 0].ToString() ?? "0"
                                                                                                                                                       where (((type == 51 || type == 52) && tick != "0") || (!redirects_to_ignore.Contains(type)))                                                                   // && amount != "" && method != -1
//                    where (((type == "51" || type == "52") && tick != "0") || (!redirects_to_ignore.Contains(type) && (isShow != "False" || abnormalid == "201" || abnormalid == "202" || abnormalid == "10152050"))) && amount != "" && method != ""
                                                                                                                                                       select new { abnormalid, type, amount = amount.Contains(',')?amount.Split(',').Last() : amount, method, time, tick, num, property, isBuff, isShow }).ToList(); //// 201 202 - marked as not shown, but needed
            var parser = (from item in abnormalityDC
                          let abnormalid = item["id", 0].ToInt32()
                                           let isShow = item["isShow", "False"].AsString != "False"
                                                        from eff in item.Children("AbnormalityEffect")
                                                        let type = eff["type", 0].ToInt32()
                                                                   where redirects_to_follow.Contains(type)
                                                                   let num = item.Children("AbnormalityEffect").TakeWhile(x => x != eff).Count() + 1
                                                                             let redirected = eff["value", 0].ToInt32()
                                                                                              select new { abnormalid, isShow, num, redirected }).ToList();

            for (var i = 1; i <= 4; i++) //5 lvl of redirection
            {
                parser = (from item in parser join item1 in parser on item.redirected equals item1.abnormalid into wrapped
                          from wrap in wrapped.DefaultIfEmpty()
                          select new { item.abnormalid, item.isShow, item.num, redirected = wrap == null ? item.redirected : wrap.redirected }).ToList();
                parser = parser.Distinct((x, y) => x.abnormalid == y.abnormalid && x.redirected == y.redirected, x => x.abnormalid.GetHashCode()).ToList();    //don't eat all RAM in redirect loops
            }
            parser = parser.Where(x => x.isShow).ToList();
            var Dotdata = (from item in abnormalityDC
                           join item1 in parser on item["id", 0].ToInt32() equals item1.redirected into parsed
                           from par in parsed
                           let abnormalid = par.abnormalid
                                            let isShow = par.isShow
                                                         let isBuff = item["isBuff", true].ToBoolean()
                                                                      let time = item["infinity", false].ToBoolean() ? "0" : item["time", "0"].AsString
                                                                                 let property = item["property", 0].ToString()
                                                                                                from eff in item.Children("AbnormalityEffect")
                                                                                                let type = eff["type", -1].ToInt32()
                                                                                                           let method = eff["method", -1].ToInt32()
                                                                                                                        let num = par.num
                                                                                                                                  let amount = eff["value", ""].AsString
                                                                                                                                               let tick = eff["tickInterval", 0].ToString()
                                                                                                                                                          where (((type == 51 || type == 52) && tick != "0") || ((isShow || abnormalid == 201 || abnormalid == 202))) && amount != "" && method != -1
                                                                                                                                                          select new { abnormalid, type, amount, method, time, tick, num, property, isBuff, isShow }).ToList();

            Dots = Dots.Union(Dotdata).ToList();
            var Missing = parser.Distinct((x, y) => x.redirected.Equals(y.redirected), x => x.redirected.GetHashCode()).ToList();

            Dots = Dots.Distinct((x, y) => x.abnormalid.Equals(y.abnormalid) && x.num == y.num, x => (x.abnormalid, x.num).GetHashCode()).ToList();
            var subs = (from dot in Dots
                        let change = ((dot.method == 3 || dot.method == 4 || dot.method == 0) && dot.type != 227 && dot.type != 228)
                            ? (dot.type == 51 || dot.type == 52)
                                ? Math.Abs(Math.Round(double.Parse(dot.amount, CultureInfo.InvariantCulture) * 100, 2)).ToString("r", CultureInfo.InvariantCulture) + "%"
                                : Math.Abs(Math.Round((1 - double.Parse(dot.amount, CultureInfo.InvariantCulture)) * 100, 2)).ToString("r", CultureInfo.InvariantCulture) + "%"
                            : dot.amount
                                     select new formatter {
                abnormalid = dot.abnormalid, index = dot.num, tick = dot.tick, change = change, time = dot.time
            })
                       .GroupBy(x => x.abnormalid).ToDictionary(g => g.Key, g => g.ToDictionary(h => h.index));

            Dots = Dots.Distinct((x, y) => x.abnormalid.Equals(y.abnormalid) && x.type == y.type, x => (x.abnormalid, x.type).GetHashCode()).ToList();

            var Names = (from item in dc.Root.Children("StrSheet_Abnormality").SelectMany(x => x.Children("String"))
                         let abnormalid = item["id", 0].ToInt32()
                                          let name = item["name", ""].AsString
                                                     where abnormalid != 0 && name != "" && !name.Contains("BTS")
                                                     let tooltip = item["tooltip"].IsNull ? "" : SubValues(item["tooltip", ""].AsString
                                                                                                           //                                    .Replace("$H_W_GOOD","").Replace("H_W_GOOD", "").Replace("$COLOR_END","").Replace("$H_W_BAD","").Replace("$H_W_Bad","").Replace("H_W_BAD","").Replace("$BR"," ").Replace("<br>", " ")
                                                                                                           .Replace("\n", "$BR").Replace("\r", "$BR "), abnormalid, subs.GetValueOrDefault(abnormalid))
                                                                   where !tooltip.Contains("BTS")
                                                                   select new { abnormalid, name, tooltip }).Distinct((x, y) => x.abnormalid == y.abnormalid, x => x.abnormalid.GetHashCode()).ToList();

            Missing.ForEach(x =>
            {
                var found = Names.FirstOrDefault(z => x.abnormalid == z.abnormalid);
                if (found != null)
                {
                    if (!Names.Any(z => z.abnormalid == x.redirected))
                    {
                        Names.Add(new { abnormalid = x.redirected, name = found.name, tooltip = found.tooltip });
                    }
                }
            });

            var Icons = (from item in dc.Root.Children("AbnormalityIconData").SelectMany(x => x.Children("Icon"))
                         let abnormalid = item["abnormalityId", 0].ToInt32()
                                          let iconName = item["iconName", ""].AsString
                                                         where abnormalid != 0 && iconName != ""
                                                         select new { abnormalid, iconName }).Distinct((x, y) => x.abnormalid == y.abnormalid, x => x.abnormalid.GetHashCode()).ToList();

            Missing.ForEach(x =>
            {
                var found = Icons.FirstOrDefault(z => x.abnormalid == z.abnormalid);
                if (found != null)
                {
                    if (!Icons.Any(z => z.abnormalid == x.redirected))
                    {
                        Icons.Add(new { abnormalid = x.redirected, iconName = found.iconName });
                    }
                }
            });

            var SkillToName = (from item in dc.Root.Children("ItemData").SelectMany(x => x.Children("Item"))
                               let comb = item["category", "no"].AsString
                                          let skillid = item["linkSkillId", 0].ToInt32()
                                                        let nameid = item["id", 0].ToInt32()
                                                                     where ((comb == "combat") || (comb == "brooch") || (comb == "charm") || (comb == "magical")) && skillid != 0 && nameid != 0 select new { skillid, nameid });
            // filter only combat items, we don't need box openings etc.
            var ItemNames = (from item in dc.Root.Children("StrSheet_Item").SelectMany(x => x.Children("String"))
                             let nameid = item["id", 0].ToInt32()
                                          let name = item["string", ""].AsString
                                                     where nameid != 0 && name != "" && name != "[TBU]" && name != "TBU_new_in_V24" select new { nameid, name }).ToList();
            var Items = (from item in SkillToName join nam in ItemNames on item.nameid equals nam.nameid orderby item.skillid where nam.name != ""
                         select new { item.skillid, item.nameid, nam.name }).ToList();

            string[] abnormalFilter = { "AbnormalityOnPvp", "AbnormalityOnCommon" };
            var      ItemSkills     = (from skill in dc.Root.Children("SkillData").SelectMany(x => x.Children("Skill"))
                                       let template = skill["templateId", 0].ToInt32()
                                                      let skillid = skill["id", 0].ToInt32()
                                                                    where skill.Parent["huntingZoneId", 0].ToInt32() == 0 && template != 0 && skillid != 0
                                                                    from TargetingList in skill.Children("TargetingList")
                                                                    from Targeting in TargetingList.Children("Targeting")
                                                                    from AreaList in Targeting.Children("AreaList")
                                                                    from Area in AreaList.Children("Area")
                                                                    from Effect in Area.Children("Effect")
                                                                    from Abnormal in Effect.Children(abnormalFilter)
                                                                    let abid = Abnormal["id", 0].ToInt32()
                                                                               where abid != 0
                                                                               select new { skillid, abid, template }).ToList();
            var ItemAbnormals = (from skills in ItemSkills
                                 join names in Items on skills.skillid equals names.skillid
                                 orderby names.nameid
                                 select new { abid = skills.abid, nameid = names.nameid, names.name }).ToList();

            ItemAbnormals = ItemAbnormals.Distinct((x, y) => x.abid == y.abid, x => x.abid.GetHashCode()).ToList();

            if (_region != "KR")
            {
                skilllist.Where(x => x.Name.Contains(":")).ToList().ForEach(x => x.Name = x.Name.Replace(":", ""));
            }
            var directSKills = (from iskills in ItemSkills
                                join temp in templates on iskills.template equals temp.templateId
                                join names in skilllist on new { temp.PClass, iskills.skillid } equals new { names.PClass, skillid = names.Id }
                                where iskills.abid != 902 //noctineum, bugged skills abnormals
                                orderby iskills.abid
                                select new { abnormalid = iskills.abid, name = names.Name, iconName = names.IconName }).ToList();

            var Passives = directSKills.GroupBy(x => x.abnormalid).Where(x => x.Key != 400500 && x.Key != 400501 && x.Key != 400508).Select(x1 => new {
                abnormalid = x1.Key,
                name       = x1.Count() > 1 ? SkillExtractor.RemoveLvl(x1.First().name) : x1.First().name,
                iconName   = x1.First().iconName
            }).ToList();

            var Glyphs = (from item in dc.Root.FirstChild("StrSheet_Crest").Children("String")
                          join crestItem in dc.Root.FirstChild("CrestData").Children("CrestItem") on item["id", 0].ToInt32() equals crestItem["id", 0].ToInt32()
                          let passiveid = item["id", 0].ToInt32()
                                          let name = item["name", ""].AsString
                                                     let pclass = SkillExtractor.ClassConv(crestItem["class", ""].AsString)
                                                                  let skillname = item["skillName", ""].AsString
                                                                                  let searchname = _region == "RU"? skillname.Replace("Всплеск ярости", "Сила гиганта").Replace("Разряд бумеранга", "Возвратный разряд").Replace("Фронтальная защита", "Сзывающий клич").Replace(":", "") :
                                                                                                   _region != "KR"?skillname.Replace(":", ""): skillname
                                                                                                   let iconName1 = skilllist.Find(x => x.Name.Contains(searchname) && x.PClass == pclass)?.IconName ?? ""
                                                                                                                   let skillId1 = skilllist.Find(x => x.Name.Contains(searchname) && x.PClass == pclass)?.Id ?? 0
                                                                                                                                  let iconName = _region == "KR" || iconName1 != "" || !name.Contains(" ") ? iconName1 : skilllist.Find(x => x.Name.ToLowerInvariant().Contains(
                                                                                                                                                                                                                                            _region == "EU-FR" ? name.ToLowerInvariant().Remove(name.LastIndexOf(' ')) : name.ToLowerInvariant().Substring(name.IndexOf(' ') + 1)
                                                                                                                                                                                                                                            ))?.IconName ?? ""
                                                                                                                                                 let skillId = _region == "KR" || skillId1 != 0 || !name.Contains(" ") ? skillId1 : skilllist.Find(x => x.Name.ToLowerInvariant().Contains(
                                                                                                                                                                                                                                                       _region == "EU-FR" ? name.ToLowerInvariant().Remove(name.LastIndexOf(' ')) : name.ToLowerInvariant().Substring(name.IndexOf(' ') + 1)
                                                                                                                                                                                                                                                       ))?.Id ?? 0
                                                                                                                                                               let tooltip = item["tooltip", ""].AsString
                                                                                                                                                                             select new { passiveid, name, skillname, skillId, iconName, tooltip });
            //dont parse CrestData.xml for passiveid<=>crestid, since they are identical now
            var PassiveData = (from item in dc.Root.Children("Passivity").SelectMany(x => x.Children("Passive"))
                               let passiveid = item["id", 0].ToInt32()
                                               join glyph in Glyphs on passiveid equals glyph.passiveid
                                               let type = item["type", 0].ToInt32()
                                                          let method = item["method", 0].ToInt32()
                                                                       where (type == 209 || (type == 210 && method == 4) || type == 156 || type == 157 || type == 80 || type == 232 || type == 106)
                                                                       let abnormalid = item["value", 0].ToInt32()
                                                                                        where abnormalid != 0 && abnormalid != 500100
                                                                                        select new { abnormalid, name = (isGlyph(glyph.name))?$"{glyph.skillname}({glyph.name})": glyph.name, glyph.iconName }).ToList();

            Passives = Passives.Union(PassiveData, (x, y) => (x.abnormalid == y.abnormalid), x => x.abnormalid.GetHashCode()).ToList();

            Dotlist = (from dot in Dots
                       join nam in Names on dot.abnormalid equals nam.abnormalid into inames
                       join icon in Icons on dot.abnormalid equals icon.abnormalid into iicons
                       join skills in ItemAbnormals on dot.abnormalid equals skills.abid into iskills
                       join glyph in Passives on dot.abnormalid equals glyph.abnormalid into gskills
                       from iname in inames.DefaultIfEmpty()
                       from iicon in iicons.DefaultIfEmpty()
                       from iskill in iskills.DefaultIfEmpty()
                       from gskill in gskills.DefaultIfEmpty()

                       where (iname != null || iskill != null || gskill != null)
                       orderby dot.abnormalid, dot.type
                       select new HotDot(dot.abnormalid, dot.type, double.Parse(dot.amount, CultureInfo.InvariantCulture), dot.method, long.Parse(dot.time), (int)Math.Floor(double.Parse(dot.tick, CultureInfo.InvariantCulture)), gskill == null?iname?.name ?? iskill.name:gskill.name, iskill == null?"":iskill.nameid.ToString(), iskill == null ? "" : iskill.name, iname?.tooltip ?? "", gskill == null?iicon?.iconName ?? "":gskill.iconName, dot.property, dot.isBuff, dot.isShow, iicon?.iconName ?? "")).ToList();

            var Crests = (from item in dc.Root.Children("Passivity").SelectMany(x => x.Children("Passive"))
                          let value = item["value", 0f].ToSingle()
                                      let prob = item["prob", 0f].ToSingle() * 100
                                                 let type = item["type", 0].ToInt32()
                                                            let passiveid = item["id", 0].ToInt32()
                                                                            join glyph in Glyphs on passiveid equals glyph.passiveid
                                                                            join icon in dc.Root.FirstChild("CrestIconData").Children("Icon") on passiveid equals icon["crestId", 0].ToInt32()
                                                                            let glyphIcon = icon["iconName", ""].AsString
                                                                                            let tooltip = glyph.tooltip == null ? "" : glyph.tooltip.Replace("$BR", " ").Replace("\n", " ").Replace("$value",
                                                                                                                                                                                                    type == 72?(-value).ToString():type == 171 || type == 26 || type == 175 ? value.ToString():Math.Round(Math.Abs(value * 100 - 100), 2) + "%"
                                                                                                                                                                                                    ).Replace("$prob", prob + "%")
                                                                                                          select new { passiveid, glyph.skillname, glyph.skillId, glyph.iconName, glyph.name, glyphIcon, tooltip })
                         .Distinct((x, y) => (x.passiveid == y.passiveid), x => x.passiveid.GetHashCode()).ToList();

            var outputFile = new StreamWriter(Path.Combine(OutFolder, $"glyph-{_region}.tsv"));

            foreach (var glyph in Crests)
            {
                outputFile.WriteLine(glyph.passiveid + "\t" + glyph.skillname + "\t" + glyph.skillId + "\t" + glyph.iconName.ToLowerInvariant() + "\t" + glyph.name + "\t" + glyph.glyphIcon.ToLowerInvariant() + "\t" + glyph.tooltip);
                Program.Copytexture(glyph.glyphIcon);
                Program.Copytexture(glyph.iconName);
            }
            outputFile.Flush();
            outputFile.Close();
        }
Exemplo n.º 29
0
        private static bool TargetType(string command, Argument[] args, bool quiet, bool force)
        {
            if (Targeting.FromGrabHotKey)
            {
                return(false);
            }

            if (args.Length < 1)
            {
                throw new RunTimeError(null, "Usage: targettype (graphic) OR ('name of item or mobile type') [inrangecheck/backpack]");
            }

            string gfxStr = args[0].AsString();
            Serial gfx    = Utility.ToUInt16(gfxStr, 0);

            bool inRangeCheck = Config.GetBool("ScriptTargetTypeRange");
            bool backpack     = false;

            if (args.Length == 2)
            {
                if (args[1].AsString().IndexOf("pack", StringComparison.InvariantCultureIgnoreCase) > 0)
                {
                    backpack = true;
                }
                else
                {
                    inRangeCheck = args[1].AsBool();
                }
            }

            ArrayList list = new ArrayList();

            // No graphic id, maybe searching by name?
            if (gfx == 0)
            {
                if (backpack) // search backpack only
                {
                    if (World.Player.Backpack != null)
                    {
                        Item i = World.Player.Backpack.FindItemByName(gfxStr, true);

                        if (i != null)
                        {
                            list.Add(i);
                        }
                    }
                }
                else if (inRangeCheck) // inrange includes both backpack and within 2 tiles
                {
                    list.AddRange(World.FindItemsByName(gfxStr).Where(item =>
                                                                      !item.IsInBank && (Utility.InRange(World.Player.Position, item.Position, 2) ||
                                                                                         (item.RootContainer != null && item.RootContainer is UOEntity && Utility.InRange(World.Player.Position, (item.RootContainer as UOEntity).Position, 2)) ||
                                                                                         item.RootContainer == World.Player)).ToList());
                }
                else
                {
                    list.AddRange(World.FindItemsByName(gfxStr).Where(item => !item.IsInBank).ToList());
                }

                if (list.Count == 0) // no item found, search mobile by name
                {
                    List <Mobile> mobiles = World.FindMobilesByName(gfxStr);

                    if (mobiles.Count > 0)
                    {
                        list.AddRange(inRangeCheck
                            ? mobiles.Where(m => Utility.InRange(World.Player.Position, m.Position, 2)).ToList()
                            : mobiles);
                    }
                    else
                    {
                        throw new RunTimeError(null, $"Script Error: Couldn't find '{gfxStr}'");
                    }
                }
            }
            else // Using graphic id, so find mobile or item
            {
                // Look for a mobile first
                foreach (Mobile find in World.MobilesInRange())
                {
                    if (find.Body == gfx)
                    {
                        if (Config.GetBool("ScriptTargetTypeRange"))
                        {
                            if (Utility.InRange(World.Player.Position, find.Position, 2))
                            {
                                list.Add(find);
                            }
                        }
                        else
                        {
                            list.Add(find);
                        }
                    }
                }

                if (list.Count == 0) // No mobile found, search for items
                {
                    if (backpack)    // search backpack only
                    {
                        if (World.Player.Backpack != null)
                        {
                            Item i = World.Player.Backpack.FindItemByID(Utility.ToUInt16(gfxStr, 0));

                            if (i != null)
                            {
                                list.Add(i);
                            }
                        }
                    }
                    else if (inRangeCheck) // inrange includes both backpack and within 2 tiles
                    {
                        list.AddRange(World.Items.Values.Where(i =>
                                                               i.ItemID == gfx && !i.IsInBank &&
                                                               (Utility.InRange(World.Player.Position, i.Position, 2) ||
                                                                (i.RootContainer != null && i.RootContainer is UOEntity && Utility.InRange(World.Player.Position, (i.RootContainer as UOEntity).Position, 2)) ||
                                                                i.RootContainer == World.Player))
                                      .ToList());
                    }
                    else
                    {
                        list.AddRange(World.Items.Values.Where(i => i.ItemID == gfx && !i.IsInBank)
                                      .ToList());
                    }
                }
            }

            if (list.Count > 0)
            {
                Targeting.Target(list[Utility.Random(list.Count)]);
            }
            else
            {
                World.Player.SendMessage(MsgLevel.Warning, LocString.NoItemOfType,
                                         gfx.IsMobile ? $"Character [{gfx}]" : ((ItemID)gfx.Value).ToString());
            }

            return(true);
        }
Exemplo n.º 30
0
        public override void OnButtonPress(int num)
        {
            switch (num)
            {
            case 1:
                World.Player.SendMessage(MsgLevel.Force, LocString.TargItemAdd);
                Targeting.OneTimeTarget(new Targeting.TargetResponseCallback(OnTarget));
                break;

            case 2:
                if (m_SubList == null)
                {
                    break;
                }

                if (m_SubList.SelectedIndex >= 0)
                {
                    BuyEntry e      = (BuyEntry)m_Items[m_SubList.SelectedIndex];
                    ushort   amount = e.Amount;
                    if (InputBox.Show(Engine.MainWindow, Language.GetString(LocString.EnterAmount),
                                      Language.GetString(LocString.InputReq), amount.ToString()))
                    {
                        e.Amount = (ushort)InputBox.GetInt(1);
                        m_SubList.BeginUpdate();
                        m_SubList.Items.Clear();
                        for (int i = 0; i < m_Items.Count; i++)
                        {
                            m_SubList.Items.Add(m_Items[i]);
                        }

                        m_SubList.EndUpdate();
                    }
                }

                break;

            case 3:

                if (MessageBox.Show(Language.GetString(LocString.Confirm), Language.GetString(LocString.ClearList),
                                    MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    if (m_SubList.SelectedIndex >= 0)
                    {
                        m_Items.RemoveAt(m_SubList.SelectedIndex);
                        m_SubList.Items.RemoveAt(m_SubList.SelectedIndex);
                        m_SubList.SelectedIndex = -1;
                    }
                }

                break;

            case 4:

                if (MessageBox.Show(Language.GetString(LocString.Confirm), Language.GetString(LocString.ClearList),
                                    MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    m_SubList.Items.Clear();
                    m_Items.Clear();
                }

                break;

            case 5:
                m_Enabled        = !m_Enabled;
                m_EnableBTN.Text = Language.GetString(m_Enabled ? LocString.PushDisable : LocString.PushEnable);
                break;
            }
        }
Exemplo n.º 31
0
    private GameObject GetTarget(GameObject[] allEnemies, Targeting _targeting)
    {
        GameObject enemyReturn  = null;
        GameObject optimalEnemy = null;

        if (_targeting == Targeting.closest)
        {
            float optimalDistance = Mathf.Infinity;

            foreach (GameObject enemy in allEnemies)
            {
                float distanceToEnemy = Vector3.Distance(transform.position, enemy.transform.position);

                if (distanceToEnemy < optimalDistance)
                {
                    optimalEnemy    = enemy;
                    optimalDistance = distanceToEnemy;
                }
            }

            if (optimalEnemy != null && optimalDistance <= range)
            {
                enemyReturn = optimalEnemy;
            }
            else
            {
                enemyReturn = null;
            }
        }
        else if (_targeting == Targeting.farthest)
        {
            float optimalDistance = -Mathf.Infinity;

            foreach (GameObject enemy in allEnemies)
            {
                float distanceToEnemy = Vector3.Distance(transform.position, enemy.transform.position);

                if (distanceToEnemy > optimalDistance && distanceToEnemy < range)
                {
                    optimalEnemy    = enemy;
                    optimalDistance = distanceToEnemy;
                }
            }

            if (optimalEnemy != null)
            {
                enemyReturn = optimalEnemy;
            }
            else
            {
                enemyReturn = null;
            }
        }
        else if (_targeting == Targeting.strongest)
        {
            float optimalEnemyHealth = -Mathf.Infinity;

            foreach (GameObject enemy in allEnemies)
            {
                float enemyHealth = enemy.GetComponent <Enemy>().GetCurrentHealth();
                float enemyDist   = Vector3.Distance(transform.position, enemy.transform.position);

                if (enemyHealth > optimalEnemyHealth && enemyDist < range)
                {
                    optimalEnemy       = enemy;
                    optimalEnemyHealth = enemyHealth;
                }
            }

            if (optimalEnemy != null)
            {
                enemyReturn = optimalEnemy;
            }
            else
            {
                enemyReturn = null;
            }
        }
        else if (_targeting == Targeting.weakest)
        {
            float optimalEnemyHealth = Mathf.Infinity;

            foreach (GameObject enemy in allEnemies)
            {
                float enemyHealth = enemy.GetComponent <Enemy>().GetCurrentHealth();
                float enemyDist   = Vector3.Distance(transform.position, enemy.transform.position);

                if (enemyHealth < optimalEnemyHealth && enemyDist < range)
                {
                    optimalEnemy       = enemy;
                    optimalEnemyHealth = enemyHealth;
                }
            }

            if (optimalEnemy != null)
            {
                enemyReturn = optimalEnemy;
            }
            else
            {
                enemyReturn = null;
            }
        }
        else if (_targeting == Targeting.first)
        {
            float optimalDist = Mathf.Infinity;

            foreach (GameObject enemy in allEnemies)
            {
                float remainingDist = Vector3.Distance(enemy.transform.position, GameObject.FindGameObjectWithTag("Destination").transform.position);
                float enemyDist     = Vector3.Distance(transform.position, enemy.transform.position);

                if (remainingDist < optimalDist && enemyDist < range)
                {
                    optimalEnemy = enemy;
                    optimalDist  = remainingDist;
                }
            }

            if (optimalEnemy != null)
            {
                enemyReturn = optimalEnemy;
            }
            else
            {
                enemyReturn = null;
            }
        }
        else if (_targeting == Targeting.last)
        {
            float optimalDist = -Mathf.Infinity;

            foreach (GameObject enemy in allEnemies)
            {
                float remainingDist = Vector3.Distance(enemy.transform.position, GameObject.FindGameObjectWithTag("Destination").transform.position);
                float enemyDist     = Vector3.Distance(transform.position, enemy.transform.position);

                if (remainingDist > optimalDist && enemyDist < range)
                {
                    optimalEnemy = enemy;
                    optimalDist  = remainingDist;
                }
            }

            if (optimalEnemy != null)
            {
                enemyReturn = optimalEnemy;
            }
            else
            {
                enemyReturn = null;
            }
        }

        return(enemyReturn);
    }
Exemplo n.º 32
0
 // Use this for initialization
 void Start()
 {
     attackTimer = 0;
     coolDown = 0.0f;
     targeting = (Targeting)GetComponent("Targeting");
 }
Exemplo n.º 33
0
        /// <summary>
        /// Run the code examples.
        /// </summary>
        public void Run(DfpUser user)
        {
            // Get the ProposalLineItemService.
            ProposalLineItemService proposalLineItemService =
                (ProposalLineItemService)user.GetService(DfpService.v201702.ProposalLineItemService);

            // Get the NetworkService.
            NetworkService networkService =
                (NetworkService)user.GetService(DfpService.v201702.NetworkService);

            long proposalId = long.Parse(_T("INSERT_PROPOSAL_ID_HERE"));
            long rateCardId = long.Parse(_T("INSERT_RATE_CARD_ID_HERE"));
            long productId  = long.Parse(_T("INSERT_PRODUCT_ID_HERE"));

            // Get the root ad unit ID used to target the whole site.
            String rootAdUnitId = networkService.getCurrentNetwork().effectiveRootAdUnitId;

            // Create inventory targeting.
            InventoryTargeting inventoryTargeting = new InventoryTargeting();

            // Create ad unit targeting for the root ad unit (i.e. the whole network).
            AdUnitTargeting adUnitTargeting = new AdUnitTargeting();

            adUnitTargeting.adUnitId           = rootAdUnitId;
            adUnitTargeting.includeDescendants = true;

            inventoryTargeting.targetedAdUnits = new AdUnitTargeting[] { adUnitTargeting };

            // Create targeting.
            Targeting targeting = new Targeting();

            targeting.inventoryTargeting = inventoryTargeting;

            // Create a proposal line item.
            ProposalLineItem proposalLineItem = new ProposalLineItem();

            proposalLineItem.name = "Proposal line item #" + new Random().Next(int.MaxValue);

            proposalLineItem.proposalId = proposalId;
            proposalLineItem.rateCardId = rateCardId;
            proposalLineItem.productId  = productId;
            proposalLineItem.targeting  = targeting;

            // Set the length of the proposal line item to run.
            proposalLineItem.startDateTime =
                DateTimeUtilities.FromDateTime(System.DateTime.Now.AddDays(7), "America/New_York");
            proposalLineItem.endDateTime =
                DateTimeUtilities.FromDateTime(System.DateTime.Now.AddDays(30), "America/New_York");

            // Set delivery specifications for the proposal line item.
            proposalLineItem.deliveryRateType     = DeliveryRateType.EVENLY;
            proposalLineItem.creativeRotationType = CreativeRotationType.OPTIMIZED;

            // Set billing specifications for the proposal line item.
            proposalLineItem.billingCap    = BillingCap.CAPPED_CUMULATIVE;
            proposalLineItem.billingSource = BillingSource.THIRD_PARTY_VOLUME;

            // Set pricing for the proposal line item for 1000 impressions at a CPM of $2
            // for a total value of $2.
            proposalLineItem.goal = new Goal()
            {
                unitType = UnitType.IMPRESSIONS, units = 1000L
            };
            proposalLineItem.netCost = new Money()
            {
                currencyCode = "USD", microAmount = 2000000L
            };
            proposalLineItem.netRate = new Money()
            {
                currencyCode = "USD", microAmount = 2000000L
            };
            proposalLineItem.rateType = RateType.CPM;

            try {
                // Create the proposal line item on the server.
                ProposalLineItem[] proposalLineItems = proposalLineItemService.createProposalLineItems(
                    new ProposalLineItem[] { proposalLineItem });

                foreach (ProposalLineItem createdProposalLineItem in proposalLineItems)
                {
                    Console.WriteLine("A proposal line item with ID \"{0}\" and name \"{1}\" was created.",
                                      createdProposalLineItem.id, createdProposalLineItem.name);
                }
            } catch (Exception e) {
                Console.WriteLine("Failed to create proposal line items. Exception says \"{0}\"",
                                  e.Message);
            }
        }
Exemplo n.º 34
0
	void Awake () 
    {
        TG = this;
	}
Exemplo n.º 35
0
    public static Targeting SelfTargetArea()
    {
        var targeting = new Targeting();
        targeting.TargetGroup = Const.SkillTargetGroup.Self;
        targeting.TargetType = Const.SkillTargetType.Unit;

        targeting.Pattern = Pattern.Single();
        return targeting;
    }
    /// <summary>
    /// Run the code examples.
    /// </summary>
    /// <param name="user">The DFP user object running the code examples.</param>
    public override void Run(DfpUser user) {
      // Get the ProductTemplateService.
      ProductTemplateService productTemplateService =
          (ProductTemplateService) user.GetService(DfpService.v201508.ProductTemplateService);

      // Get the NetworkService.
      NetworkService networkService =
          (NetworkService) user.GetService(DfpService.v201508.NetworkService);

      // Create a product template.
      ProductTemplate productTemplate = new ProductTemplate();
      productTemplate.name = "Product template #" + new Random().Next(int.MaxValue);
      productTemplate.description = "This product template creates standard proposal line items "
          + "targeting Chrome browsers with product segmentation on ad units and geo targeting.";

      // Set the name macro which will be used to generate the names of the products.
      // This will create a segmentation based on the line item type, ad unit, and location.
      productTemplate.nameMacro = "<line-item-type> - <ad-unit> - <template-name> - <location>";

      // Set the product type so the created proposal line items will be trafficked in DFP.
      productTemplate.productType = ProductType.DFP;

      // Set rate type to create CPM priced proposal line items.
      productTemplate.rateType = RateType.CPM;

      // Optionally set the creative rotation of the product to serve one or more creatives.
      productTemplate.roadblockingType = RoadblockingType.ONE_OR_MORE;

      // Create the master creative placeholder.
      CreativePlaceholder creativeMasterPlaceholder = new CreativePlaceholder();
      creativeMasterPlaceholder.size =
          new Size() {width = 728, height = 90, isAspectRatio = false};

      // Create companion creative placeholders.
      CreativePlaceholder companionCreativePlaceholder = new CreativePlaceholder();
      companionCreativePlaceholder.size =
          new Size() {width = 300, height = 250, isAspectRatio = false};

      // Set the size of creatives that can be associated with the product template.
      productTemplate.creativePlaceholders =
          new CreativePlaceholder[] {creativeMasterPlaceholder, companionCreativePlaceholder};

      // Set the type of proposal line item to be created from the product template.
      productTemplate.lineItemType = LineItemType.STANDARD;

      // Get the root ad unit ID used to target the whole site.
      String rootAdUnitId = networkService.getCurrentNetwork().effectiveRootAdUnitId;

      // Create ad unit targeting for the root ad unit (i.e. the whole network).
      AdUnitTargeting adUnitTargeting = new AdUnitTargeting();
      adUnitTargeting.adUnitId = rootAdUnitId;
      adUnitTargeting.includeDescendants = true;

      // Create geo targeting for the US.
      Location countryLocation = new Location();
      countryLocation.id = 2840L;

      // Create geo targeting for Hong Kong.
      Location regionLocation = new Location();
      regionLocation.id = 2344L;

      GeoTargeting geoTargeting = new GeoTargeting();
      geoTargeting.targetedLocations = new Location[] {countryLocation, regionLocation};

      // Add browser targeting to Chrome on the product template distinct from product
      // segmentation.
      Browser chromeBrowser = new Browser();
      chromeBrowser.id = 500072L;

      BrowserTargeting browserTargeting = new BrowserTargeting();
      browserTargeting.browsers = new Browser[] {chromeBrowser};

      TechnologyTargeting technologyTargeting = new TechnologyTargeting();
      technologyTargeting.browserTargeting = browserTargeting;

      Targeting productTemplateTargeting = new Targeting();
      productTemplateTargeting.technologyTargeting = technologyTargeting;

      productTemplate.builtInTargeting = productTemplateTargeting;

      // Add inventory and geo targeting as product segmentation.
      ProductSegmentation productSegmentation = new ProductSegmentation();
      productSegmentation.adUnitSegments = new AdUnitTargeting[] {adUnitTargeting};
      productSegmentation.geoSegment = geoTargeting;

      productTemplate.productSegmentation = productSegmentation;

      try {
        // Create the product template on the server.
        ProductTemplate[] productTemplates = productTemplateService.createProductTemplates(
            new ProductTemplate[] {productTemplate});

        foreach (ProductTemplate createdProductTemplate in productTemplates) {
          Console.WriteLine("A product template with ID \"{0}\" and name \"{1}\" was created.",
              createdProductTemplate.id, createdProductTemplate.name);
        }

      } catch (Exception e) {
        Console.WriteLine("Failed to create product templates. Exception says \"{0}\"",
            e.Message);
      }
    }
Exemplo n.º 37
0
        private static bool TargetType(string command, Variable[] vars, bool quiet, bool force)
        {
            if (Targeting.FromGrabHotKey)
            {
                return(false);
            }

            if (vars.Length < 1)
            {
                throw new RunTimeError("Usage: targettype (graphic) OR ('name of item or mobile type') [inrangecheck/backpack]");
            }

            string        gfxStr = vars[0].AsString();
            Serial        gfx    = Utility.ToUInt16(gfxStr, 0);
            List <Item>   items;
            List <Mobile> mobiles = new List <Mobile>();

            bool inRangeCheck = false;
            bool backpack     = false;

            if (vars.Length == 2)
            {
                if (vars[1].AsString().IndexOf("pack", StringComparison.InvariantCultureIgnoreCase) != -1)
                {
                    backpack = true;
                }
                else
                {
                    inRangeCheck = vars[1].AsBool();
                }
            }

            // No graphic id, maybe searching by name?
            if (gfx == 0)
            {
                items = CommandHelper.GetItemsByName(gfxStr, backpack, inRangeCheck);

                if (items.Count == 0) // no item found, search mobile by name
                {
                    mobiles = CommandHelper.GetMobilesByName(gfxStr, inRangeCheck);
                }
            }
            else // Provided graphic id for type, check backpack first (same behavior as DoubleClickAction in macros
            {
                ushort id = Utility.ToUInt16(gfxStr, 0);

                items = CommandHelper.GetItemsById(id, backpack, inRangeCheck);

                // Still no item? Mobile check!
                if (items.Count == 0)
                {
                    mobiles = CommandHelper.GetMobilesById(id, inRangeCheck);
                }
            }

            if (items.Count > 0)
            {
                Targeting.Target(items[Utility.Random(items.Count)]);
            }
            else if (mobiles.Count > 0)
            {
                Targeting.Target(mobiles[Utility.Random(mobiles.Count)]);
            }
            else
            {
                CommandHelper.SendWarning(command, $"Item or mobile type '{gfxStr}' not found", quiet);
            }

            return(true);
        }
Exemplo n.º 38
0
 public void keepDistance(Vector3 _destination, float rotationOffset, float _distance)
 {
     destination    = Targeting.LerpByDistance(_destination, transform.position, _distance);
     faceTargetOnly = false;
     initalizeMove(rotationOffset);
 }
Exemplo n.º 39
0
 public static Targeting MeleeTargetArea()
 {
     var targeting = new Targeting();
     targeting.TargetGroup = Const.SkillTargetGroup.Opponent;
     targeting.TargetType = Const.SkillTargetType.Tile;
     
     targeting.Pattern = Pattern.TwoColumns();
     return targeting;
 }
Exemplo n.º 40
0
        private static bool Target(string command, Variable[] vars, bool quiet, bool force)
        {
            if (vars.Length < 1)
            {
                throw new RunTimeError("Usage: target (serial) OR target (closest/random/next/prev [noto] [type]");
            }

            switch (vars[0].AsString())
            {
            case "close":
            case "closest":
                CommandHelper.FindTarget(vars, true);

                break;

            case "rand":
            case "random":
                CommandHelper.FindTarget(vars, false, true);

                break;

            case "next":
                CommandHelper.FindTarget(vars, false, false, true);

                break;

            case "prev":
            case "previous":
                CommandHelper.FindTarget(vars, false, false, false, true);

                break;

            case "cancel":
                Targeting.CancelTarget();

                break;

            case "clear":
                Targeting.OnClearQueue();

                break;

            default:
                Serial serial = vars[0].AsSerial();

                if (serial != Serial.Zero)     // Target a specific item or mobile
                {
                    Item item = World.FindItem(serial);

                    if (item != null)
                    {
                        Targeting.Target(item);
                        return(true);
                    }

                    Mobile mobile = World.FindMobile(serial);

                    if (mobile != null)
                    {
                        Targeting.Target(mobile);
                    }
                }

                break;
            }

            return(true);
        }
    /// <summary>
    /// Run the code examples.
    /// </summary>
    /// <param name="user">The DFP user object running the code examples.</param>
    public override void Run(DfpUser user) {
      // [START get_proposal_line_item_service] MOE:strip_line
      // Get the ProposalLineItemService.
      ProposalLineItemService proposalLineItemService =
          (ProposalLineItemService) user.GetService(DfpService.v201508.ProposalLineItemService);
      // [END get_proposal_line_item_service] MOE:strip_line

      // Get the NetworkService.
      NetworkService networkService =
          (NetworkService) user.GetService(DfpService.v201508.NetworkService);

      long proposalId = long.Parse(_T("INSERT_PROPOSAL_ID_HERE"));
      long rateCardId = long.Parse(_T("INSERT_RATE_CARD_ID_HERE"));
      long productId = long.Parse(_T("INSERT_PRODUCT_ID_HERE"));

      // [START add_targeting] MOE:strip_line
      // Get the root ad unit ID used to target the whole site.
      String rootAdUnitId = networkService.getCurrentNetwork().effectiveRootAdUnitId;

      // Create inventory targeting.
      InventoryTargeting inventoryTargeting = new InventoryTargeting();

      // Create ad unit targeting for the root ad unit (i.e. the whole network).
      AdUnitTargeting adUnitTargeting = new AdUnitTargeting();
      adUnitTargeting.adUnitId = rootAdUnitId;
      adUnitTargeting.includeDescendants = true;

      inventoryTargeting.targetedAdUnits = new AdUnitTargeting[] {adUnitTargeting};

      // Create targeting.
      Targeting targeting = new Targeting();
      targeting.inventoryTargeting = inventoryTargeting;
      // [END add_targeting] MOE:strip_line

      // [START create_proposal_line_item_local] MOE:strip_line
      // Create a proposal line item.
      ProposalLineItem proposalLineItem = new ProposalLineItem();
      proposalLineItem.name = "Proposal line item #" + new Random().Next(int.MaxValue);
      // [END create_proposal_line_item_local] MOE:strip_line

      // [START set_required_creation_fields] MOE:strip_line
      proposalLineItem.proposalId = proposalId;
      proposalLineItem.rateCardId = rateCardId;
      proposalLineItem.productId = productId;
      proposalLineItem.targeting = targeting;
      // [END set_required_creation_fields] MOE:strip_line

      // [START set_dates] MOE:strip_line
      // Set the length of the proposal line item to run.
      proposalLineItem.startDateTime =
          DateTimeUtilities.FromDateTime(System.DateTime.Now.AddDays(7), "America/New_York");
      proposalLineItem.endDateTime =
          DateTimeUtilities.FromDateTime(System.DateTime.Now.AddDays(30), "America/New_York");
      // [END set_dates] MOE:strip_line

      // [START set_delivery_info] MOE:strip_line
      // Set delivery specifications for the proposal line item.
      proposalLineItem.deliveryRateType = DeliveryRateType.EVENLY;
      proposalLineItem.creativeRotationType = CreativeRotationType.OPTIMIZED;
      // [END set_delivery_info] MOE:strip_line

      // [START set_billing] MOE:strip_line
      // Set billing specifications for the proposal line item.
      proposalLineItem.billingCap = BillingCap.CAPPED_CUMULATIVE;
      proposalLineItem.billingSource = BillingSource.THIRD_PARTY_VOLUME;
      // [END set_billing] MOE:strip_line

      // [START set_goal] MOE:strip_line
      // Set pricing for the proposal line item for 1000 impressions at a CPM of $2
      // for a total value of $2.
      proposalLineItem.goal = new Goal() {unitType = UnitType.IMPRESSIONS, units = 1000L};
      // [END set_goal] MOE:strip_line
      // [START set_costs] MOE:strip_line
      proposalLineItem.cost = new Money() {currencyCode = "USD", microAmount = 2000000L};
      proposalLineItem.costPerUnit = new Money() {currencyCode = "USD", microAmount = 2000000L};
      proposalLineItem.rateType = RateType.CPM;
      // [END set_costs] MOE:strip_line

      try {
        // [START create_proposal_line_item_server] MOE:strip_line
        // Create the proposal line item on the server.
        ProposalLineItem[] proposalLineItems = proposalLineItemService.createProposalLineItems(
            new ProposalLineItem[] {proposalLineItem});
        // [END create_proposal_line_item_server] MOE:strip_line

        foreach (ProposalLineItem createdProposalLineItem in proposalLineItems) {
          Console.WriteLine("A proposal line item with ID \"{0}\" and name \"{1}\" was created.",
              createdProposalLineItem.id, createdProposalLineItem.name);
        }

      } catch (Exception e) {
        Console.WriteLine("Failed to create proposal line items. Exception says \"{0}\"",
            e.Message);
      }
    }
Exemplo n.º 42
0
        //---------------------------------------------------------------------------------------------

        public static HealInfo BandSafe(Serial serial, bool isAutoHeal)
        {
            HealInfo hInfo = new HealInfo();

            hInfo.HasBandages = Healing.CleanBandage.Exist;

            if (hInfo.HasBandages)
            {
                if (isAutoHeal && Game.CheckRunning())
                {
                    return(hInfo);
                }

                UOCharacter ch = new UOCharacter(serial);

                ch.PrintHitsMessage("[Banding...]");
                int ohits = new UOCharacter(serial).Hits;

                Game.RunScriptCheck(250);
                Journal.Clear();
                Targeting.ResetTarget();
                Healing.CleanBandage.Use();
                UO.WaitTargetObject(serial);

                DateTime start = DateTime.Now;
                //Vylecil jsi otravu!
                hInfo.Used = Journal.WaitForText(true, 3500, "You must be able to reach the target", "Chces vytvorit mumii?", "You put the bloody bandagess in your pack.", "You apply the bandages, but they barely help.", "Your target is already fully healed", "Vylecil jsi otravu!");
                int time = Convert.ToInt32((DateTime.Now - start).TotalMilliseconds);
                int wait = 2550 - time;

                if (Journal.Contains(true, "Nemuzes pouzit bandy na summona!"))
                {
                    hInfo.TryHealSummon = true;
                }
                if (Journal.Contains(true, "You must be able to reach the target"))
                {
                    hInfo.CantReach = true;
                }
                if (Journal.Contains(true, "Chces vytvorit mumii?") || Journal.Contains(true, "Your target is already fully healed"))
                {
                    hInfo.FullHealed = true;
                }
                if (Journal.Contains(true, "Vylecil jsi otravu!"))
                {
                    hInfo.CuredPoison = true;
                }

                hInfo.Success = Journal.Contains(true, "You put the bloody bandagess in your pack");
                hInfo.Failed  = Journal.Contains(true, "You apply the bandages, but they barely help");

                if (hInfo.CuredPoison)
                {
                    wait = 250;
                }

                wait += 1;

                if (wait > 0)
                {
                    Game.Wait(wait);
                }

                if (hInfo.CantReach)
                {
                    ch.PrintMessage("[Can't reach Band]" + (serial == World.Player.Serial ? " Self" : ""), Game.Val_LightGreen);
                }

                int hits = new UOCharacter(serial).Hits;
                int incr = hits - ohits;

                if (hInfo.Success && incr > 0)
                {
                    hInfo.Gain = incr;
                }
            }

            return(hInfo);
        }
Exemplo n.º 43
0
        public static void GetTargetForNonPlayer(ISystemContainer systemContainer, IEntity sender, Targeting data, Action <MapCoordinate> callback)
        {
            var     position       = systemContainer.PositionSystem.CoordinateOf(sender);
            var     player         = systemContainer.PlayerSystem.Player;
            var     origin         = systemContainer.PositionSystem.CoordinateOf(sender);
            IEntity intendedTarget = null;

            if (data.Friendly)
            {
                intendedTarget = PickRandomFriendlyTarget(systemContainer, data, position, origin, player);
            }
            else
            {
                intendedTarget = systemContainer.PlayerSystem.Player;
            }

            if (data.Range > 0)
            {
                bool canSeeTarget = CanSeeTarget(systemContainer, data, position, origin, intendedTarget);

                if (!canSeeTarget)
                {
                    return;
                }
            }

            if (intendedTarget == null)
            {
                return;
            }

            MapCoordinate targetCoordinate = systemContainer.PositionSystem.CoordinateOf(intendedTarget);

            var targetableCells = systemContainer.TargetingSystem.TargetableCellsFrom(data, position);

            if (targetableCells.Contains(targetCoordinate))
            {
                callback(targetCoordinate);
            }
        }
Exemplo n.º 44
0
        private static IEntity PickRandomFriendlyTarget(ISystemContainer systemContainer, Targeting data, MapCoordinate position, MapCoordinate origin, IEntity player)
        {
            IEntity intendedTarget;
            var     currentMap = systemContainer.MapSystem.MapCollection[position.Key];
            var     fov        = currentMap.FovFrom(systemContainer.PositionSystem, origin, data.Range);

            var friendlies = fov
                             .SelectMany(c => systemContainer.PositionSystem.EntitiesAt(c))
                             .Where(e => e.Has <Health>())
                             .Except(new[] { player })
                             .ToList();

            intendedTarget = systemContainer.Random.PickOne(friendlies);
            return(intendedTarget);
        }
Exemplo n.º 45
0
 public static void Target(int client, Targeting targeting)
 {
     switch (targeting)
     {
         case Targeting.Select_Next_Hostile:
             Event(client, 50, 1);
             break;
         case Targeting.Select_Next_Party_Member:
             Event(client, 50, 2);
             break;
         case Targeting.Select_Next_Follower:
             Event(client, 50, 3);
             break;
         case Targeting.Select_Next_Object:
             Event(client, 50, 4);
             break;
         case Targeting.Select_Next_Mobile:
             Event(client, 50, 5);
             break;
         case Targeting.Select_Previous_Hostile:
             Event(client, 51, 1);
             break;
         case Targeting.Select_Previous_Party_Member:
             Event(client, 51, 2);
             break;
         case Targeting.Select_Previous_Follower:
             Event(client, 51, 3);
             break;
         case Targeting.Select_Previous_Object:
             Event(client, 51, 4);
             break;
         case Targeting.Select_Previous_Mobile:
             Event(client, 51, 5);
             break;
         case Targeting.Select_Nearest_Hostile:
             Event(client, 52, 1);
             break;
         case Targeting.Select_Nearest_Party_Member:
             Event(client, 52, 2);
             break;
         case Targeting.Select_Nearest_Follower:
             Event(client, 52, 3);
             break;
         case Targeting.Select_Nearest_Object:
             Event(client, 52, 4);
             break;
         case Targeting.Select_Nearest_Mobile:
             Event(client, 52, 5);
             break;
         case Targeting.Attack_Selected:
             Event(client, 53, 0);
             break;
         case Targeting.Use_Selected:
             Event(client, 54, 0);
             break;
         case Targeting.Current_Target:
             Event(client, 55, 0);
             break;
         case Targeting.Toggle_Targeting_System:
             Event(client, 56, 0);
             break;
         case Targeting.Toggle_Buff_Window:
             Event(client, 57, 0);
             break;
         case Targeting.Bandage_Self:
             Event(client, 58, 0);
             break;
         case Targeting.Bandage_Target:
             Event(client, 59, 0);
             break;
     }
 }
        /// <summary>
        /// Run the code examples.
        /// </summary>
        public void Run(DfpUser user, long proposalId)
        {
            // Get the ProposalLineItemService.
            ProposalLineItemService proposalLineItemService =
                (ProposalLineItemService)user.GetService(DfpService.v201702.ProposalLineItemService);

            // Get the NetworkService.
            NetworkService networkService =
                (NetworkService)user.GetService(DfpService.v201702.NetworkService);

            ProposalLineItem proposalLineItem = new ProposalLineItem();

            proposalLineItem.name = "Programmatic proposal line item #"
                                    + new Random().Next(int.MaxValue);
            proposalLineItem.proposalId   = proposalId;
            proposalLineItem.lineItemType = LineItemType.STANDARD;

            // Set required Marketplace information.
            proposalLineItem.marketplaceInfo = new ProposalLineItemMarketplaceInfo()
            {
                adExchangeEnvironment = AdExchangeEnvironment.DISPLAY
            };

            // Get the root ad unit ID used to target the whole site.
            String rootAdUnitId = networkService.getCurrentNetwork().effectiveRootAdUnitId;

            // Create inventory targeting.
            InventoryTargeting inventoryTargeting = new InventoryTargeting();

            // Create ad unit targeting for the root ad unit (i.e. the whole network).
            AdUnitTargeting adUnitTargeting = new AdUnitTargeting();

            adUnitTargeting.adUnitId           = rootAdUnitId;
            adUnitTargeting.includeDescendants = true;

            inventoryTargeting.targetedAdUnits = new AdUnitTargeting[] { adUnitTargeting };

            // Create targeting.
            Targeting targeting = new Targeting();

            targeting.inventoryTargeting = inventoryTargeting;
            proposalLineItem.targeting   = targeting;

            // Create creative placeholder.
            Size size = new Size()
            {
                width         = 300,
                height        = 250,
                isAspectRatio = false
            };
            CreativePlaceholder creativePlaceholder = new CreativePlaceholder();

            creativePlaceholder.size = size;

            proposalLineItem.creativePlaceholders = new CreativePlaceholder[] { creativePlaceholder };

            // Set the length of the proposal line item to run.
            proposalLineItem.startDateTime =
                DateTimeUtilities.FromDateTime(System.DateTime.Now.AddDays(7), "America/New_York");
            proposalLineItem.endDateTime =
                DateTimeUtilities.FromDateTime(System.DateTime.Now.AddDays(30), "America/New_York");

            // Set delivery specifications for the proposal line item.
            proposalLineItem.deliveryRateType = DeliveryRateType.EVENLY;

            // Set pricing for the proposal line item for 1000 impressions at a CPM of $2
            // for a total value of $2.
            proposalLineItem.goal = new Goal()
            {
                unitType = UnitType.IMPRESSIONS, units = 1000L
            };
            proposalLineItem.netCost = new Money()
            {
                currencyCode = "USD", microAmount = 2000000L
            };
            proposalLineItem.netRate = new Money()
            {
                currencyCode = "USD", microAmount = 2000000L
            };
            proposalLineItem.rateType = RateType.CPM;

            try {
                // Create the proposal line item on the server.
                ProposalLineItem[] proposalLineItems = proposalLineItemService.createProposalLineItems(
                    new ProposalLineItem[] { proposalLineItem });

                foreach (ProposalLineItem createdProposalLineItem in proposalLineItems)
                {
                    Console.WriteLine("A programmatic proposal line item with ID \"{0}\" "
                                      + "and name \"{1}\" was created.",
                                      createdProposalLineItem.id,
                                      createdProposalLineItem.name);
                }
            } catch (Exception e) {
                Console.WriteLine("Failed to create programmatic proposal line items. "
                                  + "Exception says \"{0}\"",
                                  e.Message);
            }
        }
Exemplo n.º 47
0
 // Use this for initialization
 void Start()
 {
     m_Targeting = GetComponent<Targeting>();
 }
Exemplo n.º 48
0
        /// <summary>
        /// Run the code examples.
        /// </summary>
        public void Run(DfpUser user)
        {
            // Get the ProductService.
            ProductService productTemplateService =
                (ProductService)user.GetService(DfpService.v201608.ProductService);

            // Get the NetworkService.
            NetworkService networkService =
                (NetworkService)user.GetService(DfpService.v201608.NetworkService);

            // Create a product.
            Product product = new Product();

            product.name = "Non-sales programmatic product #" + new Random().Next(int.MaxValue);

            // Set required Marketplace information.
            product.productMarketplaceInfo = new ProductMarketplaceInfo()
            {
                additionalTerms       = "Additional terms for the product",
                adExchangeEnvironment = AdExchangeEnvironment.DISPLAY
            };

            // Set common required fields for a programmatic product.
            product.productType     = ProductType.DFP;
            product.rateType        = RateType.CPM;
            product.lineItemType    = LineItemType.STANDARD;
            product.priority        = 8;
            product.environmentType = EnvironmentType.BROWSER;
            product.rate            = new Money()
            {
                currencyCode = "USD", microAmount = 6000000L
            };

            CreativePlaceholder placeholder = new CreativePlaceholder();

            placeholder.size = new Size()
            {
                width = 300, height = 250, isAspectRatio = false
            };
            product.creativePlaceholders = new CreativePlaceholder[] { placeholder };

            // Create inventory targeting to serve to run of network..
            String          rootAdUnitId    = networkService.getCurrentNetwork().effectiveRootAdUnitId;
            AdUnitTargeting adUnitTargeting = new AdUnitTargeting();

            adUnitTargeting.adUnitId           = rootAdUnitId;
            adUnitTargeting.includeDescendants = true;

            Targeting productTargeting = new Targeting();

            productTargeting.inventoryTargeting = new InventoryTargeting()
            {
                targetedAdUnits = new AdUnitTargeting[] { adUnitTargeting }
            };

            product.builtInTargeting = productTargeting;

            try {
                // Create the product on the server.
                Product[] products = productTemplateService.createProducts(
                    new Product[] { product });

                foreach (Product createdProduct in products)
                {
                    Console.WriteLine("A programmatic product with ID \"{0}\" and name \"{1}\" was created.",
                                      createdProduct.id, createdProduct.name);
                }
            } catch (Exception e) {
                Console.WriteLine("Failed to create products. Exception says \"{0}\"",
                                  e.Message);
            }
        }
Exemplo n.º 49
0
 private void Start()
 {
     PC = this;
     owner = Owner.Player;
     //Make persistent
     //set up references
     initializeShip();
     //initialize the bar readouts for the components
     tg = FindObjectOfType<Targeting>();
     StartCoroutine(initialize());
 }
        /// <summary>
        /// Run the code example.
        /// </summary>
        public void Run(AdManagerUser user)
        {
            using (LineItemService lineItemService = user.GetService <LineItemService>())
            {
                // Set the order that all created line items will belong to and the
                // video ad unit ID to target.
                long   orderId = long.Parse(_T("INSERT_ORDER_ID_HERE"));
                string targetedVideoAdUnitId = _T("INSERT_TARGETED_VIDEO_AD_UNIT_ID_HERE");

                // Set the content bundle to target
                long contentBundleId =
                    long.Parse(_T("INSERT_CONTENT_BUNDLE_ID_HERE"));

                // Create content targeting.
                ContentTargeting contentTargeting = new ContentTargeting()
                {
                    targetedVideoContentBundleIds = new long[] { contentBundleId }
                };

                // Create inventory targeting.
                InventoryTargeting inventoryTargeting = new InventoryTargeting()
                {
                    targetedAdUnits = new AdUnitTargeting[] {
                        new AdUnitTargeting()
                        {
                            adUnitId           = targetedVideoAdUnitId,
                            includeDescendants = true
                        }
                    }
                };

                // Create video position targeting.
                VideoPositionTargeting videoPositionTargeting = new VideoPositionTargeting()
                {
                    targetedPositions = new VideoPositionTarget[] {
                        new VideoPositionTarget()
                        {
                            videoPosition = new VideoPosition()
                            {
                                positionType = VideoPositionType.PREROLL
                            }
                        }
                    }
                };

                // Target only video platforms
                RequestPlatformTargeting requestPlatformTargeting = new RequestPlatformTargeting()
                {
                    targetedRequestPlatforms = new RequestPlatform[] {
                        RequestPlatform.VIDEO_PLAYER
                    }
                };

                // Create targeting.
                Targeting targeting = new Targeting()
                {
                    contentTargeting         = contentTargeting,
                    inventoryTargeting       = inventoryTargeting,
                    videoPositionTargeting   = videoPositionTargeting,
                    requestPlatformTargeting = requestPlatformTargeting
                };

                // Create local line item object.
                LineItem lineItem = new LineItem()
                {
                    name                 = "Video line item - " + this.GetTimeStamp(),
                    orderId              = orderId,
                    targeting            = targeting,
                    lineItemType         = LineItemType.SPONSORSHIP,
                    allowOverbook        = true,
                    environmentType      = EnvironmentType.VIDEO_PLAYER,
                    creativeRotationType = CreativeRotationType.OPTIMIZED
                };


                // Create the master creative placeholder.
                CreativePlaceholder creativeMasterPlaceholder = new CreativePlaceholder()
                {
                    size = new Size()
                    {
                        width         = 400,
                        height        = 300,
                        isAspectRatio = false
                    }
                };

                // Create companion creative placeholders.
                CreativePlaceholder companionCreativePlaceholder1 = new CreativePlaceholder()
                {
                    size = new Size()
                    {
                        width         = 300,
                        height        = 250,
                        isAspectRatio = false
                    }
                };

                CreativePlaceholder companionCreativePlaceholder2 = new CreativePlaceholder()
                {
                    size = new Size()
                    {
                        width         = 728,
                        height        = 90,
                        isAspectRatio = false
                    }
                };

                // Set companion creative placeholders.
                creativeMasterPlaceholder.companions = new CreativePlaceholder[]
                {
                    companionCreativePlaceholder1,
                    companionCreativePlaceholder2
                };

                // Set the size of creatives that can be associated with this line item.
                lineItem.creativePlaceholders = new CreativePlaceholder[]
                {
                    creativeMasterPlaceholder
                };

                // Set delivery of video companions to optional.
                lineItem.companionDeliveryOption = CompanionDeliveryOption.OPTIONAL;

                // Set the line item to run for one month.
                lineItem.startDateTimeType = StartDateTimeType.IMMEDIATELY;
                lineItem.endDateTime       =
                    DateTimeUtilities.FromDateTime(System.DateTime.Now.AddMonths(1),
                                                   "America/New_York");

                // Set the cost per day to $1.
                lineItem.costType    = CostType.CPD;
                lineItem.costPerUnit = new Money()
                {
                    currencyCode = "USD",
                    microAmount  = 1000000L
                };

                // Set the percentage to be 100%.
                lineItem.primaryGoal = new Goal()
                {
                    goalType = GoalType.DAILY,
                    unitType = UnitType.IMPRESSIONS,
                    units    = 100
                };

                try
                {
                    // Create the line item on the server.
                    LineItem[] createdLineItems = lineItemService.createLineItems(new LineItem[]
                    {
                        lineItem
                    });

                    foreach (LineItem createdLineItem in createdLineItems)
                    {
                        Console.WriteLine(
                            "A line item with ID \"{0}\", belonging to order ID \"{1}\", and " +
                            "named \"{2}\" was created.", createdLineItem.id,
                            createdLineItem.orderId, createdLineItem.name);
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("Failed to create line items. Exception says \"{0}\"",
                                      e.Message);
                }
            }
        }
Exemplo n.º 51
0
    // Use this for initialization
    void Start()
    {
        m_Targeting = GetComponent<Targeting>();

        musicSource = GetComponent<AudioSource> ();
    }
Exemplo n.º 52
0
    // Use this for initialization
    void Start()
    {
        m_Grappling = false;
        m_target = GetComponent<Targeting>();
        m_PlayerHealth = GetComponent<PlayerHealth> ();
        m_GrappleHook.renderer.enabled = true;

        //Calls the base class start function
        base.start ();
    }