Exemple #1
0
        static void Main(string[] args)
        {
            // Let's try singing about a Farm Animal
            // Put them all in a collection and sing the entire song
            List <ISingable> singableObjects = new List <ISingable>();

            Object obj = new Horse();

            singableObjects.Add(new Horse());
            // Let's create a couple more animals. Maybe a Pig, Dog, Cow, Chicken?
            singableObjects.Add(new Cow());
            singableObjects.Add(new Chicken(4.0M, 30.00M));
            singableObjects.Add(new Tractor());
            singableObjects.Add(new Pig(120M, 400.00M));
            singableObjects.Add(new Sheep());
            foreach (ISingable singable in singableObjects)
            {
                SingVerse(singable);

                if (singable is ISellable)
                {
                    ISellable thingToSell = (ISellable)singable;
                    thingToSell.Sell();
                }
            }

            // What if Farm Animals are to be sold? (add a weight and a price)

            // What if we want to sell Produce?

            Console.ReadLine();
        }
Exemple #2
0
    private void Update()
    {
        if (!playerEntered)
        {
            return;
        }

        if (Input.GetKeyDown(KeyCode.W) && canBePurchased)
        {
            int currentPoints = PlayerPoints.instance.GetPoints();

            if (itemPrice <= currentPoints)
            {
                itemToSell.Sell(player);
                PlayerPoints.instance.AddPoints(-itemPrice);
                canBePurchased  = false;
                itemIcon.sprite = null;
                priceText.text  = "XXXX";
            }
            else
            {
                Debug.Log("This item can't be purchased!");
            }
        }
    }
 public void SellDev(Node node)
 {
     selling.Sell(node.dev);
     node.dev = null;
 }