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); }
protected override void MouseUp(IBoardView board, Coord coord) { var player = PlayerAgent; var existing = BoardView.Get(coord); if (existing == null) { player.PushRequest(new MovePiece(PlayerAgent.Model, Agent.Model, coord), Response); return; } if (ReferenceEquals(existing, this)) { return; } // TODO: allow for mounting if (existing.SameOwner(this)) { ReturnToStart(); return; } player.PushRequest(new Battle(PlayerAgent.Model, Agent.Model, existing.Agent.Model), Response); }
private void OnMouseDrag() { if (!_dragging) { return; } var mp = Input.mousePosition; var cursorPoint = new Vector3(mp.x, mp.y, _screenPoint.z); var cursorPosition = Camera.main.ScreenToWorldPoint(cursorPoint); transform.position = cursorPosition + _cursorOffset; transform.SetZ(-0.5f); _squareOver.Value = BoardView.TestRayCast(Input.mousePosition); }
private void AddCardSubscriptions() { MouseOver.Subscribe(v => _mouseOver.Value = v).AddTo(this); 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); SquareOver.Subscribe(sq => { if (sq != null) { BoardView.ShowSquares(Agent.Model, sq); } }).AddTo(this); }
protected override bool Begin() { if (!base.Begin()) { return(false); } Coord.Subscribe(c => Move()); SquareOver.Subscribe(sq => { if (sq != null) { BoardView.ShowSquares(Agent.Model.Card, sq); } }).AddTo(this); return(true); }
private void MoveTo(Coord coord) { BoardView.MovePiece(this, coord); }