コード例 #1
0
        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")),
            })));
        }
コード例 #2
0
ファイル: MainCharacter.cs プロジェクト: chaami/PowerArgs
        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();
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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;
            }
        }
コード例 #5
0
        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",
            })));
        }