public void Get()
        {
            // The other part of the client code constructs the actual chain.
            var monkey   = new MonkeyHandler();
            var squirrel = new SquirrelHandler();
            var dog      = new DogHandler();

            monkey.SetNext(squirrel).SetNext(dog);

            // The client should be able to send a request to any handler, not
            // just the first one in the chain.
            Console.WriteLine("Chain: Monkey > Squirrel > Dog\n");
            Client.ClientCode(monkey);
            Console.WriteLine();

            Console.WriteLine("Subchain: Squirrel > Dog\n");
            Client.ClientCode(squirrel);
        }
예제 #2
0
        static void Main(string[] args)
        {
            // Другая часть клиентского кода создает саму цепочку.
            var monkey   = new MonkeyHandler();
            var squirrel = new SquirrelHandler();
            var dog      = new DogHandler();

            monkey.SetNext(squirrel).SetNext(dog);

            // Клиент должен иметь возможность отправлять запрос любому
            // обработчику, а не только первому в цепочке.
            Console.WriteLine("Chain: Monkey > Squirrel > Dog\n");
            ChainOfResponsibilityClient.ClientCode(monkey);
            Console.WriteLine();

            Console.WriteLine("Subchain: Squirrel > Dog\n");
            ChainOfResponsibilityClient.ClientCode(squirrel);

            Console.ReadKey();
        }
예제 #3
0
    void Start()
    {
        mRaycastHits = new RaycastHit[NumberOfRaycastHits];
        mMap         = GetComponentInChildren <Environment>();
        Character.setCharacterType(1);

        //Setting up gameobjects
        paddockProfile = GameObject.Find("PaddockStats");
        actionSprite   = GameObject.Find("Sprite");
        profile        = GameObject.Find("DogStats");
        deletionScreen = GameObject.Find("PaddockDeletion");

        //Setting up gameobjects with the appropriate scripts
        paddockHandle = GameObject.Find("PaddockHandler").GetComponent <PaddockHandler>();
        dog           = GameObject.Find("DogHandler").GetComponent <DogHandler>();
        environment   = GameObject.Find("Environment").GetComponent <Environment>();
        cam           = GameObject.Find("MainCamera").GetComponent <CameraScript>();
        currency      = GameObject.Find("Currency").GetComponent <PlayerCurrency>();
        park          = GameObject.Find("ParkHandler").GetComponent <Park>();
        vis           = GameObject.Find("VisitorHandler").GetComponent <VisitorHandler>();
        decorations   = GameObject.Find("Decoration").GetComponent <Decorations>();
        events        = GameObject.Find("Event").GetComponent <Events>();
        level         = GameObject.Find("Levelling").GetComponent <LevelExp>();

        //Set up the paddock colour - darker green than the tiles
        paddockColor = new Color32(60, 107, 62, 1);
        actionSprite.SetActive(false);

        //Three seperate colours for grass - used for when deleting paths
        grassColours.Add(new Color32(98, 214, 164, 1));
        grassColours.Add(new Color32(122, 221, 159, 1));
        grassColours.Add(new Color32(105, 229, 140, 1));

        pauseScreen.SetActive(false);
        tutorialScreen.SetActive(false);
        deletionScreen.SetActive(false);

        ShowMenu(true);
    }
    // Start is called before the first frame update
    void Start()
    {
        mMap    = GameObject.Find("Environment").GetComponent <Environment>();
        handler = GameObject.Find("DogHandler").GetComponent <DogHandler>();

        //Random names
        names.Add("Rupert");
        names.Add("Spot");
        names.Add("George");
        names.Add("Skye");
        names.Add("Woody");
        names.Add("Willow");
        names.Add("Boomer");
        names.Add("Flynn");
        names.Add("Bobbi");

        //Dog must be set up before moving
        setUpDog();

        //Move the dog as soon as it has been placed
        pickRandomTile();
        moveDog();
    }
예제 #5
0
        static void Main(string[] args)
        {
            var thread = new Thread(SeparateThread);

            Action a1 = SeparateThread;

            Action a2 = delegate { Console.WriteLine("Waddup"); };

            // WILL NOT WORK:
            // var a3 = delegate { Console.WriteLine("Waddup"); };

            // Default is also target-typed.
            int x = default;



            a.GetType();

            Action <Animal> d = Pet;

            d.GetType();

            Action <Dog> a5 = d;

            a5.GetType();
            thread.Start();

            Dog fido = new Dog();

            //read right-to-left:  instance of dog which is a class being assigned to a variable of animal which is a class type
            Animal a = fido;

            //read right-to-left:  instance of a method which is a delegate being assigned to a variable of dog handler which is a delegate type
            DogHandler petter = Pet;

            //var threader = SeparateThread;

            while (false)
            {
                // Update UI
                Thread.Sleep(10);
                Console.WriteLine("Updated UI!");
            }


            Func <Animal, Animal> evolve = Mutate;

            var TMNF = evolve(fido);

            Func <Animal, Chemical, Animal> mutateWithChemical = Mutate;

            {
                var ImTiredOfComingUpWithVariableNames = "yooooo";
                Console.WriteLine(ImTiredOfComingUpWithVariableNames);
            }


            bool TryShop(DogHandler job, int money)
            {
                if (money % 2 == 0)
                {
                    job(fido);
                    return(true);
                }
                return(false);
            }

            //
            DogHandler wrapDog = (dog) =>
            {
                Console.WriteLine("Doggo " + dog + " is being wrapped. Obviously not as cool as " + TMNF);
            };

            TryShop(wrapDog, 1000);

            pendingAction = wrapDog;
        }