public DistributedSwapTransaction(SwapTransaction swapTransaction) { this.BlockHeight = swapTransaction.BlockHeight; this.StraxAddress = swapTransaction.StraxAddress; this.SenderAmount = swapTransaction.SenderAmount; this.TransactionHash = swapTransaction.TransactionHash; }
/// <summary> /// Поменяться местами с другим элементом. Вызывается самим игроком. Если после смены мест совпадений не нашлось, /// то элементы перемещаются обратно. /// </summary> /// <param name="otherElement"></param> /// <returns></returns> public IEnumerator Swap(Element otherElement) { GameManager.GameStatus = GameStatus.PlayingAnimation; using (var transaction = new SwapTransaction(this, otherElement)) { var swap1 = StartCoroutine(UpdateWorldPosition()); var swap2 = StartCoroutine(otherElement.UpdateWorldPosition()); yield return(swap1); yield return(swap2); // int matches = Grid.Instance.CalculateMatches(false); var matches = Grid.Instance.CalculateMatches(false); if (matches > 0) { transaction.Commit(); Grid.Instance.CalculateMatches(true); yield break; } } var returnSwap1 = StartCoroutine(UpdateWorldPosition()); var returnSwap2 = StartCoroutine(otherElement.UpdateWorldPosition()); yield return(returnSwap1); yield return(returnSwap2); GameManager.GameStatus = GameStatus.WaitingForInput; }