示例#1
0
文件: Game.cs 项目: artifexor/TankWar
        public void PlayerFire(Player player)
        {
            var shell = new Shell {
                Id = _shellCounter++, LaunchTime = _time
            };

            shell.Origin = Deep.Clone(player.Tank.ToDto());

            // make the shell appear to come from the correct side of the tank
            shell.Origin.Point.X += Convert.ToInt32(player.Tank.Turret.Angle * Tank.Width / 180);

            player.Shells.Add(shell);
            player.Tank.IsFiring = true;
        }
    static void Main(string[] args)
    {
        var s1 = new Shallow(new Thing(23));
        var s2 = (Shallow)s1.Clone();

        Console.WriteLine(s2.T.I); // 23
        s1.T.I = 9;
        Console.WriteLine(s2.T.I); // 9

        var d1 = new Deep(new Thing(23));
        var d2 = (Deep)d1.Clone();

        Console.WriteLine(d2.T.I); // 23
        d1.T.I = 9;
        Console.WriteLine(d2.T.I); // 23
    }