예제 #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
        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 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",
            })));
        }