Beispiel #1
0
        private void PerformAttack()
        {
            BattleHitZone?attackZone  = this.AttackTarget.GetHitZone();
            BattleHitZone?defenceZone = this.BlockTarget.GetHitZone();

            if (!attackZone.HasValue || !defenceZone.HasValue)
            {
                MessageBox.Show("You need to chose targets for attack and block before making the move.", "Choose move",
                                MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            BattleMoveData data = new BattleMoveData();

            data.Attack     = attackZone.Value;
            data.Defence    = defenceZone.Value;
            data.TargetName = this.EnemyName;
            this.engine.MakeBattleMove(data);

            //
            // Clear data for next move.
            //

            this.AttackTarget.ClearZones();
            this.BlockTarget.ClearZones();
        }
Beispiel #2
0
        public void MakeBattleMove(BattleMoveData moveData)
        {
            moveData.BattleId = this.BattleId;

            var opHandler = new OperationDataHandler();

            byte[] data = opHandler.GetBytes(new ClientRequestData(ClientOperationsType.SendBattleTurn, opHandler.GetBytes(moveData)));


            // Send the message to the connected TcpServer.
            this.WriteData(data);

            this.BattleStatus = BattleStatus.Wait;
        }
Beispiel #3
0
        public void ProcessBattleMove(ClientMessage data)
        {
            var opHandler = new OperationDataHandler();

            BattleMoveData moveData = opHandler.TranslateObject <BattleMoveData>(data.Operation.OperationData);

            Battle battleToProcess = this.ActiveBattles.FirstOrDefault(x => x.BattleId.Equals(moveData.BattleId));

            if (battleToProcess != null)
            {
                battleToProcess.MakeMove(data.Client, moveData.Attack, moveData.Defence, moveData.TargetName);

                if (battleToProcess.IsBattleEnded)
                {
                    this.ActiveBattles.Remove(battleToProcess);
                    battleToProcess = null;
                }
            }
        }