Ejemplo n.º 1
0
 private void Update()
 {
     if (_moving)
     {
         _t += Time.deltaTime / secondsToTravel;
         transform.localPosition = Vector3.Lerp(_start, _end, _t);
         if (Vector3.Distance(transform.localPosition, _end) < 0.01)
         {
             transform.localPosition = _end;
             map.Move(_msg.Piece, _msg.From, _msg.To);
             gameInputActive.Unlock(gameObject);
             _moving = false;
             Message.Publish(new PieceMovementFinished());
         }
     }
 }
 private void Update()
 {
     if (_teleporting)
     {
         _t = Mathf.Min(1, _t + Time.deltaTime / secondsToTravel);
         UpdateTextures(Generate(255, Mathf.Max(0, _t - 0.5f) * 2, Mathf.Min(1, _t * 2)), Generate(255, Mathf.Max(0, (1 - _t) - 0.5f) * 2, Mathf.Min(1, (1 - _t) * 2)));
         if (_t == 1)
         {
             var tempPosition = _renderer.transform.position;
             transform.localPosition = new Vector3(_msg.To.X, _msg.To.Y, transform.localPosition.z);
             rendererParticles.transform.position             = tempPosition;
             _goToPosition.gameObject.transform.localPosition = _renderer.gameObject.transform.localPosition;
             var temp = _renderer;
             _renderer     = _goToPosition;
             _goToPosition = temp;
             UpdateTextures(Generate(1, 0, 0), Generate(1, 1, 1));
             _goToPosition.gameObject.SetActive(false);
             map.Move(_msg.Piece, _msg.From, _msg.To);
             gameInputActive.Unlock(gameObject);
             _teleporting = false;
         }
     }
 }
 protected override void Execute(PieceMoved msg) => map.Move(msg.Piece, msg.From, msg.To);