示例#1
0
 /// <summary>
 /// Helper method to print player info.
 /// </summary>
 /// <param name="player"></param>
 private static void PrintPlayerInfo(FNPlayer player)
 {
     Console.WriteLine("{0} is {1} => Health is {2} and Weapon is {3}",
                       player.GetType().Name,
                       player.Alive ? "alive" : "dead",
                       player.Health,
                       player.Weapon);
 }
示例#2
0
        /// <summary>
        /// Static method which performs an attack.
        /// </summary>
        /// <param name="p1">Player who performs the attack.</param>
        /// <param name="p2">Player who suffers the attack.</param>
        private static void PerformAttack(FNPlayer p1, FNPlayer p2)
        {
            // Determine player classes
            string p1class = p1.GetType().Name;
            string p2class = p1 != p2?p2.GetType().Name : "himself";

            // Perform attack and show info
            Console.WriteLine($" == {p1class} attacks {p2class} == ");
            p1.Attack(p2);
            Console.WriteLine($"{p1}\n{p2}\n");
        }