Exemple #1
0
        public string ManufactureTank(string name, double attackPoints, double defensePoints)
        {
            Tank tank    = null;
            var  message = string.Format(OutputMessages.MachineExists, name);

            if (!this.machineRepository.Contains(name))
            {
                tank = (Tank)tankFactory.Create(name, attackPoints, defensePoints);
                this.machineRepository.AddUnit(tank);

                message = string.Format(OutputMessages.TankManufactured,
                                        tank.Name, tank.AttackPoints, tank.DefensePoints);
            }

            return(message);
        }
        protected override void Run(ETModel.Session session, B2C_CreateTanks message)
        {
            Log.Warning("收到消息 B2C_CreateTanks");

            Log.Warning("进入战场,坦克数量=" + message.Tanks.Count);

            TankComponent tankComponent = ETModel.Game.Scene.GetComponent <TankComponent>();

            // 第一次进入战场,先创建自己坦克(创建其他坦克时需要判断与自己坦克关系,所以先创建自己坦克)
            if (tankComponent.MyTank == null)
            {
                foreach (TankInfoFirstEnter firstInfo in message.Tanks)
                {
                    TankFrameInfo tankInfo = firstInfo.TankFrameInfo;
                    if (tankInfo.TankId == PlayerComponent.Instance.MyPlayer.TankId)
                    {
                        Vector3 pos = new Vector3(tankInfo.PX * 1f / Tank.m_coefficient, tankInfo.PY * 1f / Tank.m_coefficient,
                                                  tankInfo.PZ * 1f / Tank.m_coefficient);

                        Vector3 rot = new Vector3(tankInfo.RX * 1f / Tank.m_coefficient, tankInfo.RY * 1f / Tank.m_coefficient,
                                                  tankInfo.RZ * 1f / Tank.m_coefficient);
                        Tank tank = TankFactory.Create(firstInfo, pos, rot);
                        break;
                    }
                }
            }

            foreach (TankInfoFirstEnter firstInfo in message.Tanks)
            {
                TankFrameInfo tankInfo = firstInfo.TankFrameInfo;
                if (tankComponent.Get(tankInfo.TankId) != null)
                {
                    continue;
                }

                Vector3 pos = new Vector3(tankInfo.PX * 1f / Tank.m_coefficient, tankInfo.PY * 1f / Tank.m_coefficient,
                                          tankInfo.PZ * 1f / Tank.m_coefficient);

                Vector3 rot = new Vector3(tankInfo.RX * 1f / Tank.m_coefficient, tankInfo.RY * 1f / Tank.m_coefficient,
                                          tankInfo.RZ * 1f / Tank.m_coefficient);

                Tank tank = TankFactory.Create(firstInfo, pos, rot);
            }

            Game.EventSystem.Run(EventIdType.CreateTanksFinish);
        }
Exemple #3
0
        static void Main(string[] args)
        {
            //string Column1 = csvTable.Columns[0].ToString();
            int shot, shot_num = 0;

            Console.WriteLine("Choose your tank:");
            string path             = @"C:\Users\Administrator\source\repos\Wot1\Wot1\TankListForChoose.txt";
            string path_for_tankfac = @"C:\Users\Administrator\source\repos\Wot1\Wot1\ChoosenTanks";

            string[] lines = File.ReadAllLines(path);
            for (int i = 0; i < lines.Length; i++)
            {
                Console.WriteLine(lines[i]);
            }

            int user_tank_num = int.Parse(Console.ReadLine());

            var tank_factory = new TankFactory();

            var tank_Fi = tank_factory.Create(user_tank_num, path_for_tankfac);

            var x = tank_Fi.GetEnumerator();

            x.MoveNext();
            var z = x.Current;

            Console.WriteLine(z.GetInfo());



            /* var battle = new Battle(Tank_Fi, Tank_Sec, new ConsoleLogger());
             *
             * battle.Start();*/

            /*
             * Tank Tank_Fi, Tank_Sec;
             *
             * if (user_tank_num == 1)
             * {
             *   Tank_Fi = new Tank("Obj.907", 325, 410, 2500);
             *   Tank_Sec = new Tank("Chieftain  FV4201 ", 331, 315, 2800);
             * }
             * else
             * {
             *   Tank_Fi = new Tank("Chieftain  FV4201 ", 331, 315, 2800);
             *   Tank_Sec = new Tank("Obj.907", 325, 410, 2500);
             * }
             *
             *
             * Console.WriteLine("Your tank properties: " + Tank_Fi.GetInfo());
             * Console.WriteLine("Enemy tank properties: " + Tank_Sec.GetInfo());
             * Console.WriteLine("Enter 1 if you want to start BATTLE!!!!!");
             * shot = int.Parse(Console.ReadLine());
             * if (shot == 1)
             * {
             *   while (Tank_Sec.Health > 0 && Tank_Fi.Health > 0)
             *   {
             *       Console.WriteLine("Enter armor's matrix number:");
             *       int a_arr_index = int.Parse(Console.ReadLine());
             *       int b_arr_index = int.Parse(Console.ReadLine());
             *       Console.WriteLine(Tank_Fi.MakeShot(Tank_Sec, a_arr_index, b_arr_index));
             *       Console.WriteLine(Tank_Fi.TakeShot(Tank_Sec));
             *       Console.WriteLine("Your tank Health: " + Tank_Fi.Health);
             *       Console.WriteLine("Enemy tank Health: " + Tank_Sec.Health);
             *       shot_num++;
             *
             *   }
             *   if (Tank_Fi.Health > 0)
             *   {
             *       Console.WriteLine($"VICTORY, You won this game, you did {shot_num}  shot!!!! ");
             *
             *   }
             *   else Console.WriteLine($"LOSERRRR!!!! Your opponent won this battle, you did {shot_num}  shot!!!! ");
             * }*/
        }