예제 #1
0
        public static Direction DirectionTo(Germ item1, Rectangle item2)
        {
            Point middlePoint1 = new Point((int)item1.Position.X + item1.FrameSize.X / 2, (int)item1.Position.Y + item1.FrameSize.X / 2);
            Point middlePoint2 = new Point((int)item2.X + item2.X / 2, (int)item2.Y + item2.X / 2);

            if (item1.Position.X < middlePoint2.X &&
                middlePoint2.X < item1.Position.X + item1.FrameSize.X)
            {
                if (middlePoint1.Y < middlePoint2.Y)
                {
                    return(Direction.South);
                }
                if (middlePoint1.Y > middlePoint2.Y)
                {
                    return(Direction.North);
                }
            }
            if (middlePoint1.X < middlePoint2.X)
            {
                return(Direction.East);
            }
            if (middlePoint1.X > middlePoint2.X)
            {
                return(Direction.West);
            }


            return(Direction.East);
        }
예제 #2
0
        public Mission(string targetDescript, int numberRandoms, int protectors, Germ target)
        {
            Germs    = new List <Germ>();
            random   = new Random();
            Ready    = false;
            Finished = false;


            currentStep  = 0;
            resetTime    = 30;
            timeTillNext = resetTime;
            timeForTyper = 300;
            countDown    = false;
            tempTime     = 300;

            this.targetDescript = targetDescript;
            Germs.Add(target);
            System.Threading.Thread.Sleep(100);
            int germType = 0;

            for (int i = 0; i < numberRandoms; i++)
            {
                germType = random.Next(0, 6);

                switch (germType)
                {
                case 0:
                    Germs.Add(new Germ(Game1.Textures["BarGuy"], "BarGuy"));
                    break;

                case 1:
                    Germs.Add(new Germ(Game1.Textures["ClassyGuy"], "ClassyGuy"));
                    break;

                case 2:
                    Germs.Add(new Germ(Game1.Textures["MustacheGuy"], "MustacheGuy"));
                    break;

                case 3:
                    Germs.Add(new Germ(Game1.Textures["SuitGuy"], "SuitGuy"));
                    break;

                case 4:
                    Germs.Add(new Germ(Game1.Textures["Regular1"], "Regular"));
                    break;

                case 5:
                    Germs.Add(new Germ(Game1.Textures["Regular2"], "Regular"));
                    break;

                case 6:
                    Germs.Add(new Germ(Game1.Textures["Regular3"], "Regular"));
                    break;
                }
                System.Threading.Thread.Sleep(80);
            }

            Protectors = new List <Germ>();
            for (int i = 0; i < protectors; i++)
            {
                Protectors.Add(new Germ(Game1.Textures["SuitGuy"], "Protectors"));
                System.Threading.Thread.Sleep(30);
            }
        }