public static void fireProjectile(WeaponProperties weaponProperties, TargetProperties targetProperties) { GameObject newGameObject = new GameObject(); Projectile.SetProjectile(weaponProperties, targetProperties, newGameObject); newGameObject.transform.parent = GameObject.Find("playerProjectileLayer").transform; }
/// <inheritdoc/> /// <param name="targetMolecule">targetMolecule graph</param> public bool HasMap(TargetProperties targetMolecule) { IState state = new VFState(query, targetMolecule); maps.Clear(); return(MapFirst(state)); }
public UnitTargetConditions(TargetProperties trueconditionalFlags, int MinimumRadiusDistance=-1, double MinimumHealthPercent=0d, TargetProperties falseConditionalFlags=TargetProperties.None) { TrueConditionFlags=trueconditionalFlags; FalseConditionFlags=falseConditionalFlags; Distance=MinimumRadiusDistance; HealthPercent=MinimumHealthPercent; }
public IReadOnlyDictionary <INode, IAtom> GetFirstMap(TargetProperties targetMolecule) { IState state = new VFState(query, targetMolecule); maps.Clear(); MapFirst(state); return(maps.Count == 0 ? new Dictionary <INode, IAtom>() : maps[0]); }
public int CountMaps(TargetProperties targetMolecule) { IState state = new VFState(query, targetMolecule); maps.Clear(); MapAll(state); return(maps.Count); }
public IReadOnlyList <IReadOnlyDictionary <INode, IAtom> > GetMaps(TargetProperties targetMolecule) { IState state = new VFState(query, targetMolecule); maps.Clear(); MapAll(state); return(new List <IReadOnlyDictionary <INode, IAtom> >(maps)); }
public UnitTargetConditions(TargetProperties trueconditionalFlags, int MinimumDistance = -1, double MinimumHealthPercent = 0d, TargetProperties falseConditionalFlags = TargetProperties.None) { TrueConditionFlags = trueconditionalFlags; FalseConditionFlags = falseConditionalFlags; Distance = MinimumDistance; HealthPercent = MinimumHealthPercent; CreateCriteria(); }
public UnitTargetConditions(TargetProperties trueconditionalFlags, int maxdistance = -1, int mindistance = -1, double MinimumHealthPercent = 0d, TargetProperties falseConditionalFlags = TargetProperties.None) { TrueConditionFlags = trueconditionalFlags; FalseConditionFlags = falseConditionalFlags; MaximumDistance = maxdistance; MinimumDistance = mindistance; HealthPercent = MinimumHealthPercent; CreateCriteria(); }
private IEnumerable <(string name, object value)> GetProperties(TInformation obj) { foreach (var p in Properties) { if (SerializeAllProperties || TargetProperties.ContainsKey(p.Key) || TargetCollectionProperties.ContainsKey(p.Key)) { yield return(p.Key, p.Value.GetValue(obj)); } } }
public void Initialize(WeaponProperties weaponProperties, TargetProperties targetProperties) { this.weaponProperties = weaponProperties; this.targetProperties = targetProperties; gameObject.transform.position = targetProperties.getStartPosition(); Vector2 test = Vector3.Normalize(targetProperties.getTargetPosition() - targetProperties.getStartPosition()); // gameObject.GetComponent<Rigidbody2D> ().AddForce (test); }
private bool MatchMaximumNeighbors(TargetProperties targetContainer, IAtom targetAtom) { if (maximumNeighbors == -1 || !IsBondMatchFlag) { return(true); } int maximumTargetNeighbors = targetContainer.CountNeighbors(targetAtom); return(maximumTargetNeighbors <= maximumNeighbors); }
public object Deserialize(BinaryReader reader, SerializationManager manager) { var res = new TConcrete(); while (true) { var name = reader.ReadString(); if (string.IsNullOrEmpty(name)) { break; } var value = manager.Deserialize(reader); if (TargetProperties.TryGetValue(name, out var pi)) { pi.SetValue(res, value); } else if (value is IEnumerable enumerable && TargetCollectionProperties.TryGetValue(name, out pi)) { var collection = pi.GetValue(res); if (collection == null) { continue; } foreach (var i in value.GetType().GetInterfaces()) { if (i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IEnumerable <>)) { var add = collection.GetType().GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy).Where(m => m.Name == "Add" && m.GetParameters() is ParameterInfo[] parameters && parameters.Length == 1 && parameters[0].ParameterType == i.GenericTypeArguments[0]).FirstOrDefault(); if (add == null) { continue; } var enumeratorMethod = i.GetMethod("GetEnumerator"); var enumerator = (IEnumerator)enumeratorMethod.Invoke(value, null); while (enumerator.MoveNext()) { add.Invoke(collection, new object[] { enumerator.Current }); } break; } } } } return(res); }
/// <summary> /// Initialise the VFState with query and target /// </summary> public VFState(IQuery query, TargetProperties target) { this.map = new Dictionary <INode, IAtom>(); this.queryPath = new List <INode>(); this.targetPath = new List <IAtom>(); this.query = query; this.target = target; this.candidates = new List <Match>(); LoadRootCandidates(); Console.WriteLine(map.Count); }
/// <summary> /// Scans the target host and sets target property list /// </summary> /// <param name="targetHost">The target host.</param> public void SetTargetProperties(Object targetHost) { TargetProperties.Clear(); if (targetHost != typeof(Type)) { SetTargetPropertiesFromType(targetHost.GetType()); } else { SetTargetPropertiesFromType(targetHost as Type); } TargetHost = targetHost; }
private VFState(VFState state, Match match) { this.candidates = new List <Match>(); this.queryPath = new List <INode>(state.queryPath); this.targetPath = new List <IAtom>(state.targetPath); this.map = state.map; this.query = state.query; this.target = state.target; map[match.QueryNode] = match.TargetAtom; queryPath.Add(match.QueryNode); targetPath.Add(match.TargetAtom); LoadCandidates(match); }
public override bool TryGetMember(GetMemberBinder binder, out object result) { PropertyInfo property; if (TargetProperties.TryGetValue(binder.Name, out property)) { result = property.GetValue(Target); return(true); } else { result = null; return(false); } }
public void Fire(InputPackage inputPackage) { Vector3 targetPositon = inputPackage.getMousePosition(); Vector3 startPosition = gameObject.transform.position; //TODO Change Allegiane Type TargetProperties targetProperties = new TargetProperties() .setStartPosition(startPosition) .setTargetPosition(targetPositon) .setAllegianceType(AllegianceType.Player); if (inputPackage.getInputEventType() == InputEventType.OnTap) { foreach (ITapFire tapFire in tapFires) { tapFire.tapFire(targetProperties); } } }
public static void SetProjectile(WeaponProperties weaponProperties, TargetProperties targetProperties, GameObject projectileObject) { projectileObject.AddComponent <Projectile> (); projectileObject.AddComponent <SpriteRenderer> (); SpriteRenderer spriteRenderer = projectileObject.GetComponent <SpriteRenderer> (); //TODO Make this a model Sprite sprite = Resources.Load(weaponProperties.getModelPath(), typeof(Sprite)) as Sprite; spriteRenderer.sprite = sprite; BoxCollider2D boxCollider2D = projectileObject.AddComponent <BoxCollider2D> (); boxCollider2D.size = new Vector2(1, 1); Rigidbody2D rigidbody2D = projectileObject.AddComponent <Rigidbody2D> (); rigidbody2D.gravityScale = 0; projectileObject.GetComponent <Projectile> ().Initialize(weaponProperties, targetProperties); }
public bool Matches(TargetProperties targetContainer, IAtom targetAtom) { if (smartQueryAtom != null && qAtom == null) { if (!smartQueryAtom.Matches(targetAtom)) { return(false); } } else { if (!MatchSymbol(targetAtom)) { return(false); } if (!MatchMaximumNeighbors(targetContainer, targetAtom)) { return(false); } } return(true); }
/// <inheritdoc/> /// <param name="targetConatiner">target container</param> /// <param name="targetBond">target bond</param> /// <returns>true if bonds match</returns> public bool Matches(TargetProperties targetConatiner, IBond targetBond) { if (this.smartQueryBond != null) { return(smartQueryBond.Matches(targetBond)); } else { if (!IsBondMatchFlag) { return(true); } if (IsBondMatchFlag && IsBondTypeMatch(targetBond)) { return(true); } if (IsBondMatchFlag && this.unsaturation == GetUnsaturation(targetConatiner, targetBond)) { return(true); } } return(false); }
protected static bool FeedTarget(Func <DataflowBlockOptions, TargetProperties <int> > targetFactory, DataflowBlockOptions options, int messageCount, Intervention intervention, CancellationTokenSource cancellationSource, FeedMethod feedMethod, bool isVerifiable) { bool passed = true; int expectedCaptureCount = messageCount; DataflowMessageStatus expectedStatus = DataflowMessageStatus.Accepted; bool expectedBoolStatus = true; // Aestetics var maxDop = options is ExecutionDataflowBlockOptions ? ((ExecutionDataflowBlockOptions)options).MaxDegreeOfParallelism : 1; string testHeader = string.Format(" + MessageCount={0}, MaxDOP={1}, MaxMPT={2}, Intervention={3}, FeedMethod={4}, Verifyable={5}", messageCount, maxDop, options.MaxMessagesPerTask, intervention, feedMethod, isVerifiable); // Initialize capturing structs s_captures = new int[messageCount]; for (int j = 0; j < messageCount; j++) { s_captures[j] = -1; } s_captureCount = 0; s_currentDOP = 0; s_maxDOP = maxDop; // Construct target TargetProperties <int> targetProperties = targetFactory(options); ITargetBlock <int> target = targetProperties.Target; // Feeding loop for (int i = 0; i < messageCount; i++) { if (feedMethod == FeedMethod.OfferMessage) { DataflowMessageStatus status = target.OfferMessage(new DataflowMessageHeader(1 + i), i, null, false); // Message ID doesn't metter because consumeToAccept:false if (status != expectedStatus && (cancellationSource == null || !cancellationSource.IsCancellationRequested)) // Ignore cancellation - it makes the expected result unpredictable { passed = false; break; } } else { bool boolStatus = target.Post(i); if (boolStatus != expectedBoolStatus && (cancellationSource == null || !cancellationSource.IsCancellationRequested)) // Ignore cancellation - it makes the expected result unpredictable { passed = false; break; } } // Intervene half way through. // While the intervention code is similar, the product behavior is different - // when DeclinePermanenetly is triggered, pending messages must still be processed, i.e. // the expectedCaptureCount is exactly i + 1; // when Cancel is triggered, pending messages may be discarded, i.e. // the expectedCaptureCount may be any number up to i + 1. if (i == messageCount / 2) { switch (intervention) { case Intervention.Complete: target.Complete(); expectedCaptureCount = i + 1; expectedStatus = DataflowMessageStatus.DecliningPermanently; expectedBoolStatus = false; break; case Intervention.Cancel: cancellationSource.Cancel(); expectedCaptureCount = i + 1; expectedStatus = DataflowMessageStatus.DecliningPermanently; expectedBoolStatus = false; break; } } } // Tell the target we are done target.Complete(); // Wait for the block to declare it is complete before starting verification try { target.Completion.Wait(); } catch (AggregateException ae) { // Swallow OperationCancelledException. ae.Handle(e => e is OperationCanceledException); } // Tell the capturer we are done Task.Delay(1000).Wait(); targetProperties.Capturer.Complete(); // Wait for the block to declare it is complete before starting verification try { targetProperties.Capturer.Completion.Wait(); } catch (AggregateException ae) { // Swallow OperationCancelledException. ae.Handle(e => e is OperationCanceledException); } // Verify total capture count. // s_captureCount is the actual number of captures. // expectedCaptureCount is the number of messages fed into the block before any intervention. // If there hasn't been intervention, that is the total number of messages. // When the intervention has been Complete, the actual capture count must match the input message count. // When the intervention has been Cancel, the actual capture count can be any number up to the input message count. if (isVerifiable && passed && ((expectedCaptureCount != s_captureCount && intervention != Intervention.Cancel) || (expectedCaptureCount < s_captureCount && intervention == Intervention.Cancel))) { passed = false; } // When there's been cancellation, there might be gaps in the last maxDop captures. // So eliminate them from verification. s_captureCount -= maxDop; // Verify gaps in captures. // Each element of the capture array contains the ID of the task that reported the message with that payload. // Each element has been initialized to -1. If an element is still -1 after the run, then a message has not // been captured. if (isVerifiable && passed) { for (int i = 0; i < s_captureCount; i++) { if (s_captures[i] < 0) { passed = false; break; } } } // Verify no task has exceeded MaxMessagesPerTask // Aggregate the elements of the capture array and count the occurences. // No count may exceed MMPT. if (isVerifiable && passed && options.MaxMessagesPerTask != -1) { var exceededMaxMPT = s_captures .Where(x => x >= 0) .GroupBy(x => x) .Where(g => g.Count() > options.MaxMessagesPerTask); foreach (var exceed in exceededMaxMPT) { passed = false; } } return(passed); }
public void tapFire(TargetProperties targetProperties) { ProjectileFactory.fireProjectile(weaponProperties, targetProperties); }
//Quick research showed Enum.HasFlag is slower compared to the below method. internal static bool CheckTargetPropertyFlag(TargetProperties property, TargetProperties flag) { return (property&flag)!=0; }
internal static bool CheckFlag(TargetProperties property, TargetProperties flag) { return((property & flag) != 0); }
internal static TargetProperties EvaluateUnitProperties(CacheUnit unit) { TargetProperties properties = TargetProperties.None; if (unit.IsBoss) { properties |= TargetProperties.Boss; } if (unit.IsBurrowableUnit) { properties |= TargetProperties.Burrowing; } if (unit.MonsterMissileDampening) { properties |= TargetProperties.MissileDampening; } if (unit.IsMissileReflecting) { properties |= TargetProperties.MissileReflecting; } if (unit.MonsterShielding) { properties |= TargetProperties.Shielding; } if (unit.IsStealthableUnit) { properties |= TargetProperties.Stealthable; } if (unit.IsSucideBomber) { properties |= TargetProperties.SucideBomber; } if (unit.IsTreasureGoblin) { properties |= TargetProperties.TreasureGoblin; } if (unit.IsFast) { properties |= TargetProperties.Fast; } if (unit.IsEliteRareUnique) { properties |= TargetProperties.RareElite; } if (unit.MonsterUnique) { properties |= TargetProperties.Unique; } if (unit.CurrentHealthPct.HasValue && unit.CurrentHealthPct.Value == 1d) { properties |= TargetProperties.FullHealth; } if (unit.UnitMaxHitPointAverageWeight < 0) { properties |= TargetProperties.Weak; } if (unit.IsRanged) { properties |= TargetProperties.Ranged; } if (unit.IsTargetableAndAttackable) { properties |= TargetProperties.TargetableAndAttackable; } if (unit.HasDOTdps.HasValue && unit.HasDOTdps.Value) { properties |= TargetProperties.DOTDPS; } if (unit.RadiusDistance < 10f) { properties |= TargetProperties.CloseDistance; } if (unit.MonsterReflectDamage) { properties |= TargetProperties.ReflectsDamage; } if (unit.MonsterElectrified) { properties |= TargetProperties.Electrified; } if (unit.MonsterNormal) { properties |= TargetProperties.Normal; } if (unit.CurrentHealthPct.HasValue && unit.CurrentHealthPct.Value < 0.25d) { properties |= TargetProperties.LowHealth; } return(properties); }
private static int GetUnsaturation(TargetProperties container, IAtom atom) { return(GetValency(atom) - container.CountNeighbors(atom)); }
private static int GetUnsaturation(TargetProperties container, IBond bond) { return(GetUnsaturation(container, bond.Atoms[0]) + GetUnsaturation(container, bond.Atoms[1])); }
public void Map() { ToolStripItem item = null; defaultMenuItem.DropDownItems.Clear(); targetMenuItem.DropDownItems.Clear(); requestMenuItem.DropDownItems.Clear(); item = defaultMenuItem.DropDownItems.Add("(Clear)"); item.Click += new EventHandler(DefaultSessionPropertyClickEventHandler); item.Enabled = this.IsEditable; item = targetMenuItem.DropDownItems.Add("(Clear)"); item.Click += new EventHandler(TargetPropertyClickEventHandler); item.Enabled = this.IsEditable; item = requestMenuItem.DropDownItems.Add("(Clear)"); item.Click += new EventHandler(RequestPropertyClickEventHandler); item.Enabled = this.IsEditable; if (TargetProperties.Count() > 0) { foreach (IMappableProperty targetProperty in TargetProperties.OrderBy(property => property.Name)) { if (targetProperty is UXSessionProperty) { item = defaultMenuItem.DropDownItems.Add(string.Format("[Session] {0} ({1})", targetProperty.Name, targetProperty.Type.Name)); item.Click += new EventHandler(DefaultSessionPropertyClickEventHandler); item.Enabled = this.IsEditable; } else { item = targetMenuItem.DropDownItems.Add(string.Format("{0}{1}", targetProperty.Name, targetProperty.Type != null ? string.Format(" ({0})", targetProperty.Type.Name) : string.Empty)); item.Click += new EventHandler(TargetPropertyClickEventHandler); item.Enabled = this.IsEditable; } item.Tag = targetProperty; } defaultMenuItem.Enabled = true; targetMenuItem.Enabled = true; } else { defaultMenuItem.Enabled = false; targetMenuItem.Enabled = false; defaultMenuItem.Visible = false; targetMenuItem.Visible = false; } if (RequestProperties != null && RequestProperties.Count() > 0) { foreach (IMappableProperty requestProperty in RequestProperties.OrderBy(property => property.Name)) { item = requestMenuItem.DropDownItems.Add(string.Format("{0}{1}", requestProperty.Name, requestProperty.Type != null ? string.Format(" ({0})", requestProperty.Type.Name) : string.Empty)); item.Click += new EventHandler(RequestPropertyClickEventHandler); item.Tag = requestProperty; item.Enabled = this.IsEditable; } requestMenuItem.Enabled = true; } else { requestMenuItem.Visible = false; requestMenuItem.Enabled = false; } if (!requestMenuItem.Enabled && !targetMenuItem.Enabled && !defaultMenuItem.Enabled) { mapContextMenu.Enabled = false; } else { mapContextMenu.Enabled = true; } propertyListView.Items.Clear(); if (PropertyMap != null) { // Write the propertylist from the propertymap RecreatePropertyListFromPropertyMap(); } else { PropertyMap = new PropertyMap(); foreach (IMappableProperty sourceProperty in SourceProperties) { MapProperty(null, sourceProperty); } } RefreshView(); // Select first in list if any exist if (propertyListView.Items.Count > 0) { propertyListView.Items[0].Selected = true; } }
public virtual void UpdateProperties() { Properties = TargetProperties.None; }