コード例 #1
0
ファイル: Program.cs プロジェクト: PenchoPenchev/Exam-Tasks
    protected override Item CreateItem(string itemTypeString, string itemNameString, Location itemLocation, Item item)
    {
        switch (itemTypeString)
        {
        case "weapon":
            item = new Weapon(itemNameString, itemLocation);
            break;

        case "wood":
            item = new WoodItem(itemNameString, itemLocation);
            break;

        case "iron":
            item = new IronItem(itemNameString, itemLocation);
            break;

        default:
            break;
        }

        if (item == null)
        {
            item = base.CreateItem(itemTypeString, itemNameString, itemLocation, item);
        }
        return(item);
    }
コード例 #2
0
ファイル: Program.cs プロジェクト: PenchoPenchev/Exam-Tasks
    private void HandleGatherInteraction(string[] commandWords, Person actor)
    {
        bool hasWeapon = false;
        bool hasArmor  = false;

        foreach (var item in actor.ListInventory())
        {
            if (item is Weapon)
            {
                hasWeapon = true;
            }

            if (item is Armor)
            {
                hasArmor = true;
            }
        }

        Location currentLocation = DetermineActorLocation(actor);

        if (hasWeapon && actor.Location.LocationType == LocationType.Forest)
        {
            Item gatheredItem = new WoodItem(commandWords[2], currentLocation);
            actor.AddToInventory(gatheredItem);
            this.AddToPerson(actor, gatheredItem);
        }

        if (hasArmor && actor.Location.LocationType == LocationType.Mine)
        {
            Item gatheredItem = new IronItem(commandWords[2], currentLocation);
            actor.AddToInventory(gatheredItem);
            this.AddToPerson(actor, gatheredItem);
        }
    }
コード例 #3
0
        public IWoodProduct CreateProduct(WoodItem woodItem)
        {
            IWoodProduct woodProduct = null;

            switch (woodItem)
            {
            case WoodItem.CricketBat:
                woodProduct = new CricketBat();
                break;

            case WoodItem.HockeyStick:
                woodProduct = new HockeyStick();
                break;
            }

            return(woodProduct);
        }
コード例 #4
0
ファイル: TreeManager.cs プロジェクト: sethnel99/HungerGame
    // Use this for initialization
    new void Start()
    {
        base.Start();
        displayName = "Tree";

        lootTables = new Item[1][];
        lootTables[0] = new Item[3];

        lootTables[0][0] = new WoodItem(2);
        lootTables[0][1] = new WoodItem(3);
        lootTables[0][2] = new WoodItem(4);

        lootFrequencyTables = new int[1][];
        lootFrequencyTables[0] = new int[3];

        lootFrequencyTables[0][0] = 20;
        lootFrequencyTables[0][1] = 60;
        lootFrequencyTables[0][2] = 20;

        numberOfItemsDropped = new int[1];
        numberOfItemsDropped[0] = 1;
    }
コード例 #5
0
        private void OnWoodCreated(TableViewModel sender, Wood e)
        {
            var model = new WoodItem(this, e);

            Items.Add(model.ConvertToModel());
        }
コード例 #6
0
ファイル: WoodItem.cs プロジェクト: sethnel99/HungerGame
 public WoodItem(WoodItem other)
     : base(other)
 {
 }
コード例 #7
0
ファイル: Program.cs プロジェクト: NikolovNikolay/Exam-Tasks
    private void HandleGatherInteraction(string[] commandWords, Person actor)
    {
        bool hasWeapon = false;
        bool hasArmor = false;

        foreach (var item in actor.ListInventory())
        {
            if (item is Weapon)
            {
                hasWeapon = true;
            }

            if (item is Armor)
            {
                hasArmor = true;
            }
        }

        Location currentLocation = DetermineActorLocation(actor);

        if (hasWeapon && actor.Location.LocationType == LocationType.Forest)
        {
            Item gatheredItem = new WoodItem(commandWords[2], currentLocation);
            actor.AddToInventory(gatheredItem);
            this.AddToPerson(actor, gatheredItem);
        }

        if (hasArmor && actor.Location.LocationType == LocationType.Mine)
        {
            Item gatheredItem = new IronItem(commandWords[2], currentLocation);
            actor.AddToInventory(gatheredItem);
            this.AddToPerson(actor, gatheredItem);
        }
    }
コード例 #8
0
ファイル: Program.cs プロジェクト: NikolovNikolay/Exam-Tasks
    protected override Item CreateItem(string itemTypeString, string itemNameString, Location itemLocation, Item item)
    {
        switch (itemTypeString)
        {
            case "weapon":
                item = new Weapon(itemNameString, itemLocation);
                break;
            case "wood":
                item = new WoodItem(itemNameString, itemLocation);
                break;
            case "iron":
                item = new IronItem(itemNameString, itemLocation);
                break;
            default:
                break;
        }

        if (item == null)
        {
            item = base.CreateItem(itemTypeString, itemNameString, itemLocation, item);
        }
        return item;
    }