static void Main(string[] args) { Prototype clone = new Character(10, 2); ((Character)clone).TakeDamage(5); Prototype clone2 = clone.Clone(); ((Character)clone2).TakeDamage(2); ((Character)clone).GetCurrentHP(); ((Character)clone2).GetCurrentHP(); //IClonable Enemy enemy = new Enemy(10); Enemy enemy2 = (Enemy)enemy.Clone(); enemy.currentHP -= 2; Console.WriteLine("enemy hp{0}", enemy.currentHP.ToString()); Console.WriteLine("enemy clone hp{0}", enemy2.currentHP.ToString()); Console.ReadLine(); }
static void Main(string[] args) { Enemy RedSlime = new Enemy("Slimey", 10); Enemy GreenSlime = RedSlime.Clone(); Console.WriteLine(RedSlime); Console.WriteLine(GreenSlime); }
private void Update() { if (Input.GetKeyDown(KeyCode.Mouse0)) { Enemy clonedEnemy = enemy1.Clone(); Debug.Log(clonedEnemy.GetDescription()); } else if (Input.GetKeyDown(KeyCode.Mouse1)) { Enemy clonedEnemy = enemy2.Clone(); Debug.Log(clonedEnemy.GetDescription()); } }