コード例 #1
0
        public static void Main()
        {
            var neptune = new Planet("Neptune");

            var ironMine = new IronMine();

            var playerBase = new PlayerBase("TestBase", neptune);

            playerBase.AddComponent(new Storage <IronResource>(1000));
            playerBase.AddComponent(new Storage <PowerResource>(1000));
            playerBase.Buildings.Add(ironMine);

            while (true)
            {
                Console.WriteLine(playerBase);
                Console.WriteLine();
                if (!playerBase.TryBuild(ironMine))
                {
                    break;
                }
            }

            var kestrelAttack = new Attack(20);
            var kestrelHealth = new Health(200);
            var kestrel       = new Ship("Kestrel", kestrelAttack, kestrelHealth);

            var vultureAttack = new Attack(15);
            var vultureHealth = new Health(250);
            var vulture       = new Ship("Vulture", vultureAttack, vultureHealth);

            Console.WriteLine("Before Attack:");
            Console.WriteLine(kestrel);
            Console.WriteLine(vulture);

            kestrel.Attack(vulture);

            Console.WriteLine();
            Console.WriteLine("After Attack:");
            Console.WriteLine(kestrel);
            Console.WriteLine(vulture);
        }
コード例 #2
0
ファイル: Order.cs プロジェクト: ColleaguesME/CommandCenter
        public Order(Village village, string name, int quantity = 1)
        {
            id           = GetId();
            headquarters = new Headquarters();
            timberCamp   = new TimberCamp();
            clayPit      = new ClayPit();
            ironMine     = new IronMine();
            farm         = new Farm();
            warehouse    = new Warehouse();
            rallyPoint   = new RallyPoint();
            barracks     = new Barracks();
            statue       = new Statue();
            wall         = new Wall();
            hospital     = new Hospital();
            market       = new Market();
            tavern       = new Tavern();
            academy      = new Academy();
            hallOfOrders = new HallOfOrders();

            spearman      = new Spearman();
            swordsman     = new Swordsman();
            archer        = new Archer();
            heavyCavalry  = new HeavyCavalry();
            axeFighter    = new AxeFighter();
            lightCavalry  = new LightCavalry();
            mountedArcher = new MountedArcher();
            ram           = new Ram();
            catapult      = new Catapult();


            barracksInfos      = new List <PartialBarracksInfo>();
            farmInfos          = new List <PartialFarmInfo>();
            waitInfos          = new List <PartialWaitInfo>();
            barracksToDateTime = new Dictionary <int, DateTime>();
            stringToEntity     = new Dictionary <string, Entity>()
            {
                { "Headquarters", headquarters },
                { "TimberCamp", timberCamp },
                { "ClayPit", clayPit },
                { "IronMine", ironMine },
                { "Farm", farm },
                { "Warehouse", warehouse },
                { "RallyPoint", rallyPoint },
                { "Barracks", barracks },
                { "Statue", statue },
                { "Wall", wall },
                { "Hospital", hospital },
                { "Market", market },
                { "Tavern", tavern },
                { "Academy", academy },
                { "HallOfOrders", hallOfOrders },

                { "Spearman", spearman },
                { "Swordsman", swordsman },
                { "Archer", archer },
                { "HeavyCavalry", heavyCavalry },
                { "AxeFighter", axeFighter },
                { "LightCavalry", lightCavalry },
                { "MountedArcher", mountedArcher },
                { "Ram", ram },
                { "Catapult", catapult },

                { "init", null }
            };
            barracksToLimit = new Dictionary <int, int>()
            {
                { 1, 5 },
                { 2, 10 },
                { 3, 15 }
            };
            for (int i = 4; i <= 25; i++)
            {
                barracksToLimit.Add(i, int.MaxValue);
            }
            this.name     = name;
            this.quantity = quantity;
            entity        = stringToEntity[name];
            bar           = new OrderBar(this.village = village);
        }