示例#1
0
        public override bool AddSubscriptions()
        {
            Agent.Power.Subscribe(p => Power.text   = $"{p}").AddTo(this);
            Agent.Health.Subscribe(p => Health.text = $"{p}").AddTo(this);
            //agent.Model.ManaCost.Subscribe(p => Mana.text = $"{p}").AddTo(this);

            MouseOver.DistinctUntilChanged().Subscribe(
                v =>
            {
                //BoardView.ShowSquares(this);
            }
                );

            Dead.Subscribe(dead =>
            {
                if (!dead)
                {
                    return;
                }

                Info($"{Agent.Model} died");
                _Queue.Sequence(Cmd.Do(() => _AudioSource.PlayOneShot(DiedClip)));
                BoardView.Remove(this);
            });

            return(true);
        }
示例#2
0
        public override void SetAgent(IPlayerView view, IPieceAgent agent)
        {
            base.SetAgent(view, agent);

            Assert.IsNotNull(agent);
            Assert.IsNotNull(agent.Power);
            Assert.IsNotNull(agent.Health);
            Assert.IsNotNull(Power);
            Assert.IsNotNull(Health);

            agent.Power.Subscribe(p => Power.text   = $"{p}").AddTo(this);
            agent.Health.Subscribe(p => Health.text = $"{p}").AddTo(this);
            //agent.Model.ManaCost.Subscribe(p => Mana.text = $"{p}").AddTo(this);

            FindPiece().GetComponent <Renderer>().material
                = Owner.Value.Color == EColor.Black ? BoardView.BlackMaterial : BoardView.WhiteMaterial;

            MouseOver.DistinctUntilChanged().Subscribe(
                v =>
            {
                //BoardView.ShowSquares(this);
            }
                );
            Dead.Subscribe(d => { if (d)
                                  {
                                      Die();
                                  }
                           });
        }
示例#3
0
 public PieceModel(IPlayerModel player, ICardModel card)
     : base(player)
 {
     Card = card;
     Dead.Subscribe(dead => { if (dead)
                              {
                                  Died();
                              }
                    }).AddTo(this);
 }
示例#4
0
 public PieceModel(IOwner player, ICardModel card)
     : base(player)
 {
     Card = card;
     Dead.Subscribe(dead => { if (dead)
                              {
                                  Died();
                              }
                    });                            // TODO ADDTO .AddTo();
 }