示例#1
0
        public Snake(Canvas board, int Height, int Width)
        {
            this.board = board;
            width      = Width; height = Height;
            Random pos = new Random();

            this.Body = new List <BodyPart>();
            for (int i = 1; i <= lenght; i++)
            {
                if (this.Body.Count == 0)
                {
                    this.Body.Add(new BodyPart(pos.Next(5, Width), pos.Next(5, Height)));
                }
                else
                {
                    this.Body.Add(new BodyPart(this.Head.position.x, this.Head.position.y + i * 20));
                }
            }
            status              = state.alive;
            CurrentOrientation  = orientation.up;
            this.hasEaten      += Eating;
            this.hasGrown      += Growing;
            this.hasDied       += Dying;
            this.hasOverlapped += Overlapping;
        }
示例#2
0
        static void Main(string[] args)
        {
            byte   directionByte;
            string directionString;

            orientation myDirection = orientation.north;

            WriteLine($"myDirection = {myDirection}");

            directionByte   = (byte)myDirection;
            directionString = Convert.ToString(myDirection);

            WriteLine($"byte equivalent = {directionByte}");
            WriteLine($"string equivalent = {directionString}");

            byte myByte = 5;

            myDirection = (orientation)myByte;
            WriteLine($"myDirection = {myDirection}");

            myDirection = (orientation)Enum.Parse(typeof(orientation), "east");
            WriteLine($"myDirection = {myDirection}");

            byte x = (byte)Enum.Parse(typeof(orientation), "south");

            WriteLine($"x = {x}");

            ReadKey();
        }
示例#3
0
        public void update(SFML.Graphics.RenderWindow window, orientation orientation, List<IObject> list, Stopwatch touch, Stopwatch shot)
        {
            if (orientation == orientation.vertical)
                _sprite.Position = new SFML.Window.Vector2f(_sprite.Position.X, _sprite.Position.Y + 0.05f + (_fireRate / 10));
            else if (orientation == orientation.horizontal)
                _sprite.Position = new SFML.Window.Vector2f(_sprite.Position.X + 0.05f + (_fireRate / 10), _sprite.Position.Y);

            for (var x = 0; x < list.Count; x++)
                {
                    if (list[x].isEnemy())
                    {
                        if ((orientation == orientation.vertical
                            && (list[x]._sprite.Position.X <= _sprite.Position.X
                            && _sprite.Position.X  <= list[x]._sprite.Position.X + 32)
                            && list[x]._sprite.Position.Y > _sprite.Position.Y)
                            || (orientation == orientation.horizontal
                            && (list[x]._sprite.Position.Y <= _sprite.Position.Y
                            && _sprite.Position.Y <= list[x]._sprite.Position.Y + 32)
                            && list[x]._sprite.Position.X < _sprite.Position.X))
                        {
                            list.RemoveAt(x);
                            list.Remove(this);
                        }
                    }
                }
        }
        static void Main(string[] args)
        {
            byte   directionByte;
            string directionString;

            orientation myDirection = orientation.north;

            WriteLine($"myDirection = {myDirection}");

            directionByte   = (byte)myDirection;
            directionString = Convert.ToString(myDirection); // Or
            directionString = myDirection.ToString();

            WriteLine($"byte equivalent = {directionByte}");
            WriteLine($"string equivalent = {directionString}");

            myDirection = (orientation)3;
            WriteLine($"byte -> orientation type: 3 -> {myDirection}");

            directionString = "west";

            myDirection = (orientation)Enum.Parse(typeof(orientation), directionString);
            WriteLine($"string -> orientation type: \"west\" -> {myDirection}");
            ReadKey();
        }
