Beispiel #1
0
        public static void SurfaceAnimals()
        {
            Console.WriteLine("Pterodactyl I am!");
            Pterodactyl pterodactyl = new Pterodactyl();

            Console.WriteLine($"Tail: {pterodactyl.Tail}.");
            Console.WriteLine($"Location: {pterodactyl.Location}.");
            Console.WriteLine($"Feed Cost:${pterodactyl.FeedCost}.");
            Console.WriteLine($"# of Eyes: {pterodactyl.Eyes}.");
            Console.WriteLine($"Are they Safe: {pterodactyl.Safe}.");
            Console.WriteLine($"Flyer: {pterodactyl.Flyer()}.");
            Console.WriteLine($"Eat: {pterodactyl.Eat()}.");
            Console.WriteLine($"Speak: {pterodactyl.Speak()}.");

            Console.WriteLine("");
            Console.WriteLine("Flying-Spider I am!");
            FlyingSpider flyingSpider = new FlyingSpider();

            Console.WriteLine($"Tail: {flyingSpider.Tail}.");
            Console.WriteLine($"Location: {flyingSpider.Location}.");
            Console.WriteLine($"Feed Cost:${flyingSpider.FeedCost}.");
            Console.WriteLine($"# of Eyes: {flyingSpider.Eyes}.");
            Console.WriteLine($"Are they Safe: {flyingSpider.Safe()}.");
            Console.WriteLine($"Flyer: {flyingSpider.Flyer()}.");
            Console.WriteLine($"Eat: {flyingSpider.Eat()}.");
            Console.WriteLine($"Speak: {flyingSpider.Speak()}.");

            //Two Interfaces here!
            Console.WriteLine("");
            Console.WriteLine("T-Rex I am!");
            TRex rex = new TRex();

            Console.WriteLine($"Tail: {rex.Tail}.");
            Console.WriteLine($"Location: {rex.Location}.");
            Console.WriteLine($"Feed Cost:${rex.FeedCost}.");
            Console.WriteLine($"# of Eyes: {rex.Eyes}.");
            Console.WriteLine($"Are they Safe: {rex.Safe}.");
            Console.WriteLine($"Walking: {rex.Walking()}.");
            Console.WriteLine($"Eat: {rex.Eat()}.");
            Console.WriteLine($"Speak: {rex.Speak()}.");
            Console.WriteLine($"Drinking: {rex.Drinking()}.");
            Console.WriteLine($"Interface => Fun Tricks: {rex.FunTricks}.");
            Console.WriteLine($"Interface => Loves Humans: {rex.lovesHumans}.");

            Console.WriteLine("");
            Console.WriteLine("Brontosaurus I am!");
            Brontosaurs brontosaurs = new Brontosaurs();

            Console.WriteLine($"Tail: {brontosaurs.Tail}.");
            Console.WriteLine($"Location: {brontosaurs.Location}.");
            Console.WriteLine($"Feed Cost:${brontosaurs.FeedCost}.");
            Console.WriteLine($"# of Eyes: {brontosaurs.Eyes}.");
            Console.WriteLine($"Are they Safe: {brontosaurs.Safe}.");
            Console.WriteLine($"Walking: {brontosaurs.Walking()}.");
            Console.WriteLine($"Eat: {brontosaurs.Eat()}.");
            Console.WriteLine($"Speak: {brontosaurs.Speak()}.");
            Console.WriteLine($"Drinking: {brontosaurs.Drinking()}.");
        }
Beispiel #2
0
        static async Task Pterodactyl1_0(string host, string key)
        {
            var pterodactyl = new Pterodactyl(host, key);

            var account = await pterodactyl.V1_0.Client.Account.GetAccountAsync();

            Console.WriteLine($"\n Account of the user {account.Username}");
            Console.WriteLine($"\n Email: {account.Email}");
        }
Beispiel #3
0
 override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     ai            = animator.GetComponent <Pterodactyl>();
     perception    = animator.GetComponent <Perception>();
     _Animator     = animator;
     movementSpeed = ai.movementSpeed;
     transform     = animator.transform;
     rigidbody     = animator.GetComponent <Rigidbody2D>();
     retreatSpeed  = ai.retreatSpeed;
 }
Beispiel #4
0
 override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     swoopTimer    = Random.Range(10, 20);
     ai            = animator.GetComponent <Pterodactyl>();
     rigidbody     = ai.GetComponent <Rigidbody2D>();
     movementSpeed = ai.movementSpeed;
     transform     = ai.transform;
     _Animator     = animator;
     aStar         = ai.aStar;
     FindNewPath();
 }
Beispiel #5
0
        private static void DinosaurTests()
        {
            Dinosaur dino1 = new Dinosaur();

            dino1.Size = 10;
            //       dino1.Eat();
            TRex tRex = new TRex();

            tRex.Size = 20;
            //        tRex.Eat();

            Dinosaur dino2 = new TRex();        // upcasting
                                                //       dino2.Eat();

            Dinosaur dino3 = new Pterodactyl(); // upcasting
                                                //      dino3.Eat();

            Dinosaur dino4 = new Dinosaur();

            dino4 = (TRex)tRex;
            //          dino4.Eat();
            dino4 = (Pterodactyl)dino3;
            //           dino4.Eat();
            Dinosaur dino6 = dino3 as Pterodactyl;  // This is a way to test if the object is valid

            dino6.Sleep();

            TRex tRex3 = dino1 as TRex;

            dino1.Sleep();


            Dinosaur[] dinoArray = { dino1, tRex, dino2, dino3 };

            foreach (Dinosaur item in dinoArray)
            {
                if (item is TRex)  //Is there an object with that name
                {
                    item.Eat();
                }
                if (item is Pterodactyl)
                {
                    item.Sleep();
                }
            }
            GenericsList <Dinosaur> dinoList = new GenericsList <Dinosaur>();

            dinoList.Add(dino1);
            dinoList.Add(tRex);
            dinoList.Add(dino2);
            dinoList.Add(dino3);
        }
Beispiel #6
0
        /// <summary>
        /// Runs when the PterodactylMoveEvent fires. It updates the position
        /// of the Control to that of the model.
        /// </summary>
        public void NotifyMoved(object sender, EventArgs e)
        {
            Pterodactyl pterodactyl = sender as Pterodactyl;

            // Determine the endpoint of the move vector
            double xPos = Canvas.GetLeft(this) + pterodactyl.speed * Math.Cos(((pterodactyl.angle + 180) * Math.PI / 180));
            double yPos = Canvas.GetTop(this) + pterodactyl.speed * Math.Sin(((pterodactyl.angle + 180) * Math.PI / 180));

            pterodactyl.coords = new Point(xPos, yPos);

            // Flipping the image to turn left or right
            if (xPos < Canvas.GetLeft(this))
            {
                LayoutTransform = new ScaleTransform()
                {
                    ScaleX = 1
                }
            }
            ;
            else
            {
                LayoutTransform = new ScaleTransform()
                {
                    ScaleX = -1
                }
            };

            // Handles transporting the Control from one side of the screen to the other
            if (xPos > (1440 - Width))
            {
                xPos -= 1440 - Width;
            }
            else if (xPos < 0)
            {
                xPos += 1440 - Width;
            }

            if (yPos >= 0 && yPos <= 900 - (Height * 2))
            {
                Canvas.SetTop(this, yPos);
            }
            Canvas.SetLeft(this, xPos);
        }
Beispiel #7
0
        /// <summary>
        /// Runs when the World.Instance.SpawnPterodactyl fires. It creates the
        /// Pterodactyls.
        /// </summary>
        public void NotifySpawn(object sender, EventArgs e)
        {
            if (!spawned)
            {
                Pterodactyl p = new Pterodactyl();
                p.coords = new Point(0, 0); // *** Set this to a respawn platform ***
                PterodactylControl pCtrl = new PterodactylControl(p.imagePath);

                // Subscribe to the event handlers
                p.PterodactylMoveEvent   += pCtrl.NotifyMoved;
                p.PterodactylStateChange += pCtrl.NotifyState;
                p.PterodactylDestroyed   += pCtrl.NotifyDestroy;

                Canvas.SetTop(pCtrl, p.coords.y);
                Canvas.SetLeft(pCtrl, p.coords.x);
                Canvas canvas = Parent as Canvas;
                canvas.Children.Add(pCtrl);
                spawned = true;
            }
        }
Beispiel #8
0
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        ai                    = animator.GetComponent <Pterodactyl>();
        perception            = animator.GetComponent <Perception>();
        _Animator             = animator;
        movementSpeed         = ai.movementSpeed;
        transform             = animator.transform;
        rigidbody             = animator.GetComponent <Rigidbody2D>();
        aStar                 = ai.aStar;
        ai.OnHit             += Retreat;
        swoopSpeed            = ai.swoopSpeed;
        pathFindingSwoopSpeed = ai.pathFindingSwoopSpeed;

        hasTwoTargets      = SetStartAndEnd();
        reachedFirstTarget = false;
        if (hasTwoTargets)
        {
            FindNewPath();
        }
    }
Beispiel #9
0
        static async Task Pterodactyl0_7(string host, string key)
        {
            var pterodactyl = new Pterodactyl(host, key);

            var servers = await pterodactyl.V0_7.Client.Servers.GetServersAsync();

            var server = servers[0];

            if (server == null)
            {
                throw new PterodactylException("Server not found.");
            }

            var resource = await server.GetResourceAsync();

            Console.WriteLine($"\nServer stats of {server.Name}");
            Console.WriteLine($"CPU: {resource.CPU.Current} / {resource.CPU.Limit}");
            Console.WriteLine($"Memory: {resource.Memory.Current} / {resource.Memory.Limit}");
            Console.WriteLine($"State: {resource.State}");
            Console.WriteLine($"Total Disk: {resource.Disk.Current} / {resource.Disk.Limit}");
        }
Beispiel #10
0
        public static void RunWeek3Classwork()
        {
            //Week 3 in class
            //Deconstructor
            //ClassMaterial.Week1.Week3.Square MySquare0 = new ClassMaterial.Week1.Week3.Square(11,22);


            ClassMaterial.Week1.Week3.Square MySquare = new ClassMaterial.Week1.Week3.Square(3, 3);  //

            //var (length, height) = MySquare;    //

            int length = 5, height = 5;//////////, top = 100;


            MySquare.Deconstruct(out length, out height);                     //////////, out top);

            System.Console.WriteLine("MySquare.Length = " + MySquare.Length); //

            (length, height) = MySquare;

            System.Console.WriteLine("2nd MySquare.Length = " + MySquare.Length);

            //ClassMaterial.Week1.Week3.Square MySquare2 = new ClassMaterial.Week1.Week3.Square(,);

            //MySquare.Deconstruct(out length, out height);

            System.Console.WriteLine(length);  //


            //ClassMaterial.Week1.Week3.Square MySquare3 = new ClassMaterial.Week1.Week3.Square(3,3);


            ClassMaterial.Week1.Week3.Square yourSquare =
                new ClassMaterial.Week1.Week3.Square {
                Length = 5, Height = 5, Color = "Blue"
            };

            Dinosaur dino1 = new Dinosaur();

            dino1.Size = 10;

            TRex tRex = new TRex();

            tRex.Size = 20;

            Dinosaur dino2 = new TRex();  //upcasting

            //Now play with private, public, protected and sealed of the
            //  base and child class to see
            //  what you can access with the dot operator
            dino2.Eat();

            Dinosaur dino3 = new Pterodactyl(); //upcasting

            dino3.Eat();


            Dinosaur dino4 = new Dinosaur();

            dino4 = (TRex)tRex;
            dino4.Eat();
            dino4 = (Pterodactyl)dino3;
            dino4.Eat();

            System.Console.WriteLine("Now let's try an IS:");

            Dinosaur[] dinoArray = { dino1, tRex, dino2, dino3 };

            foreach (Dinosaur item in dinoArray)
            {
                if (item is TRex)
                {
                    item.Eat();
                }

                /*
                 * if( item is Pterodactyl)
                 * {
                 *  item.Sleep();
                 *
                 * }
                 *
                 */
            }

            System.Console.WriteLine(Utility.AddTwoNumbers(10101, 1010));
            System.Console.WriteLine(Utility.AddTwoNumbers(10101, 1010));

            var dinoList = new List <Dinosaur>(10000);

            dinoList.Add(dino1);
            dinoList.Add(tRex);
            dinoList.Add(dino2);
            dinoList.Add(dino3);

            foreach (var item in dinoList)
            {
                Console.WriteLine(item);
            }

            dinoList.ForEach(item => Console.Write(item + ","));

            System.Console.WriteLine("Week3Classwork");
        }
