예제 #1
0
        static void Main(string[] args)
        {
            string[] menuiItems = new string[] { "quit",
                                                 "create new vehicle",
                                                 "show all vehicles in list",
                                                 "show max speed vehicle",
                                                 "show the newest vehicle",
                                                 "show the oldest vehicle",

                                                 "clear console" };
            int indexCommand;

            CCar   Car1   = new CCar(new GPS(1, 1), 10, 2018);
            CPlane Plane1 = new CPlane(new GPS(2, 2), 100, 2015, "100 m", 200);
            CPlane Plane2 = new CPlane(new GPS(2, 2), 200, 2015, "200 m", 300);
            CShip  Ship1  = new CShip(new GPS(3, 3), 250, 2014, 50, "PortName");
            CShip  Ship2  = new CShip(new GPS(4, 4), 150, 2013, 20, "PortName2");



            do
            {
                indexCommand = UserConsoleInteractor.GetCommandFromOptionMenu(menuiItems);
                UserConsoleInteractor.ChooseOptionMenu(indexCommand);
            } while (indexCommand != 0);

            Console.ReadLine();
        }
예제 #2
0
        public CollisionShape(BinaryReader br)
        {
            ObjSize  = br.ReadUInt32();
            Name     = br.ReadCString(Constants.SizeName);
            ObjectId = br.ReadInt32();
            ParentId = br.ReadInt32();
            Flags    = (GENOBJECTFLAGS)br.ReadUInt32();

            LoadTracks(br);

            Type = (GEOM_SHAPE)br.ReadUInt32();
            switch (Type)
            {
            case GEOM_SHAPE.SHAPE_BOX:
                Box = new CBox(br);
                break;

            case GEOM_SHAPE.SHAPE_CYLINDER:
                Cylinder = new CCylinder(br);
                break;

            case GEOM_SHAPE.SHAPE_PLANE:
                Plane = new CPlane(br);
                break;

            case GEOM_SHAPE.SHAPE_SPHERE:
                Sphere = new CSphere(br);
                break;
            }
        }
예제 #3
0
        static void Main(string[] args)
        {
            CVehicle[] massTransport = new CVehicle[12];
            massTransport[0]  = new CCar("Car  #1", 1000, 100, 2015, 0, 0, "Red");
            massTransport[1]  = new CPlane("Plane#1", 500000, 1000, 2010, 0, 0, 5000, 230);
            massTransport[2]  = new CShip("Ship #1", 400000, 60, 2016, 0, 0, 500, "Kiyv");
            massTransport[3]  = new CCar("Car  #2", 1200, 120, 2017, 0, 0, "Green");
            massTransport[4]  = new CPlane("Plane#2", 520000, 900, 2014, 0, 0, 7000, 120);
            massTransport[5]  = new CShip("Ship #1", 420000, 40, 2018, 0, 0, 700, "Kiyv 1");
            massTransport[6]  = new CCar("Car  #4", 1300, 120, 2016, 0, 0, "Yellow");
            massTransport[7]  = new CPlane("Plane#3", 530000, 1100, 2012, 0, 0, 8000, 280);
            massTransport[8]  = new CShip("Ship #1", 430000, 30, 2014, 0, 0, 400, "Dnipro");
            massTransport[9]  = new CCar("Car  #3", 1400, 130, 2015, 0, 0, "Blue");
            massTransport[10] = new CPlane("Plane#4", 550000, 1200, 2011, 0, 0, 4000, 100);
            massTransport[11] = new CShip("Ship #1", 460000, 70, 2017, 0, 0, 520, "Chernigov");


            Console.WriteLine("1. Найти транспортное стредство от 2011 до 2015 года выпуска");
            Console.WriteLine("2. Найти транспортное стредство со скоростью от 70 до 900 км/час ");
            Console.WriteLine("3. Найти транспортное стредство с посадочными местами от 150 до 500");
            Console.WriteLine("4. Найти транспортное стредство красного цвета");
            Console.WriteLine("Введите пункт меню");

            int MenuItem;

            int.TryParse(Console.ReadLine(), out MenuItem);

            Console.WriteLine("Результат поиска");
            switch (MenuItem)
            {
            case 1:
                MySearch.VehicleYear(massTransport, 2015, 2011);
                break;

            case 2:
                MySearch.VehicleSpeed(massTransport, 900, 70);
                break;

            case 3:
                MySearch.VehiclePassengerCapacity(massTransport, 500, 150);
                break;

            case 4:
                MySearch.VehicleColor(massTransport, "Red");
                break;

            default:
                break;
            }

            Console.WriteLine("Полный список");
            foreach (var item in massTransport)
            {
                Console.WriteLine(item.ToString());
            }
            Console.ReadLine();
        }
