Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Inheritance.MapObjects
- {
- public interface IOwnerable
- {
- int Owner { get; set; }
- }
- public interface ILootable
- {
- Treasure Treasure { get; set; }
- }
- public interface IAttackble
- {
- Army Army { get; set; }
- }
- public class Dwelling : IOwnerable
- {
- public int Owner { get; set; }
- }
- public class Mine : IOwnerable, IAttackble, ILootable
- {
- public int Owner { get; set; }
- public Army Army { get; set; }
- public Treasure Treasure { get; set; }
- }
- public class Creeps : IAttackble, ILootable
- {
- public Army Army { get; set; }
- public Treasure Treasure { get; set; }
- }
- public class Wolfs : IAttackble
- {
- public Army Army { get; set; }
- }
- public class ResourcePile : ILootable
- {
- public Treasure Treasure { get; set; }
- }
- public static class Interaction
- {
- public static void Make(Player player, object mapObject)
- {
- if (mapObject is IAttackble)
- {
- if (player.CanBeat((mapObject as IAttackble).Army))
- {
- if (mapObject is IOwnerable) (mapObject as IOwnerable).Owner = player.Id;
- if (mapObject is ILootable) player.Consume((mapObject as ILootable).Treasure);
- }
- else player.Die();
- }
- else if (mapObject is IOwnerable)
- {
- (mapObject as IOwnerable).Owner = player.Id;
- if (mapObject is ILootable) player.Consume((mapObject as ILootable).Treasure);
- }
- else if (mapObject is ILootable)
- player.Consume((mapObject as ILootable).Treasure);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement