public void Initialize(TargetProvider targetProvider, Transform vehicleContainer, Transform turretContainer, PatrolContainer patrolContainer) { UpdateTargets(targetProvider); ai = GetComponent <MassDriverAI>(); ai.Initialize(RateOfFire); }
/// <summary> /// Creates a new Tombola Umbraco Client connection. /// </summary> /// <exception cref="ArgumentNullException">thrown if any of the parameters are not given (are null)</exception> public UmbracoConnection(Target primaryTarget, Target secondaryTarget, UmbracoConnectionSettings connectionSettings, HttpClient httpClient, ICacheProvider cache = null) { if (primaryTarget == null) { throw new ArgumentNullException(nameof(primaryTarget)); } if (connectionSettings == null) { throw new ArgumentNullException(nameof(connectionSettings)); } if (httpClient == null) { throw new ArgumentNullException(nameof(httpClient)); } // Configure HttpClient httpClient.Timeout = connectionSettings.GlobalRequestTimeout; httpClient.DefaultRequestHeaders.Add("X-Tombola-ApiKey", "UB1eS3LZQMs9k6xXqAMMiZ1uvhhh2Gck"); this.httpClient = httpClient; // Configure cache this.cache = cache; if (cache != null) { cache.OnCacheMiss += Cache_OnCacheMiss; } // Create target provider this.targetProvider = new TargetProvider(primaryTarget, secondaryTarget, httpClient); ConnectionStatus = ConnectionStatus.UnInitialized; }
protected override object ProvideValueCore() { var targetProperty = TargetProvider.With(x => x.TargetProperty as DependencyProperty); var targetObject = TargetProvider.With(x => x.TargetObject as DependencyObject); PropertyMetadata metadata = targetProperty != null && targetObject != null? targetProperty.GetMetadata(targetObject) : null; if (Mode != BindingMode.Default || metadata == null) { ActualMode = Mode; } else { if (!(metadata is FrameworkPropertyMetadata)) { ActualMode = BindingMode.OneWay; } else if (((FrameworkPropertyMetadata)metadata).BindsTwoWayByDefault) { ActualMode = BindingMode.TwoWay; } else { ActualMode = BindingMode.OneWay; } } return(base.ProvideValueCore()); }
void Start() { var islandLevel = StaticPersistence.GameState != null ? StaticPersistence.GameState.Mission.MissionIsland.Level : RandomService.GetRandom(1, 10); var islandName = StaticPersistence.GameState != null ? StaticPersistence.GameState.Mission.MissionIsland.Name : NameProvider.GetIslandName(); StatusUI.Initialize(islandName, islandLevel); DefensePlacer.Initialize(islandLevel); DefensePlacer.PlaceDrones(); DefensePlacer.PlaceTurrets(); DefensePlacer.PlaceSAMTurrets(); DefensePlacer.PlaceDefenses(); buildings = BuildingContainer.GetComponentsInChildren <Building>(); hitPoints = buildings.Count(); TargetProvider = new CoalitionTargetProvider(); foreach (var b in buildings) { var healthBar = IslandStatus.AddBuilding(b.Name); healthBar.Initialize(b.Health.BaseHitPoints); b.Initialize(this, VehicleContainer, TurretContainer, Patrols, healthBar.UpdateHp); } }
public void Initialize(TargetProvider targetProvider, Transform vehicles, Transform turrets, PatrolContainer patrols) { dronePatrol = patrols.DronePatrol; droneContainer = vehicles; targetProvider.RegisterController(this); InitializeDrones(); }
protected override void WriteSymbols(StreamWriter output) { if (String.IsNullOrEmpty(AndroidPackageName)) { throw new InvalidOperationException("Android package name must be set"); } if (UsesMonoAOT && String.IsNullOrEmpty(MonoAOTMode)) { throw new InvalidOperationException("Mono AOT enabled but no AOT mode specified"); } string stringLabel = GetStringLabel(); WriteData(output, AndroidPackageName, stringLabel); WriteDataSection(output, "application_config"); WriteSymbol(output, "application_config", TargetProvider.GetStructureAlignment(true), fieldAlignBytes: 4, isGlobal: true, alwaysWriteSize: true, structureWriter: () => { // Order of fields and their type must correspond *exactly* to that in // src/monodroid/jni/xamarin-app.h ApplicationConfig structure WriteCommentLine(output, "uses_mono_llvm"); uint size = WriteData(output, UsesMonoLLVM); WriteCommentLine(output, "uses_mono_aot"); size += WriteData(output, UsesMonoAOT); WriteCommentLine(output, "uses_assembly_preload"); size += WriteData(output, UsesAssemblyPreload); WriteCommentLine(output, "is_a_bundled_app"); size += WriteData(output, IsBundledApp); WriteCommentLine(output, "environment_variable_count"); size += WriteData(output, environmentVariables == null ? 0 : environmentVariables.Count * 2); WriteCommentLine(output, "system_property_count"); size += WriteData(output, systemProperties == null ? 0 : systemProperties.Count * 2); // After uses_embedded_dsos was removed, we need padding on 64-bit if (TargetProvider.Is64Bit) { size += WriteDataPadding(output, 4); } WriteCommentLine(output, "android_package_name"); size += WritePointer(output, stringLabel); return(size); }); stringLabel = GetStringLabel(); WriteData(output, MonoAOTMode ?? String.Empty, stringLabel); WriteDataSection(output, "mono_aot_mode_name"); WritePointer(output, stringLabel, "mono_aot_mode_name", isGlobal: true); WriteNameValueStringArray(output, "app_environment_variables", environmentVariables); WriteNameValueStringArray(output, "app_system_properties", systemProperties); }
protected virtual void WriteFileHeader(StreamWriter output) { TargetProvider.WriteFileHeader(output, Indent); output.Write(Indent); output.Write(".file"); output.Write(Indent); output.Write('"'); output.Write(Path.GetFileName(MainSourceFile)); output.WriteLine('"'); }
uint UpdateSize <T> (StreamWriter output, T[] value) { uint typeSize = TargetProvider.GetTypeSize <T> (); uint fieldSize = typeSize * (uint)value.Length; fieldSize += WriteDataPadding(output, fieldSize, structureByteCount); structureByteCount += fieldSize; return(fieldSize); }
public void Initialize(TargetProvider targetProvider, Transform vehicles, Transform turretContainer, PatrolContainer patrols) { targetProvider.RegisterController(this); turrets = turretContainer.GetComponentsInChildren <SamAI>(); foreach (var t in turrets) { t.Initialize(); } }
protected uint WriteData(StreamWriter output, string value, string label, bool isGlobal = false) { if (String.IsNullOrEmpty(label)) { throw new ArgumentException("must not be null or empty", nameof(label)); } if (value == null) { value = String.Empty; } WriteSection(output, $".rodata.{label}", hasStrings: true, writable: false); WriteSymbol(output, value, isGlobal ? label : MakeLocalLabel(label), size: (ulong)(value.Length + 1), alignBits: 0, isGlobal: isGlobal, isObject: true, alwaysWriteSize: true); return(TargetProvider.GetTypeSize(value)); }
void WriteCompressedAssembliesStructure(StreamWriter output, uint count, string descriptorsLabel) { WriteDataSection(output, CompressedAssembliesField); WriteSymbol(output, CompressedAssembliesField, TargetProvider.GetStructureAlignment(true), packed: false, isGlobal: true, alwaysWriteSize: true, structureWriter: () => { // Order of fields and their type must correspond *exactly* to that in // src/monodroid/jni/xamarin-app.h CompressedAssemblies structure WriteCommentLine(output, "count"); uint size = WriteData(output, count); WriteCommentLine(output, "descriptors"); size += WritePointer(output, descriptorsLabel); return(size); }); }
// Start is called before the first frame update void Start() { rb = gameObject.GetComponent <Rigidbody2D>(); animator = gameObject.GetComponent <Animator>(); targetProvider = gameObject.GetComponent <TargetProvider>(); rb.gravityScale = 0.0f; rb.constraints = RigidbodyConstraints2D.FreezeRotation; Physics2D.IgnoreLayerCollision(13, 9); Physics2D.IgnoreLayerCollision(10, 10); Physics2D.IgnoreLayerCollision(10, 11); Physics2D.IgnoreLayerCollision(11, 11); Physics2D.IgnoreLayerCollision(11, 9); Physics2D.IgnoreLayerCollision(10, 13); aiState = GhostAIState.SCATTER; }
uint UpdateSize <T> (StreamWriter output, T value) { uint fieldSize; Type t = typeof(T); if (t == typeof(string)) { fieldSize = TargetProvider.GetPointerSize(); } else { fieldSize = TargetProvider.GetTypeSize(value); } fieldSize += WriteDataPadding(output, fieldSize, structureByteCount); structureByteCount += fieldSize; return(fieldSize); }
protected uint WriteData(StreamWriter output, byte[] value, string label = null, bool isGlobal = false) { uint fieldSize = UpdateSize(output, value); var symbolValue = new StringBuilder(); bool first = true; foreach (byte b in value) { if (!first) { symbolValue.Append(", "); } else { first = false; } symbolValue.Append($"0x{b:x02}"); } WriteSymbol(output, TargetProvider.MapType <byte> (), symbolValue.ToString(), symbolName: label, size: 0, alignBits: 0, isGlobal: isGlobal, isObject: false, alwaysWriteSize: false); return(fieldSize); }
public object Provide(object context) { InvokeMethod invoke = InvokeMethodInstance == null ? new InvokeMethod() : InvokeMethodInstance; if (TargetProvider != null) { invoke.TargetObject = TargetProvider.Provide(context); } if (MethodNameProvider != null) { invoke.MethodName = MethodNameProvider.Provide(context); } if (ArgumentProviders != null) { object[] args = new object[ArgumentProviders.Length]; for (int i = 0; i < ArgumentProviders.Length; i++) { args[i] = ArgumentProviders[i].Provide(context); } invoke.Arguments = args; } return(invoke.Provide(context)); }
void WriteNameValueStringArray(StreamWriter output, string label, SortedDictionary <string, string> entries) { if (entries == null || entries.Count == 0) { WriteDataSection(output, label); WriteSymbol(output, label, TargetProvider.GetStructureAlignment(true), packed: false, isGlobal: true, alwaysWriteSize: true, structureWriter: null); return; } var entry_labels = new List <string> (); foreach (var kvp in entries) { string name = kvp.Key; string value = kvp.Value ?? String.Empty; string stringLabel = GetStringLabel(); WriteData(output, name, stringLabel); entry_labels.Add(stringLabel); stringLabel = GetStringLabel(); WriteData(output, value, stringLabel); entry_labels.Add(stringLabel); } WriteDataSection(output, label); WriteSymbol(output, label, TargetProvider.GetStructureAlignment(true), packed: false, isGlobal: true, alwaysWriteSize: true, structureWriter: () => { uint size = 0; foreach (string l in entry_labels) { size += WritePointer(output, MakeLocalLabel(l)); } return(size); }); }
// `alignBits` indicates the number of lowest bits that have to be cleared to 0 in order to align the // following data structure, thus `2` would mean "align to 4 bytes", `3' would be "align to 8 bytes" // etc. In general, if the data field contains a pointer the alignment should be to the platform's // native pointer size, if not it should be 2 (for 4-byte alignment) in the case of the targets we // support. Alignment is not necessary for standalone fields (i.e. not parts of a structure) protected void WriteSymbol <T> (StreamWriter output, T symbolValue, string symbolName, ulong size, uint alignBits, bool isGlobal, bool isObject, bool alwaysWriteSize) { WriteSymbol(output, TargetProvider.MapType <T>(), QuoteValue(symbolValue), symbolName, size, alignBits, isGlobal, isObject, alwaysWriteSize); }
public void UpdateTargets(TargetProvider targetProvider) { targets = targetProvider.PossibleSmallTargets; RefreshDrones(); }
public void UpdateTargets(TargetProvider targetProvider) => targets = targetProvider.PossibleBigTargets;
private void HandleAttacking(IWowUnit target) { if (TargetProvider.Get(out IEnumerable <IWowUnit> targetToTarget)) { ulong guid = targetToTarget.First().Guid; if (Bot.Objects.Player.TargetGuid != guid) { Bot.Wow.ChangeTarget(guid); } } if (Bot.Objects.Target == null || Bot.Objects.Target.IsDead || !IWowUnit.IsValidUnit(Bot.Objects.Target)) { return; } double playerRunePower = Bot.Objects.Player.RunicPower; double distanceToTarget = Bot.Objects.Player.Position.GetDistance(target.Position); double targetHealthPercent = (target.Health / (double)target.MaxHealth) * 100; double playerHealthPercent = (Bot.Objects.Player.Health / (double)Bot.Objects.Player.MaxHealth) * 100.0; (string, int)targetCastingInfo = Bot.Wow.GetUnitCastingInfo(WowLuaUnit.Target); //List<string> myBuffs = Bot.NewBot.GetBuffs(WowLuaUnit.Player.ToString()); //myBuffs.Any(e => e.Equals("Chains of Ice")) if (Bot.Wow.GetSpellCooldown("Death Grip") <= 0 && distanceToTarget <= 30) { Bot.Wow.CastSpell("Death Grip"); return; } if (target.IsFleeing && distanceToTarget <= 30) { Bot.Wow.CastSpell("Chains of Ice"); return; } if (Bot.Wow.GetSpellCooldown("Army of the Dead") <= 0 && IsOneOfAllRunesReady()) { Bot.Wow.CastSpell("Army of the Dead"); return; } List <IWowUnit> unitsNearPlayer = Bot.Objects.WowObjects .OfType <IWowUnit>() .Where(e => e.Position.GetDistance(Bot.Objects.Player.Position) <= 10) .ToList(); if (unitsNearPlayer.Count > 2 && Bot.Wow.GetSpellCooldown("Blood Boil") <= 0 && Bot.Wow.IsRuneReady(0) || Bot.Wow.IsRuneReady(1)) { Bot.Wow.CastSpell("Blood Boil"); return; } List <IWowUnit> unitsNearTarget = Bot.Objects.WowObjects .OfType <IWowUnit>() .Where(e => e.Position.GetDistance(target.Position) <= 30) .ToList(); if (unitsNearTarget.Count > 2 && Bot.Wow.GetSpellCooldown("Death and Decay") <= 0 && IsOneOfAllRunesReady()) { Bot.Wow.CastSpell("Death and Decay"); Bot.Wow.ClickOnTerrain(target.Position); return; } if (Bot.Wow.GetSpellCooldown("Icy Touch") <= 0 && Bot.Wow.IsRuneReady(2) || Bot.Wow.IsRuneReady(3)) { Bot.Wow.CastSpell("Icy Touch"); return; } }
static void Demo() { var ____ = Spider.Factory; var _____ = TestTinkerStuff.tinker; var ______ = TestStatusStuff.status; System.Console.WriteLine("\n ------ Definition + Instantiation Demo ------ \n"); World world = new World(5, 5); System.Console.WriteLine("Created world"); // Statused.RegisterStatus(TestStatusTinkerStuff.status, 1); var packed = Registry.Default.Tinker.PackModMap(); Registry.Default.Tinker.SetServerMap(packed); var player.Factory = new EntityFactory<Player>(); player.Factory.AddBehavior(Attackable.DefaultPreset); player.Factory.AddBehavior(Attacking.Preset); player.Factory.AddBehavior(Displaceable.DefaultPreset); player.Factory.AddBehavior(Moving.Preset); player.Factory.AddBehavior(Pushable.Preset); player.Factory.AddBehavior(Statused.Preset); System.Console.WriteLine("Set up player.Factory"); Acting.Config playerActingConf = new Acting.Config(Algos.SimpleAlgo, null); player.Factory.AddBehavior(Acting.Preset(playerActingConf)); player.Factory.Retouch(Hopper.Core.Retouchers.Skip.EmptyAttack); // this one's for the equip demo player.Factory.Retouch(Hopper.Core.Retouchers.Equip.OnDisplace); var enemy.Factory = new EntityFactory<Entity>(); enemy.Factory.AddBehavior(Attackable.DefaultPreset); enemy.Factory.AddBehavior(Attacking.Preset); enemy.Factory.AddBehavior(Displaceable.DefaultPreset); enemy.Factory.AddBehavior(Moving.Preset); enemy.Factory.AddBehavior(Pushable.Preset); Acting.Config enemyActingConf = new Acting.Config(Algos.EnemyAlgo); enemy.Factory.AddBehavior(Acting.Preset(enemyActingConf)); var attackAction = Action.CreateBehavioral<Attacking>(); var moveAction = Action.CreateBehavioral<Moving>(); CompositeAction attackMoveAction = new CompositeAction( new Action[] { attackAction, moveAction } ); Step[] stepData = { new Step { action = null }, new Step { action = attackMoveAction, movs = Movs.Basic } }; var sequenceConfig = new Sequential.Config(stepData); enemy.Factory.AddBehavior(Sequential.Preset(sequenceConfig)); System.Console.WriteLine("Set up enemy.Factory"); Entity player = player.Factory.Instantiate(); System.Console.WriteLine("Instantiated Player"); Entity enemy = enemy.Factory.Instantiate(); System.Console.WriteLine("Instantiated Enemy"); enemy.Init(new IntVector2(1, 2), world); world.State.AddEntity(enemy); world.Grid.Reset(enemy, enemy.Pos); System.Console.WriteLine("Enemy set in world"); player.Init(new IntVector2(1, 1), world); world.State.AddPlayer(player); world.Grid.Reset(player, player.Pos); System.Console.WriteLine("Player set in world"); var playerNextAction = attackMoveAction.Copy(); playerNextAction.direction = new IntVector2(0, 1); player.Behaviors.Get<Acting>().NextAction = playerNextAction; System.Console.WriteLine("Set player action"); System.Console.WriteLine("\n ------ Modifier Demo ------ \n"); var mod = Modifier.Create(Attack.Path, new Attack { damage = 1 });//new StatModifier(Attack.Path, new Attack { damage = 1 }); var attack = player.Stats.Get(Attack.Path); System.Console.WriteLine("Attack damage:{0}", attack.damage); System.Console.WriteLine("Attack pierce:{0}", attack.pierce); System.Console.WriteLine("Adding modifier"); mod.AddSelf(player.Stats); attack = player.Stats.Get(Attack.Path); System.Console.WriteLine("Attack damage:{0}", attack.damage); System.Console.WriteLine("Attack pierce:{0}", attack.pierce); System.Console.WriteLine("Removing modifier"); mod.RemoveSelf(player.Stats); attack = player.Stats.Get(Attack.Path); System.Console.WriteLine("Attack damage:{0}", attack.damage); System.Console.WriteLine("Attack pierce:{0}", attack.pierce); var mod2 = Modifier.Create(Attack.Path, new EvHandler<StatEvent<Attack>>( (StatEvent<Attack> eve) => { System.Console.WriteLine("Called handler"); eve.file.damage *= 3; }) ); System.Console.WriteLine("Adding modifier"); mod2.AddSelf(player.Stats); attack = player.Stats.Get(Attack.Path); System.Console.WriteLine("Attack damage:{0}", attack.damage); System.Console.WriteLine("Attack pierce:{0}", attack.pierce); System.Console.WriteLine("Removing modifier"); player.Stats.RemoveChainModifier(mod2); attack = player.Stats.Get(Attack.Path); System.Console.WriteLine("Attack damage:{0}", attack.damage); System.Console.WriteLine("Attack pierce:{0}", attack.pierce); System.Console.WriteLine("\n ------ Pools Demo ------ \n"); PoolItem[] items = new[] { new PoolItem(0, 1), new PoolItem(1, 1), new PoolItem(2, 1), new PoolItem(3, 1), new PoolItem(4, 10) }; var pool = Pool.CreateNormal<Hopper.Core.Items.IItem>(); pool.AddRange("zone1/weapons", items.Take(2)); pool.AddRange("zone1/trinkets", items.Skip(2).Take(2)); pool.Add("zone1/trinkets", items[4]); var poolCopy = pool.Copy(); var it1 = pool.GetNextItem("zone1/weapons"); System.Console.WriteLine($"Item Id = {it1.id}, q = {it1.quantity}"); // var it2 = pool.GetNextItem("zone1/weapons"); // System.Console.WriteLine($"Item Id = {it2.id}, q = {it2.quantity}"); var it3 = poolCopy.GetNextItem("zone1/weapons"); System.Console.WriteLine($"Item Id = {it3.id}, q = {it3.quantity}"); var it4 = poolCopy.GetNextItem("zone1/weapons"); System.Console.WriteLine($"Item Id = {it4.id}, q = {it4.quantity}"); System.Console.WriteLine("\n ------ TargetProvider Demo ------ \n"); var pattern = new Pattern ( new Piece { pos = new IntVector2(1, 0), dir = new IntVector2(1, 0), reach = null }, new Piece { pos = new IntVector2(2, 0), dir = new IntVector2(1, 0), reach = new List<int>() } ); var weapon = TargetProvider.CreateAtk(pattern, Handlers.GeneralChain); System.Console.WriteLine($"Enemy is at {enemy.Pos}"); var atk = player.Stats.Get(Attack.Path); var targets = weapon.GetTargets(player, playerNextAction.direction, atk); foreach (var t in targets) { System.Console.WriteLine($"Entity at {t.targetEntity.Pos} has been considered a potential target"); } System.Console.WriteLine("\n ------ Inventory Demo ------ \n"); var inventory = (Inventory)player.Inventory; var slot = new SizedSlot<CircularItemContainer, Hopper.Core.Items.IItem>("stuff2", 1); inventory.AddContainer(slot); var tinker = Tinker<TinkerData>.SingleHandlered<Attacking.Event>( Attacking.Check, e => System.Console.WriteLine("Hello from tinker applied by item") ); var item = new TinkerItem(new ItemMetadata("Test_Tinker_Item"), tinker, slot); // inventory.Equip(item) -> // the starting point // item.BeEquipped(entity) -> // it's interface method // tinker.Tink(entity) -> // adds the handlers // entity.Tinkers.SetStore() // creates the tinker data inventory.Equip(item); world.Loop(); System.Console.WriteLine("Looped"); // creates excess as the size is 1 inventory.Equip(item); // inventory.DropExcess() -> // item.BeUnequipped() -> // tinker.Untink() -> entity.Tinkers.RemoveStore() // + world.CreateDroppedItem(id, pos) inventory.DropExcess(); var entities = world.Grid.GetCellAt(player.Pos).m_entities; System.Console.WriteLine($"There's {entities.Count} entities in the cell where the player is standing"); System.Console.WriteLine("\n ------ History Demo ------ \n"); var enemyUpdates = enemy.History.Updates; var playerUpdates = player.History.Updates; foreach (var updateInfo in enemyUpdates) { System.Console.WriteLine($"Enemy did {System.Enum.GetName(typeof(UpdateCode), updateInfo.updateCode)}. Position after: {updateInfo.stateAfter.pos}"); } foreach (var updateInfo in playerUpdates) { System.Console.WriteLine($"Player did {System.Enum.GetName(typeof(UpdateCode), updateInfo.updateCode)}. Position after: {updateInfo.stateAfter.pos}"); } System.Console.WriteLine("\n ------ Equip on Displace Demo ------ \n"); // we don't need the entity for the next test enemy.Die(); var playerMoveAction = moveAction.Copy(); playerMoveAction.direction = IntVector2.Down; player.Behaviors.Get<Acting>().NextAction = playerMoveAction; var slot2 = new SizedSlot<CircularItemContainer, Hopper.Core.Items.IItem>("stuff3", 1); inventory.AddContainer(slot2); var chainDefs2 = new IChainDef[0]; var tinker2 = new Tinker<TinkerData>(chainDefs2); var item2 = new TinkerItem(new ItemMetadata("Test_Tinker_Item_2"), tinker2, slot2); var droppedItem2 = world.SpawnDroppedItem(item2, player.Pos + IntVector2.Down); /* this only works because we did `player.Factory.AddRetoucher(Core.Retouchers.Equip.OnDisplace);` up top. */ System.Console.WriteLine($"Player's position before moving: {player.Pos}"); world.Loop(); System.Console.WriteLine($"Player's new position: {player.Pos}"); System.Console.WriteLine($"There's {world.Grid.GetCellAt(player.Pos).m_entities.Count} entities in the cell where the player is standing"); System.Console.WriteLine("\n ------ Tinker static reference Demo ------ \n"); var tinker3 = TestTinkerStuff.tinker; // see the definition below tinker3.Tink(player); player.Behaviors.Get<Acting>().NextAction = playerMoveAction; world.Loop(); tinker3.Untink(player); System.Console.WriteLine("\n ------ Status Demo ------ \n"); // this has to be rethought for sure var status = TestStatusStuff.status; status.TryApply( player, new StatusData(), new StatusFile { power = 1, amount = 2 } ); player.Behaviors.Get<Acting>().NextAction = playerMoveAction; world.Loop(); player.Behaviors.Get<Acting>().NextAction = playerMoveAction; world.Loop(); player.Behaviors.Get<Acting>().NextAction = playerMoveAction; world.Loop(); System.Console.WriteLine("\n ------ Spider Demo ------ \n"); player.ResetPosInGrid(new IntVector2(4, 4)); var spider = world.SpawnEntity(Spider.Factory, new IntVector2(3, 3)); world.Loop(); System.Console.WriteLine($"Tinker is applied? {BindStatuses.NoMove.IsApplied(player)}"); System.Console.WriteLine("Looped"); System.Console.WriteLine($"Player's new position: {player.Pos}"); System.Console.WriteLine($"Spider's new position: {spider.Pos}"); player.Behaviors.Get<Acting>().NextAction = attackAction; world.Loop(); System.Console.WriteLine("Looped"); System.Console.WriteLine($"Player's new position: {player.Pos}"); System.Console.WriteLine($"Spider's new position: {spider.Pos}"); player.Behaviors.Get<Displaceable>().Activate(new IntVector2(-1, -1), new Move()); world.Loop(); System.Console.WriteLine("Looped"); System.Console.WriteLine($"Player's new position: {player.Pos}"); System.Console.WriteLine($"Spider's new position: {spider.Pos}"); System.Console.WriteLine("Killing spider"); spider.Die(); world.Loop(); System.Console.WriteLine($"Tinker is applied? {BindStatuses.NoMove.IsApplied(player)}"); System.Console.WriteLine("\n ------ Input Demo ------ \n"); // we also have the possibilty to add behaviors dynamically. var Input.Factory = new BehaviorFactory<Controllable>(); var input = (Controllable)Input.Factory.Instantiate(player, new Controllable.Config { defaultAction = attackMoveAction }); player.Behaviors.Add(typeof(Controllable), input); var outputAction0 = input.ConvertVectorToAction(IntVector2.Up); System.Console.WriteLine($"Fed Up. Output: {outputAction0.direction}"); var outputAction1 = input.ConvertInputToAction(InputMapping.Special_0); System.Console.WriteLine($"Fed Special_0. Output is null?: {outputAction1 == null}"); }
void Awake() { targetProvider = GetComponent <TargetProvider>(); }
protected override void WriteSymbols(StreamWriter output) { if (String.IsNullOrEmpty(AndroidPackageName)) { throw new InvalidOperationException("Android package name must be set"); } if (UsesMonoAOT && String.IsNullOrEmpty(MonoAOTMode)) { throw new InvalidOperationException("Mono AOT enabled but no AOT mode specified"); } string stringLabel = GetStringLabel(); WriteData(output, AndroidPackageName, stringLabel); WriteDataSection(output, "application_config"); WriteSymbol(output, "application_config", TargetProvider.GetStructureAlignment(true), packed: false, isGlobal: true, alwaysWriteSize: true, structureWriter: () => { // Order of fields and their type must correspond *exactly* to that in // src/monodroid/jni/xamarin-app.h ApplicationConfig structure WriteCommentLine(output, "uses_mono_llvm"); uint size = WriteData(output, UsesMonoLLVM); WriteCommentLine(output, "uses_mono_aot"); size += WriteData(output, UsesMonoAOT); WriteCommentLine(output, "uses_assembly_preload"); size += WriteData(output, UsesAssemblyPreload); WriteCommentLine(output, "is_a_bundled_app"); size += WriteData(output, IsBundledApp); WriteCommentLine(output, "broken_exception_transitions"); size += WriteData(output, BrokenExceptionTransitions); WriteCommentLine(output, "instant_run_enabled"); size += WriteData(output, InstantRunEnabled); WriteCommentLine(output, "jni_add_native_method_registration_attribute_present"); size += WriteData(output, JniAddNativeMethodRegistrationAttributePresent); WriteCommentLine(output, "have_runtime_config_blob"); size += WriteData(output, HaveRuntimeConfigBlob); WriteCommentLine(output, "bound_exception_type"); size += WriteData(output, (byte)BoundExceptionType); WriteCommentLine(output, "package_naming_policy"); size += WriteData(output, (uint)PackageNamingPolicy); WriteCommentLine(output, "environment_variable_count"); size += WriteData(output, environmentVariables == null ? 0 : environmentVariables.Count * 2); WriteCommentLine(output, "system_property_count"); size += WriteData(output, systemProperties == null ? 0 : systemProperties.Count * 2); WriteCommentLine(output, "android_package_name"); size += WritePointer(output, MakeLocalLabel(stringLabel)); return(size); }); stringLabel = GetStringLabel(); WriteData(output, MonoAOTMode ?? String.Empty, stringLabel); WriteDataSection(output, "mono_aot_mode_name"); WritePointer(output, MakeLocalLabel(stringLabel), "mono_aot_mode_name", isGlobal: true); WriteNameValueStringArray(output, "app_environment_variables", environmentVariables); WriteNameValueStringArray(output, "app_system_properties", systemProperties); }
private void Awake() { targetProvider = FindObjectOfType <TrackedControllerTarget>(); }