예제 #4
0
 void Place(CPlane plane)
 {
     for (int x = plane.x1; x <= plane.x2; x++)
     {
         for (int y = plane.y1; y <= plane.y2; y++)
         {
             CNode node = GetNodeByXY(x, y);
             if (node != null)
             {
                 node.obj.GetComponent <Image>().color = Color.gray;
                 blocks.Add(node);
             }
         }
     }
 }
예제 #5
0
    CPlane GetMinDisInOrg(Vector2 pos)
    {
        float  min   = 1000000;
        CPlane plane = new CPlane();

        for (int i = 0; i < planesOrg.Count; i++)
        {
            float dis = Vector2.Distance(pos, planesOrg[i].center);
            if (dis < min)
            {
                min   = dis;
                plane = planesOrg[i];
            }
        }

        return(plane);
    }
예제 #6
0
    void ProcessNode(CNode node)
    {
        if (node.x + size - 1 >= colNum ||
            node.y + size - 1 >= rowNum)
        {
            return;
        }

        for (int x = node.x; x <= node.x + size - 1; x++)
        {
            for (int y = node.y; y <= node.y + size - 1; y++)
            {
                if (IsInBlock(x, y))
                {
                    return;
                }
            }
        }

//		if (size == 2)
        {
            CPlane p = new CPlane();
            p.x1 = node.x;
            p.y1 = node.y;
            p.x2 = node.x + size - 1;
            p.y2 = node.y + size - 1;
            Vector2 pos1 = GetNodePos(p.x1, p.y1);
            Vector2 pos2 = GetNodePos(p.x2, p.y2);
            p.center = new Vector2((pos1.x + pos2.x) * 0.5f, (pos1.y + pos2.y) * 0.5f);

//			GenerateTag(p.center);

            planes.Add(p);
            if (!isGenerated)
            {
                planesOrg.Add(p);
            }
        }
    }
예제 #7
0
    private void OnCollisionEnter(Collision collision)
    {
        //GetComponent<Collider>().enabled = false;
        Debug.Log("OnCollisionEnter():" + collision.gameObject.name);
        CPlane  cPlane = collision.gameObject.GetComponent <CPlane>();
        Vector3 vInDir = m_vDir; //입사각

        Debug.Log("InDir(U):" + vInDir);
        Vector3 vNor = cPlane.m_plane.normal;              //평면이 바라보는 방향
        Vector3 vOutDir;
        Vector3 vInDirRev  = (vInDir * -1);                //1.입사각 뒤집기
        float   fDot       = Vector3.Dot(vInDirRev, vNor); //2.뒤집은 입사각과 평면의 방향 내적(삼각함수, 가장 긴변의 길이 구하기)
        Vector3 vDoubleNor = fDot * 2 * vNor;              //3. 2의 값을 평면에 곱하면 평면 노말의 두배크기의 벡터

        vOutDir = vDoubleNor + vInDir;                     //4. 3의 결과에 입사각을 더함.
        Debug.Log("Dot:" + fDot + " Cos(" + Mathf.Cos(fDot) + ")");
        Debug.Log("RefrectDir(U):" + vOutDir);
        //vOutDir = Vector3.Reflect(vInDir, vNor);
        Debug.Log("RefrectDir:" + vOutDir);
        m_vDir = vOutDir;
        Debug.Log("Dir(U):" + m_vDir);
    }
예제 #8
0
    void Update()
    {
        Vector2 pos = new Vector2(Input.mousePosition.x - Screen.width * 0.5f,
                                  Input.mousePosition.y - Screen.height * 0.5f);

        if (planes.Count == 0)
        {
            trDrag.localPosition = GetMinDisInOrg(pos).center;
            imgDrag.color        = Color.red;
            return;
        }

        CPlane plane = GetMinDis(pos);

        trDrag.localPosition = plane.center;
        imgDrag.color        = Color.green;

        if (Input.GetMouseButtonDown(0))
        {
            Place(plane);

            InitGrid();
        }
    }