示例#5
0
        public void direction_key(orientation key)
        {
            Figure change_matrix;

            switch (key)
            {
            case (orientation.down):
                change_matrix = new Figure(figure1.move(0, 1));
                moved_down    = true;
                break;

            case (orientation.up):
                change_matrix = new Figure(figure1.move());
                moved_down    = false;
                break;

            case (orientation.right):
                change_matrix = new Figure(figure1.move(1, 0));
                moved_down    = false;
                break;

            case (orientation.left):
                change_matrix = new Figure(figure1.move(-1, 0));
                moved_down    = false;
                break;

            default:
                change_matrix = figure1;
                moved_down    = false;
                break;
            }
            handle_changes(field1, change_matrix, figure1);
        }
示例#6
0
        private void drawSelfArrow(int state, orientation or, Pen pen)
        {
            pen.Width  = 7F;
            pen.EndCap = LineCap.ArrowAnchor;
            Point location = statePosition[state];

            switch (or)
            {
            case orientation.North:
                location.X -= 15;
                location.Y -= 40;
                g.DrawArc(pen, location.X, location.Y, 40F, 40F, 180F, 200F);
                break;

            case orientation.South:
                location.X -= 15;
                g.DrawArc(pen, location.X, location.Y, 40F, 40F, 180F, -200F);
                break;

            case orientation.East:
                location.Y -= 20;
                g.DrawArc(pen, location.X, location.Y, 40F, 40F, 260F, 200F);
                break;

            case orientation.West:
                break;
            }
        }
        static void Main(string[] args)
        {
            orientation myDirection = orientation.north;

            Console.WriteLine("myDirection = {0}", myDirection);
            Console.ReadKey();
        }
示例#8
0
        private static forIntersectionPoint intersect_(edge e1, edge e2, out double t)
        {
            point  a     = e1.source;
            point  b     = e1.dest;
            point  c     = e2.source;
            point  d     = e2.dest;
            point  n     = new point(d.y - c.y, c.x - d.x);
            double denom = dotProduct(n, new point(b.x - a.x, b.y - a.y));

            if (denom == 0)
            {
                t = double.MaxValue;
                orientation aclass = classify(e1.source, e2);
                if (aclass == orientation.Left || aclass == orientation.Right)
                {
                    return(forIntersectionPoint.Parallel);
                }
                else
                {
                    return(forIntersectionPoint.Collinear);
                }
            }
            double num = dotProduct(n, new point(a.x - c.x, a.y - c.y));

            t = -num / denom;
            return(forIntersectionPoint.Skew);
        }
示例#9
0
文件: sensor.cs 项目: shaunleeyx/temp
    public sensor(double input, int dir, int[,] grid)
    {
        this.grid = grid;
        switch (dir)
        {
        case 0:
            orientationState = orientation.Up;
            break;

        case 1:
            orientationState = orientation.Down;
            break;

        case 2:
            orientationState = orientation.Right;
            break;

        case 3:
            orientationState = orientation.Left;
            break;

        default:
            orientationState = orientation.Up;
            break;
        }
        if (input > 100 || input < 0)
        {
            input = 1;
        }
        battery   = 100;
        drainRate = input;
        state     = true;
    }
