public MainCharacter() { this.Id = nameof(MainCharacter) + ": " + NextId++; this.Tags.Add(nameof(MainCharacter)); this.MoveTo(0, 0); this.Added.SubscribeForLifetime(() => { Current = this; }, this.Lifetime); this.Inventory.SubscribeForLifetime(nameof(Inventory.PrimaryWeapon), () => { if (Inventory.PrimaryWeapon != null) { OnEquipWeapon.Fire(Inventory.PrimaryWeapon); } }, this.Lifetime); this.Inventory.SubscribeForLifetime(nameof(Inventory.ExplosiveWeapon), () => { if (Inventory.PrimaryWeapon != null) { OnEquipWeapon.Fire(Inventory.ExplosiveWeapon); } }, this.Lifetime); InitializeTargeting(SpaceTime.CurrentSpaceTime.Add(new AutoTargetingFunction(new AutoTargetingOptions() { Source = this.Velocity, TargetsEval = () => SpaceTime.CurrentSpaceTime.Elements.Where(e => e.HasSimpleTag("enemy")), }))); }
public MainCharacter() { this.Id = nameof(MainCharacter) + ": " + NextId++; this.MoveTo(0, 0); this.Added.SubscribeForLifetime(() => { Current = this; }, this.Lifetime); this.Inventory.SubscribeForLifetime(nameof(Inventory.PrimaryWeapon), () => { if (Inventory.PrimaryWeapon != null) { OnEquipWeapon.Fire(Inventory.PrimaryWeapon); } }, this.Lifetime); this.Inventory.SubscribeForLifetime(nameof(Inventory.ExplosiveWeapon), () => { if (Inventory.PrimaryWeapon != null) { OnEquipWeapon.Fire(Inventory.ExplosiveWeapon); } }, this.Lifetime); InitializeTargeting(); }
public bool TryRevive(LevelItem item, List <LevelItem> allItems, out ITimeFunction hydratedElement) { if (item.Tags.Contains("main-character") == false) { hydratedElement = null; return(false); } hydratedElement = new MainCharacter(); return(true); }
public void Interact(MainCharacter character) { var newDoorDest = IsOpen ? ClosedBounds : OpenBounds; var charactersThatWillTouchNewDest = SpaceTime.CurrentSpaceTime.Elements.WhereAs <Character>().Where(c => c.OverlapPercentage(newDoorDest) > 0).Count(); if (charactersThatWillTouchNewDest == 0) { IsOpen = !IsOpen; } }
public MainCharacter() { this.Id = nameof(MainCharacter) + ": " + NextId++; this.AddTag(nameof(MainCharacter)); this.MoveTo(0, 0); this.Added.SubscribeForLifetime(() => { Current = this; this.Lifetime.OnDisposed(() => { if (_current == this) { _current = null; } }); }, this.Lifetime); this.Inventory.SubscribeForLifetime(nameof(Inventory.PrimaryWeapon), () => { if (Inventory.PrimaryWeapon != null) { OnEquipWeapon.Fire(Inventory.PrimaryWeapon); } }, this.Lifetime); this.Inventory.SubscribeForLifetime(nameof(Inventory.ExplosiveWeapon), () => { if (Inventory.PrimaryWeapon != null) { OnEquipWeapon.Fire(Inventory.ExplosiveWeapon); } }, this.Lifetime); InitializeTargeting(SpaceTime.CurrentSpaceTime.Add(new AutoTargetingFunction(new AutoTargetingOptions() { Source = this.Velocity, TargetTag = "enemy", }))); }