예제 #1
0
    void OnValidate()
    {
        GameObject agent = transform.parent.gameObject;

        annotations          = agent.GetComponent <TargetAnnotation>();
        initializer          = agent.GetComponent <RandomInit>();
        positionDrawer       = agent.GetComponent <RandomPosition>();
        positionDrawer.agent = transform.gameObject;
        if (mode == RobotAcademy.DataCollection.gate)
        {
            annotations.target    = gateTargetObject;
            positionDrawer.target = gateTargetObject;
        }
        else if (mode == RobotAcademy.DataCollection.path)
        {
            annotations.target    = pathTargetObject;
            positionDrawer.target = pathTargetObject;
        }
    }
예제 #2
0
    void Start()
    {
        Debug.Log(Directory.GetCurrentDirectory());
        GameObject agent = transform.parent.gameObject;

        annotations          = agent.GetComponent <TargetAnnotation>();
        initializer          = agent.GetComponent <RandomInit>();
        positionDrawer       = agent.GetComponent <RandomPosition>();
        positionDrawer.agent = transform.gameObject;
        rbody         = GetComponent <Rigidbody>();
        engine        = transform.Find("Engine").GetComponent <Engine>();
        accelerometer = transform.Find("Accelerometer").GetComponent <Accelerometer>();
        depthSensor   = transform.Find("DepthSensor").GetComponent <DepthSensor>();
        // calculate max velocity with set parameters
        maxVelocity = new Vector3(engine.maxForceLateral / (rbody.drag * rbody.mass),
                                  engine.maxForceVertical / (rbody.drag * rbody.mass),
                                  engine.maxForceLongitudinal / (rbody.drag * rbody.mass));
        maxYawVelocity = engine.maxTorqueYaw / (rbody.inertiaTensor.y * rbody.angularDrag);
    }
예제 #3
0
        public ActionResult Random()
        {
            try
            {
                int userID = (int)Profile["ID"];
                int booksCount = manager.bookService.GetAllBooksCount();
                List<BookModel> books = new List<BookModel>();
                var book =
                    manager.bookService.OrderTake(ServiceOrderType.Likes, RandomInit.GetRandom().Next(booksCount), 1)
                        .FirstOrDefault();

                return View("Details", Book.GetBookPageModel(book.ID, userID));
            }
            catch (Exception ex)
            {
                logger.Error(ex);
                return View("Error");
            }
        }
예제 #4
0
        public static BookIndexPageModel GetBookIndexPageModel()
        {
            BookIndexPageModel result = new BookIndexPageModel();
            var random             = RandomInit.GetRandom();
            int booksCount         = manager.bookService.GetAllBooksCount();
            List <BookModel> books = new List <BookModel>();

            for (int i = 0; i < 4; i++)
            {
                books.Add(
                    manager.bookService.OrderTake(ServiceOrderType.Likes, random.Next(booksCount), 1)
                    .FirstOrDefault()
                    .ToBookModel());
            }
            List <AuthorShortModel> authors = new List <AuthorShortModel>();
            int authorsCount = manager.authorService.GetAuthorsCount();

            for (int i = 0; i < 4; i++)
            {
                authors.Add(
                    manager.authorService.OrderTake(random.Next(authorsCount), 1).FirstOrDefault().ToAuthorShortModel());
            }
            List <GenreFirstModel> genres = new List <GenreFirstModel>();
            var dbGenres = manager.listService.GetAllGenres().ToList();

            for (int i = 0; i < 4 && dbGenres.Count > 0; i++)
            {
                genres.Add(Genre.GetGenreFirstModel(dbGenres.ElementAt(random.Next(dbGenres.Count - 1))));
            }
            List <ListShortModel> lists = new List <ListShortModel>();
            var dbLists = manager.listService.GetAllLists().ToList();

            for (int i = 0; i < 4 && dbLists.Count > 0; i++)
            {
                lists.Add(List.GetListShortModel(dbLists.ElementAt(random.Next(dbLists.Count - 1))));
            }
            result.Authors = authors;
            result.Books   = books;
            result.Genres  = genres;
            result.Lists   = lists;
            return(result);
        }