Beispiel #11
0
        /// <summary>
        /// Runs when the PterodactylStateChange fires. It updates the graphic
        /// of the Control to that of the model's state.
        /// </summary>
        public void NotifyState(object sender, EventArgs e)
        {
            Pterodactyl pterodactyl = sender as Pterodactyl;

            Source = new BitmapImage(new Uri(pterodactyl.imagePath, UriKind.Relative));
        }
Beispiel #12
0
        private static void Week3Dinosaurs()
        {
            //Dinosaur examples (week3 topics continued)
            Dinosaur dino1 = new Dinosaur();

            dino1.Size = 10;
            dino1.Eat();  //Dinosaur Eat

            TRex tRex = new TRex();

            tRex.Size = 201;
            tRex.Eat();                         //TRex Eat

            Dinosaur dino2 = new TRex();        //Upcasting (implicit)

            dino2.Eat();                        //TRex Eat

            Dinosaur dino3 = new Pterodactyl(); //Upcasting (implicit)

            dino3.Eat();                        //Pterodactyl Eat

            Dinosaur dino4 = new Dinosaur();    //Downcasting (explicit)

            dino4 = (TRex)tRex;
            dino4.Eat();  //TRex Eat


            /*
             * Console.WriteLine("--------------------------------");
             * Console.WriteLine("..........'as' example..........");
             * Console.WriteLine("--------------------------------");
             * //gives -- Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
             * //basically, trying to test if dino10 is a Pterodactyl.  It isn't, so returns as null
             * Dinosaur dino6 = dino10 as Pterodactyl;
             * dino6.Sleep();
             */

            Console.WriteLine("--------------------------------");
            Console.WriteLine("...array and 'is' example.......");
            Console.WriteLine("--------------------------------");
            Dinosaur[] dinoArray = { dino1, tRex, dino2, dino3 };

            foreach (Dinosaur item in dinoArray)
            {
                if (item is TRex)
                {
                    item.Eat();
                }

                if (item is Pterodactyl)
                {
                    item.Sleep();
                }
            }



            /*
             * Console.WriteLine(tRex.Size);
             * Dinosaur.Raptor dino2 = new Dinosaur.Raptor();
             * dino2.Skin = true;
             * dino2.Eat();
             * //call default constructor with object initializers (optional parameters, default values)
             * Square yourSquare = new Square {Length = 5, Height =5, Color = "Blue"};
             * Console.WriteLine("yourSquare Color is " + yourSquare.Color);
             */


            //deconstructor pattern call

            /*
             *  https://docs.microsoft.com/en-us/dotnet/csharp/deconstruct
             *  https://stackoverflow.com/questions/40906305/c-sharp-7-0-deconstructor
             */
            /*
             * Square mySquare = new Square(3, 3);
             * var (length, height) = mySquare;
             * //the following 2 lines are interchageable with the above "var" line, same result
             * //int l, w;
             * //mySquare.Deconstruct(out l, out w);
             *
             * Console.WriteLine(mySquare.Length);
             * Console.WriteLine(length);
             */
        }
Beispiel #13
0
        public void PterodactylTest2Moving()
        {
            Pterodactyl testTwo = new Pterodactyl();

            Assert.Equal("I like to move it move it", testTwo.Moving());
        }
Beispiel #14
0
        public void PterodactylTest1Speak()
        {
            Pterodactyl testOne = new Pterodactyl();

            Assert.Equal("Kaaaaaaaaahnnnn", testOne.Speak());
        }