示例#10
0
        public void Show()
        {
            Console.WriteLine(@"
С учетом приведенного ниже определения для типа перечисления orientation 
напишите приложение, использующее технологию структурной обработки 
исключений (SEH) для безопасного приведения переменной типа byte к orientation. 
(Примечание: принудительную генерацию исключений можно выполнить с помощью 
ключевого слова checked, как указано ниже в примере. Обязательно используйте
этот код в приложении.)
                            ");
            Console.WriteLine("The values from 1 to 4 provide programm wright work,\nand other value get exeption\n");
            for (byte i = 1; i <= Enum.GetNames(typeof(orientation)).Length; i++)
            {
                myByte = i;
                try
                {
                    myDirection = checked ((orientation)myByte);
                    if (myDirection > orientation.west || myDirection < orientation.north)
                    {
                        throw new InvalidCastException("Faild convertion!");
                    }
                    else
                    {
                        Console.WriteLine("No exeption of type conversion of byte \"{0}\" to orientation \"{1}\"\n", myByte, myDirection);
                    }
                }
                catch (InvalidCastException e)
                {
                    Console.WriteLine("Exeption: {0}\n", e.ToString());
                }
            }
        }
        static void Main(string[] args)
        {
            byte        DirectionByte;
            string      DirectionString;
            orientation myDirection = orientation.north;

            WriteLine($"myDirection = {myDirection}");
            DirectionByte   = (byte)myDirection;
            DirectionString = myDirection.ToString();
            WriteLine($"byte equivalent = {DirectionByte}");
            WriteLine($"string equivalent = {DirectionString}");

            // loop enum values
            foreach (var i in Enum.GetValues(typeof(orientation)))
            {
                Console.WriteLine(i);
            }

            foreach (ConsoleColor color in Enum.GetValues(typeof(ConsoleColor)))
            {
                Console.ForegroundColor = color;
                Console.WriteLine($"Foreground Color set to {color}");
            }

            Console.WriteLine(typeof(System.ComponentModel.DisplayNameAttribute));
        }
示例#12
0
        public void update(SFML.Graphics.RenderWindow window, orientation orientation, List <IObject> list, Stopwatch touch, Stopwatch shot)
        {
            if (orientation == orientation.vertical)
            {
                _sprite.Position = new SFML.Window.Vector2f(_sprite.Position.X, _sprite.Position.Y + 0.05f + (_fireRate / 10));
            }
            else if (orientation == orientation.horizontal)
            {
                _sprite.Position = new SFML.Window.Vector2f(_sprite.Position.X + 0.05f + (_fireRate / 10), _sprite.Position.Y);
            }

            for (var x = 0; x < list.Count; x++)
            {
                if (list[x].isEnemy())
                {
                    if ((orientation == orientation.vertical &&
                         (list[x]._sprite.Position.X <= _sprite.Position.X &&
                          _sprite.Position.X <= list[x]._sprite.Position.X + 32) &&
                         list[x]._sprite.Position.Y > _sprite.Position.Y) ||
                        (orientation == orientation.horizontal &&
                         (list[x]._sprite.Position.Y <= _sprite.Position.Y &&
                          _sprite.Position.Y <= list[x]._sprite.Position.Y + 32) &&
                         list[x]._sprite.Position.X < _sprite.Position.X))
                    {
                        list.RemoveAt(x);
                        list.Remove(this);
                    }
                }
            }
        }
示例#13
0
    /*
     * Precondition:string and double
     * Postcondition:filename is str and 2d array copies the file,double sets the drainRate for the battery for the sensor
     */
    public robot(string str, double drainRate)
    {
        if (str == null)
        {
            throw new ArgumentNullException("invalid file");
        }
        orientationState = orientation.Up;
        filename         = str;
        grid             = new int[SIZE, SIZE];
        count            = 0;
        upSensor         = new sensor(drainRate, 0, grid);
        downSensor       = new sensor(drainRate, 1, grid);
        rightSensor      = new sensor(drainRate, 2, grid);
        leftSensor       = new sensor(drainRate, 3, grid);
        nAct             = new actuator(0);
        sAct             = new actuator(1);
        eAct             = new actuator(2);
        wAct             = new actuator(3);
        rCoord           = 5;
        cCoord           = 5;
        state            = true;
        string text = System.IO.File.ReadAllText(filename);
        string ss   = text.Replace("\n", " ");

        ss = string.Join(" ", ss.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries));
        string[] arr = ss.Split(' ');
        for (int r = 0; r <= 10; r++)
        {
            for (int c = 0; c <= 10; c++)
            {
                grid[r, c] = Int32.Parse(arr[count]);;
                count++;
            }
        }
    }
