コード例 #1
0
        static void Main(string[] args)
        {
            Unit mu = new MilitaryUnit(2, 100, 50);
            Unit su = new SettlerUnit(5, 25);

            mu.Move(new Vector2(2, -7));
            su.Move(new Vector2(-1, 4));

            Console.WriteLine(mu);
            Console.WriteLine(su);
        }
コード例 #2
0
        static void Main(string[] args)
        {
            Random rnd = new Random();

            int movement = rnd.Next();

            Unit u1 = new MilitaryUnit(movement);
            Unit u2 = new SettlerUnit(movement);

            u1.Move();
            Console.WriteLine("Health = " + u1.Health + " Value = " + u1.Value);
            Console.WriteLine();
            u2.Move();
            Console.WriteLine("Health = " + u2.Health + " Value = " + u2.Value);
        }
コード例 #3
0
        static void Main(string[] args)
        {
            Unit[] units = new Unit[2];

            units[0] = new MilitaryUnit(3, 10, 100);
            units[1] = new SettlerUnit(1, 2);

            foreach (Unit u in units)
            {
                Console.WriteLine(u);
                u.Move();
                Console.WriteLine($"Health = {u.Health}");
                Console.WriteLine($"Value  = {u.Value}");
                Console.WriteLine("---------");
            }

            Console.WriteLine("Thank you for using this program!");
        }