Example #1
0
        public static IAbnormalCondition Create(Constants.AbnormalStatus type)
        {
            switch (type)
            {
            case Constants.AbnormalStatus.Poison:
                return(new Poison());

            case Constants.AbnormalStatus.Paralysis:
                return(new Paralysis());

            case Constants.AbnormalStatus.Confuse:
                return(new Confuse());

            case Constants.AbnormalStatus.Fear:
                return(new Fear());

            case Constants.AbnormalStatus.DeadlyPoison:
                return(new DeadlyPoison());

            case Constants.AbnormalStatus.FireSpread:
                return(new FireSpread());

            default:
                Assert.IsTrue(false, $"{type}は未対応です");
                return(null);
            }
        }
Example #2
0
        public void Attach(Constants.AbnormalStatus type)
        {
            // すでに状態異常にかかっている場合はなにもしない
            if (this.Contains(type))
            {
                return;
            }

            var element = AbnormalConditionFactory.Create(type);

            this.elements.Add(element);
            this.owner.Broker.Publish(AttachedAbnormalCondition.Get(type));

            // デタッチ通知が来たらデタッチする
            element.Attach(this.owner)
            .SubscribeWithState3(this, element, type, (_, _this, _element, _type) =>
            {
                _this.elements.Remove(_element);
                _element.Detach();

                _this.owner.Broker.Publish(DetachedAbnormalCondition.Get(_type));
            })
            .AddTo(this.owner);
        }
Example #3
0
 /// <summary>
 /// <paramref name="type"/>を所持しているか返す
 /// </summary>
 public bool Contains(Constants.AbnormalStatus type)
 {
     return(this.elements.FindIndex(e => e.Type == type) >= 0);
 }