示例#14
0
 public void Show()
 {
     Console.WriteLine(@"
     С учетом приведенного ниже определения для типа перечисления orientation
     напишите приложение, использующее технологию структурной обработки
     исключений (SEH) для безопасного приведения переменной типа byte к orientation.
     (Примечание: принудительную генерацию исключений можно выполнить с помощью
     ключевого слова checked, как указано ниже в примере. Обязательно используйте
     этот код в приложении.)
                     ");
     Console.WriteLine("The values from 1 to 4 provide programm wright work,\nand other value get exeption\n");
     for (byte i = 1; i <= Enum.GetNames(typeof(orientation)).Length; i++)
     {
         myByte = i;
         try
         {
            myDirection = checked((orientation)myByte);
            if (myDirection > orientation.west || myDirection < orientation.north)
             {
                 throw new InvalidCastException("Faild convertion!");
             }
             else
             {
                 Console.WriteLine("No exeption of type conversion of byte \"{0}\" to orientation \"{1}\"\n", myByte, myDirection);
             }
         }
         catch (InvalidCastException e)
         {
             Console.WriteLine("Exeption: {0}\n", e.ToString());
         }
     }
 }
示例#15
0
 void                    Start()
 {
     _footmanAnimator   = GetComponent <Animator> ();
     FootmanOrientation = (footman.orientation)Random.Range(0, 7);
     _setCurrentAnimation();
     _selectedImage = transform.GetChild(0).GetChild(0).gameObject.GetComponent <Image>();
 }
示例#16
0
 public Node(worldObject _thing, terrainType _walk, Vector3Int _worldPos, orientation _dir)
 {
     placedThing        = _thing;
     walkable           = _walk;
     worldSpacePosition = _worldPos;
     texture            = 1;
     direction          = _dir;
 }
        public void update(SFML.Graphics.RenderWindow window, orientation orientation, List<IObject> list, Stopwatch touch, Stopwatch shot)
        {
            if (orientation == orientation.vertical)
                _sprite.Position = new SFML.Window.Vector2f(_sprite.Position.X, _sprite.Position.Y + 0.03f);
            else if (orientation == orientation.horizontal)
                _sprite.Position = new SFML.Window.Vector2f(_sprite.Position.X + 0.03f, _sprite.Position.Y);

            if (_sprite.Position.X > window.Size.X || _sprite.Position.Y > window.Size.Y)
                list.Remove(this);
        }
示例#18
0
 public Area(int x, int y, int h, int w, orientation or, buildingTypeEnum areaType)
 {
     this.height   = h;
     this.width    = w;
     this.x        = x;
     this.y        = y;
     this.dir      = or;
     this.areaType = areaType;
     this.depth    = 1;
 }
示例#19
0
 public Area(int x, int y, int h, int w, orientation or, int depth)
 {
     this.height   = h;
     this.width    = w;
     this.x        = x;
     this.y        = y;
     this.dir      = or;
     this.areaType = buildingTypeEnum.BUILDING;
     this.depth    = depth;
 }
    // Use this for initialization
    void Start()
    {
        building     = ObjectToCreate.GetComponent <Building>();
        Dimension    = building.getDimensions();
        _orientation = orientation.South;
        this.GetComponent <MeshFilter>().sharedMesh = ObjectToCreate.GetComponent <MeshFilter>().sharedMesh;

        transform.localScale = ObjectToCreate.transform.localScale;

        _orientation = orientation.South;
    }
示例#21
0
 // Update is called once per frame
 void FixedUpdate()
 {
     //print (reciever.isReady ());
     if (reciever.isReady())
     {
         print("Ready");
         orientation pos = reciever.getOrientation();
         rb.position = new Vector3(pos.xPos, rb.position.y, pos.yPos);
         rb.rotation = Quaternion.Euler(0, pos.angle, 0);
         pushPosition();
         rb.velocity = calcVelocity();
     }
 }
示例#22
0
        static void Main(string[] args)
        {
            sbyte       orienSbyte;
            string      myOrien;
            orientation myOrientation = orientation.east;

            Console.WriteLine($"The direction = {myOrientation}\n");
            orienSbyte = (sbyte)myOrientation;
            Console.WriteLine($"My direction index = {orienSbyte}\n");
            myOrien = Convert.ToString(myOrientation);
            Console.WriteLine($"Orientation associated with this index = {myOrien}");
            Console.ReadKey();
        }
示例#23
0
        static void Main(string[] args)
        {
            byte        directionByte;
            string      directionString;
            orientation myDirection = orientation.north;

            WriteLine($"myDirection = {myDirection}");
            directionByte   = (byte)myDirection;
            directionString = Convert.ToString(myDirection);
            WriteLine($"byte equivalent = {directionByte}");
            WriteLine($"string equivalent = {directionString}");
            ReadKey();
        }
示例#24
0
        static void Main(string[] args)
        {
            byte        directionByte;
            string      directionString;
            orientation myDirection = orientation.north;

            Console.WriteLine("myDirection = {0}", myDirection);
            directionByte   = (byte)myDirection;
            directionString = Convert.ToString(myDirection);
            Console.WriteLine("byte equivalent = {0}", directionByte);
            Console.WriteLine("string equivalent = {0}", directionString);
            Console.ReadKey();
        }
        private Orientation Translate(orientation orientation)
        {
            switch (orientation)
            {
            case orientation.vertical:
                return(Orientation.Vertical);

            case orientation.horizontal:
                return(Orientation.Horizontal);

            default:
                throw new ArgumentOutOfRangeException(nameof(orientation), orientation, null);
            }
        }
示例#26
0
        public void Update(SFML.Graphics.RenderWindow window, orientation orientation, List <IObject> list, Stopwatch touch, Stopwatch shot)
        {
            if (SFML.Window.Keyboard.IsKeyPressed(SFML.Window.Keyboard.Key.Left) && (_sprite.Position.X - 0.1f > 0))
            {
                _sprite.Position = new SFML.Window.Vector2f(_sprite.Position.X - 0.1f, _sprite.Position.Y);
            }
            else if (SFML.Window.Keyboard.IsKeyPressed(SFML.Window.Keyboard.Key.Right) && (_sprite.Position.X + 0.1f < window.Size.X - 32)) // !!! Moins la taille du sprite
            {
                _sprite.Position = new SFML.Window.Vector2f(_sprite.Position.X + 0.1f, _sprite.Position.Y);
            }
            else if (SFML.Window.Keyboard.IsKeyPressed(SFML.Window.Keyboard.Key.Up) && (_sprite.Position.Y - 0.1f > 0))
            {
                _sprite.Position = new SFML.Window.Vector2f(_sprite.Position.X, _sprite.Position.Y - 0.1f);
            }
            else if (SFML.Window.Keyboard.IsKeyPressed(SFML.Window.Keyboard.Key.Down) && (_sprite.Position.Y + 0.1f < window.Size.Y - 32))
            {
                _sprite.Position = new SFML.Window.Vector2f(_sprite.Position.X, _sprite.Position.Y + 0.1f);
            }
            if (SFML.Window.Keyboard.IsKeyPressed(SFML.Window.Keyboard.Key.Space))
            {
                if (touch.ElapsedMilliseconds >= 200)
                {
                    list.Add(new Shot(_sprite.Position, _userShipData._weaponSprite, _userShipData._damage, _userShipData._fireRate));
                    touch.Restart();
                }
            }

            for (var x = 0; x < list.Count; x++)
            {
                if (list[x].isEnemy())
                {
                    if (list[x]._sprite.Position.X <= _sprite.Position.X &&
                        _sprite.Position.X <= list[x]._sprite.Position.X + 32 &&
                        list[x]._sprite.Position.Y <= _sprite.Position.Y &&
                        _sprite.Position.Y <= list[x]._sprite.Position.Y + 32)
                    {
                        if (shot.ElapsedMilliseconds >= 200)
                        {
                            _life--;
                            if (_life <= 0)
                            {
                                list.Remove(this);
                            }
                            shot.Restart();
                        }
                    }
                }
            }
        }
示例#27
0
    //what is the neighbour of this grid if I move at orientation o?
    public grid_node get_neighbour(grid_node n, orientation o)
    {
        V2Int     nb_pos = n.grid_position + (V2Int)orient[o];
        grid_node nb     = nodes.Find(such_node => such_node.grid_position == nb_pos);

        if (nb != null)
        {
            if (walkable(nb))
            {
                return(nb);
            }
        }

        return(null);
    }
示例#28
0
        static void Main(string[] args)
        {
            // Commented code is for the second part the of the Try it Out.
            //byte directionByte;
            //string directionString;
            orientation myDirection = orientation.north;

            Console.WriteLine("myDirection = {0}", myDirection);
            //directionByte = (byte)myDirection;
            //directionString = Convert.ToString(myDirection);
            //Console.WriteLine("byte equivalent = {0}", directionByte);
            //Console.WriteLine("string equivalent = {0}", directionString);

            Console.ReadKey();
        }
        public void update(SFML.Graphics.RenderWindow window, orientation orientation, List <IObject> list, Stopwatch touch, Stopwatch shot)
        {
            if (orientation == orientation.vertical)
            {
                _sprite.Position = new SFML.Window.Vector2f(_sprite.Position.X, _sprite.Position.Y + 0.03f);
            }
            else if (orientation == orientation.horizontal)
            {
                _sprite.Position = new SFML.Window.Vector2f(_sprite.Position.X + 0.03f, _sprite.Position.Y);
            }

            if (_sprite.Position.X > window.Size.X || _sprite.Position.Y > window.Size.Y)
            {
                list.Remove(this);
            }
        }
示例#30
0
        static void Main(string[] args)
        {
            byte        directionByte;
            string      directionString;
            orientation myDirection = orientation.north;

            WriteLine($"myDirection = {myDirection}");

            directionByte = (byte)myDirection;
            // These 2 assignments to string produce the same result.
            //directionString = Convert.ToString(myDirection);
            directionString = myDirection.ToString();
            WriteLine($"byte equivalent = {directionByte}");
            WriteLine($"string equivalent = {directionString}");
            ReadKey();
        }
示例#31
0
        static void Main(string[] args)
        {
            // Vars
            byte   directionByte;
            string directionString;

            // Set the orientation and output it
            orientation myDirection = orientation.north;

            WriteLine($"myDirection = {myDirection}");

            // Convert the enum to byte and string and output both
            directionByte   = (byte)myDirection;
            directionString = Convert.ToString(myDirection);
            WriteLine($"byte equivalent = {directionByte}");
            WriteLine($"string equivalent = {directionString}");
        }
示例#32
0
    private void Update()
    {
        switch (Input.deviceOrientation)
        {
        case DeviceOrientation.LandscapeLeft:
            lastOrientation = orientation.LANDSCAPELEFT;
            break;

        case DeviceOrientation.LandscapeRight:
            lastOrientation = orientation.LANDSCAPERIGHT;
            break;

        case DeviceOrientation.Portrait:
            lastOrientation = orientation.PORTRAIT;
            break;
        }
    }
示例#33
0
        public static void Main(string[] args)
        {
            double number      = 3.14;
            int    number2     = (int)number;
            float  floatingNum = checked ((float)number);

            Console.WriteLine(Convert.ToString("Hello World!"));
            orientation direction = orientation.North;

            Console.WriteLine(Convert.ToString(direction));
            Console.WriteLine("This is the number {0}", floatingNum);
            Console.WriteLine((orientation)2);

            string myString = "North";

            direction = (orientation)Enum.Parse(typeof(orientation), myString);
            Console.WriteLine(direction);

            route myRoute;

            myRoute.direction = orientation.North;
            myRoute.distance  = Convert.ToDouble(Console.ReadLine());

            Console.WriteLine("myRoute specifies a direction of {0}" + " and a distance of {1}", myRoute.direction, myRoute.distance);

            int[] myIntArray1 = { 1, 2, 3, 4 };
            int[] myIntArray2 = new int[5];
            int[] myIntArray3 = new int[3] {
                1, 2, 3
            };

            const int ArraySize = 3;             //must be const if specifying array size

            int[] myIntArray4 = new int[ArraySize] {
                1, 2, 3
            };

            Console.WriteLine(myIntArray4.Length);

            string[] names = { "John", "Mike", "Susan" };
            foreach (string name in names)
            {
                Console.WriteLine(name);
            }
        }
        public void Update(SFML.Graphics.RenderWindow window, orientation orientation, List<IObject> list, Stopwatch touch, Stopwatch shot)
        {
            if (SFML.Window.Keyboard.IsKeyPressed(SFML.Window.Keyboard.Key.Left) && (_sprite.Position.X - 0.1f > 0))
                _sprite.Position = new SFML.Window.Vector2f(_sprite.Position.X - 0.1f, _sprite.Position.Y);
            else if (SFML.Window.Keyboard.IsKeyPressed(SFML.Window.Keyboard.Key.Right) && (_sprite.Position.X + 0.1f < window.Size.X - 32)) // !!! Moins la taille du sprite
                _sprite.Position = new SFML.Window.Vector2f(_sprite.Position.X + 0.1f, _sprite.Position.Y);
            else if (SFML.Window.Keyboard.IsKeyPressed(SFML.Window.Keyboard.Key.Up) && (_sprite.Position.Y - 0.1f > 0))
                _sprite.Position = new SFML.Window.Vector2f(_sprite.Position.X, _sprite.Position.Y - 0.1f);
            else if (SFML.Window.Keyboard.IsKeyPressed(SFML.Window.Keyboard.Key.Down) && (_sprite.Position.Y + 0.1f < window.Size.Y - 32))
                _sprite.Position = new SFML.Window.Vector2f(_sprite.Position.X, _sprite.Position.Y + 0.1f);
            if (SFML.Window.Keyboard.IsKeyPressed(SFML.Window.Keyboard.Key.Space))
            {
                if (touch.ElapsedMilliseconds >= 200)
                {
                    list.Add(new Shot(_sprite.Position, _userShipData._weaponSprite, _userShipData._damage, _userShipData._fireRate));
                    touch.Restart();
                }
            }

            for (var x = 0; x < list.Count; x++)
            {
                if (list[x].isEnemy())
                {
                    if (list[x]._sprite.Position.X <= _sprite.Position.X
                    && _sprite.Position.X <= list[x]._sprite.Position.X + 32
                    && list[x]._sprite.Position.Y <= _sprite.Position.Y
                    && _sprite.Position.Y <= list[x]._sprite.Position.Y + 32)
                    {
                        if (shot.ElapsedMilliseconds >= 200)
                        {
                            _life--;
                            if (_life <= 0)
                                list.Remove(this);
                            shot.Restart();
                        }
                    }
                }
            }
        }
示例#35
0
        public Prbl(int dimx, int dimy, int startx = 5, int starty = 14, orientation starto = orientation.up, int goalx = 30, int goaly = 30)
        {
            dx = dimx;
            dy = dimy;
            costs = new double[dx , dy ];
            for (int i = 0; i < dx; i++)
                for (int j = 0; j < dy; j++)
                {
                    costs[i, j] = 1;
                }
            for (int o = 0; o < 8; o++)
            {
                orientation ori = (orientation)o;

                states[ori] = new state[dx, dy];
                for (int i = 0; i < dx; i++)
                    for (int j = 0; j < dy; j++)
                    {
                        states[ori][i, j] = new state(i, j, double.PositiveInfinity, double.PositiveInfinity, ori);// { x = i, y = j, a = ori };
                    }
            }
            current = states[starto][startx, starty];
            goal = states[orientation.down][goalx, goaly];
        }