Beispiel #1
0
    private void Flow(int x, int y, DirectionState dir, int val)
    {
        Debug.Log("Flow starting...");
        GameObject startObj = _grid[x, y];
        Tube       tube     = startObj.GetComponent <Tube>();

        // If no tube found in the start spot, game over
        if (tube == null)
        {
            GameOver();
            return;
        }
        // If the tube in the start spot is facing the wrong way, game over
        TubeSideData[] sides        = tube.GetSides();
        bool           inputCorrect = false;

        for (int i = 0; i < sides.Length; i++)
        {
            if (sides[i].Direction == dir && (sides[i].State == InputOutputState.Input || sides[i].State == InputOutputState.Both))
            {
                inputCorrect = true;
            }
        }
        if (!inputCorrect)
        {
            GameOver();
            return;
        }

        tube.FlowStart(dir, val, OperationState.None);
    }
Beispiel #2
0
        public IActionResult Upload(TubeBindingModel model)
        {
            if (!this.IsValidModel(model))
            {
                return(View());
            }
            var youtubeId = model.YoutubeLink.Split("?v=")[1];
            var username  = this.User.Name;
            var user      = this.service.GetUserByName(username);

            if (user == null)
            {
                return(RedirectToAction("/account/login"));
            }

            var tube = new Tube()
            {
                Title       = model.Title,
                Author      = model.Author,
                Description = model.Description,
                YoutubeId   = youtubeId,
                User        = user,
                UserId      = user.Id
            };

            this.service.CreateTube(tube);

            return(RedirectToAction("/"));
        }
Beispiel #3
0
    public GameObject PlaceTile(int x, int y, int tileID)
    {
        if (x < 0 || x > _gridSize)
        {
            Debug.LogError(string.Format("GameObject: {0}\nScript: LevelManager\nError: X coordinate is out of bound.", gameObject.name));
            return(null);
        }

        if (y < 0 || y > _gridSize)
        {
            Debug.LogError(string.Format("GameObject: {0}\nScript: LevelManager\nError: Y coordinate is out of bound.", gameObject.name));
            return(null);
        }

        if (tileID < 0 || tileID > _tile.Length)
        {
            Debug.LogError(string.Format("GameObject: {0}\nScript: LevelManager\nError: tile id is out of bound.", gameObject.name));
            return(null);
        }

        GameObject newTile = Instantiate(_tile[tileID]);

        newTile.transform.parent   = _startPosition.transform;
        newTile.transform.position = new Vector3(_startPosition.transform.position.x + (TileSize() * x), _startPosition.transform.position.y - (TileSize() * y));
        newTile.name = string.Format("Tile {0}x{1}", x, y);
        Tube newTube = newTile.GetComponent <Tube>();

        if (newTube != null)
        {
            newTube.SetManager(this);
            newTube.SetCoordinates((byte)x, (byte)y);
        }
        _grid[x, y] = newTile;
        return(newTile);
    }
        public IActionResult Add(RegisterTubeBindingModel registerTubeBindingModel)
        {
            if (registerTubeBindingModel.Title == "" ||
                registerTubeBindingModel.Author == "" ||
                registerTubeBindingModel.YoutubeId == "")
            {
                this.Model["error"] = "Empty input fields !";
                return(View());
            }

            if (!this.IsValidModel(registerTubeBindingModel))
            {
                this.Model["error"] = "Something went wrong !";
                return(View());
            }

            User currentUser = this.Context.Users.FirstOrDefault(u => u.Username == this.User.Name);

            Tube tube = new Tube()
            {
                Author      = registerTubeBindingModel.Author,
                Title       = registerTubeBindingModel.Title,
                YoutubeId   = registerTubeBindingModel.YoutubeId,
                Description = registerTubeBindingModel.Description,
                UploaderId  = currentUser.Id,
                Views       = 0,
            };

            this.Context.Tubes.Add(tube);
            this.Context.SaveChanges();

            return(this.RedirectToAction("/"));
        }
Beispiel #5
0
        public IActionResult Upload(TubeUploadBindingModel model)
        {
            if (this.ModelState.IsValid)
            {
                var youTubeId = this.GetYouTubeIdFromLink(model.YouTubeLink);

                if (youTubeId == null)
                {
                    return(this.RedirectToAction("Error", "Home"));
                }

                var tube = new Tube
                {
                    Title       = model.Title,
                    Author      = model.Author,
                    Description = model.Description,
                    YouTubeId   = youTubeId,
                    UploaderId  = this.userManager.GetUserId(this.HttpContext.User)
                };

                this.tubeService.Add(tube);
                return(this.RedirectToAction("Details", "Tube", new { id = tube.Id }));
            }


            return(this.View());
        }
Beispiel #6
0
        public IActionResult Upload(TubeUploadingBindingModel model)
        {
            if (!this.IsValidModel(model))
            {
                return(this.BuildErrorView());
            }

            string youTubeId = GetYouTubeIdFromLink(model.YouTubeLink);

            if (youTubeId == null)
            {
                return(this.BuildErrorView());
            }

            var tube = new Tube()
            {
                Title       = model.Title,
                Author      = model.Author,
                Description = model.Description,
                YouTubeId   = youTubeId,
                UploaderId  = this.DbUser.Id
            };

            using (this.Context)
            {
                this.Context.Tubes.Add(tube);
                this.Context.SaveChanges();
            }

            return(this.RedirectToAction($"/tubes/details?id={tube.Id}"));
        }
        public bool Upload(string title, string author, string youtubeId, string description, int userId)
        {
            using (var db = new MeTubeContext())
            {
                var tubeExists = db
                                 .Tubes
                                 .FirstOrDefault(t => t.Title == title);

                if (tubeExists != null)
                {
                    return(false);
                }

                var tube = new Tube
                {
                    Title       = title,
                    Author      = author,
                    Description = description,
                    YoutubeId   = youtubeId,
                    UploaderId  = userId
                };

                db.Tubes.Add(tube);
                db.SaveChanges();

                return(true);
            }
        }
Beispiel #8
0
        public bool Create(string username, string title, string author, string youTubeId, string description)
        {
            using (MeTubeDbContext db = new MeTubeDbContext())
            {
                Tube tube = new Tube
                {
                    Title        = title,
                    Author       = author,
                    YouTubeVideo = youTubeId,
                    Description  = description
                };

                User user = db.Users.FirstOrDefault(u => u.Username == username);

                db.Tubes.Add(tube);

                if (user != null)
                {
                    user.Tubes.Add(tube);
                    db.SaveChanges();
                    return(true);
                }
                return(false);
            }
        }
Beispiel #9
0
        public IActionResult Details(int id)
        {
            if (!this.SessionUser.IsAuthenticated)
            {
                return(RedirectToLogin());
            }

            Tube tube = default(Tube);

            using (this.Context)
            {
                tube = this.Context.Tubes.FirstOrDefault(x => x.Id == id);

                if (tube == default(Tube))
                {
                    return(RedirectToHome());
                }

                tube.Views++;
                this.Context.SaveChanges();
            }

            string tubeViewSuffix = tube.Views != 1 ? "Views" : "View";

            this.Model.Data[TitleKey]       = tube.Title;
            this.Model.Data[YouTubeIdKey]   = tube.YouTubeId;
            this.Model.Data[AuthorKey]      = tube.Author;
            this.Model.Data[ViewsKey]       = $"{tube.Views.ToString()} {tubeViewSuffix}";
            this.Model.Data[DescriptionKey] = tube.Description;

            return(this.View());
        }
Beispiel #10
0
        public async Task <ActionResult <Tube> > Details(int tubeId)
        {
            Tube tube = await tubes.GetAllIncluding(x => x.Category).Where(x => x.TubeId == tubeId)
                        .FirstOrDefaultAsync();

            return(View(tube));
        }
Beispiel #11
0
 //public bool ResetPlayer()
 //{
 //    if (HubConnection != null && User != null)
 //    {
 //        Player = new LocalPlayer(HubConnection);
 //        return true;
 //    }
 //    return false;
 //}
 public GwentClientService(HubConnection hubConnection)
 {
     /*待修改*/
     (sender, receiver) = Tube.CreateSimplex();
     /*待修改*/
     hubConnection.On <bool>("MatchResult", async x =>
     {
         await sender.SendAsync <bool>(x);
     });
     hubConnection.On("RepeatLogin", async() =>
     {
         SceneManager.LoadScene("LoginSecen");
         await DependencyResolver.Container.Resolve <GlobalUIService>().YNMessageBox("账号被其他人强制登陆", "账号被登陆,被挤下了线");
     });
     hubConnection.Closed += (async x =>
     {
         Debug.Log("断线!");
         //var user = DependencyResolver.Container.Resolve<GwentClientService>().User;
         //await Task.Delay(100);
         //await DependencyResolver.Container.Resolve<HubConnection>().StartAsync();
         //var result = await DependencyResolver.Container.Resolve<HubConnection>().InvokeAsync<bool>("Reconnect", user.UserName, user.PassWord);
         //if (result) Debug.Log("尝试重连成功");
         //else
         //{
         SceneManager.LoadScene("LoginSecen");
         Debug.Log("跳转!");
         await DependencyResolver.Container.Resolve <GlobalUIService>().YNMessageBox("断开连接", "请尝试重新登陆");
         //}
     });
     //////////////////////////////
     hubConnection.On <string>("Test", message => Debug.Log($"收到了服务端来自Debug的信息:{message}"));
     Player        = new LocalPlayer(hubConnection);
     HubConnection = hubConnection;
     hubConnection.StartAsync();
 }
Beispiel #12
0
            /// <summary>
            /// Gets the tube that fits the closest for a given core.
            ///
            /// Checks tubes both the standard way and if the tubes would be rotated.
            /// </summary>
            /// <param name="tongue">Core/Lamination tongue size.</param>
            /// <param name="stack">Core stack.</param>
            /// <param name="tube">out parameter, the tube that is closest to fitting with the given parameters.</param>
            /// <returns>If the tube is rotated or not. True = rotated, False = standard.</returns>
            public static bool GetTube(double tongue, double stack, out Tube tube)
            {
                IEnumerable <Tube> standard = _tubes.Where(w => w.Width >= tongue && w.Depth >= stack).OrderBy(t => t.Width).ThenBy(x => x.Depth).Where(z => z.Width >= tongue + 0.03125 && z.Width <= tongue + 0.125 && z.Depth >= stack + 0.03125 && z.Depth <= stack + 0.5);
                IEnumerable <Tube> rotated  = _tubes.Where(w => w.Width >= stack && w.Depth >= tongue).OrderBy(t => t.Depth).ThenBy(x => x.Width).Where(z => z.Width >= stack + 0.03125 && z.Width <= stack + 0.125 && z.Depth >= tongue + 0.03125 && z.Depth <= tongue + 0.5);

                if (standard.Count() >= 1 && rotated.Count() >= 1)
                {
                    tube = GetClosestTube(standard.First(), rotated.First());
                    return(tube == rotated.First() ? true : false);
                }
                else if (standard.Count() >= 1)
                {
                    tube = standard.First();
                    return(false);
                }
                else if (rotated.Count() >= 1)
                {
                    tube = rotated.First();
                    return(true);
                }
                else
                {
                    tube = new Tube("Handmade Tube", tongue + 0.0625, stack + 0.0625, 0, 0.0625, 0.02, 0);
                    return(false);
                }
            }
Beispiel #13
0
        public IActionResult Upload(TubeUploadBindingModel tube)
        {
            if (!this.User.IsAuthenticated)
            {
                return(RedirectToLogin());
            }

            if (!this.IsValidModel(tube))
            {
                this.Model.Data["error"] = this.GetErrorMessageFromInfalidProp(tube);
                return(this.View());
            }

            var tubeDb = new Tube
            {
                Author      = tube.Author,
                Description = tube.Description,
                Title       = tube.Title,
                UploaderId  = this.Context.Users.FirstOrDefault(u => u.Username == this.User.Name).Id,
                YoutubeId   = tube.YouTubeLink
            };

            using (this.Context)
            {
                this.Context.Tubes.Add(tubeDb);
                this.Context.SaveChanges();
            }

            return(RedirectToHome());
        }
Beispiel #14
0
        public IActionResult Upload(UploadTubeBindingModel model)
        {
            if (!this.User.IsAuthenticated)
            {
                return(new RedirectResult("/"));
            }

            if (!this.IsValidModel(model))
            {
                this.Model["message"] = this.GetErrors();

                return(this.View());
            }

            var userId = this.Request.Session.Get <int>(SessionStore.CurrentUserIdKey);

            Tube tube = new Tube();

            tube.Title       = model.Title;
            tube.Author      = model.Author;
            tube.YouTubeId   = model.YouTubeId;
            tube.Description = model.Description;
            tube.UploaderId  = userId;

            using (var db = new MyTubeDbContext())
            {
                db.Tubes.Add(tube);

                db.SaveChanges();
            }

            this.Model["message"] = "<p>The Tube Successfully added</p>";

            return(this.View());
        }
Beispiel #15
0
        public IActionResult Details(int tubeId)
        {
            if (!this.User.IsAuthenticated)
            {
                return(new RedirectResult("/"));
            }

            using (var db = new MyTubeDbContext())
            {
                Tube tube = db.Tubes.FirstOrDefault(t => t.Id == tubeId);

                if (tube == null)
                {
                    return(new RedirectResult("/"));
                }

                tube.Views++;

                db.SaveChanges();

                this.Model["title"]  = tube.Title;
                this.Model["tubeId"] = tube.YouTubeId;
                this.Model["author"] = tube.Author;
                this.Model["views"]  = tube.Views.ToString();
                this.Model["desc"]   = tube.Description;
            }

            return(this.View());
        }
Beispiel #16
0
        public IActionResult Upload(UploadTubeBindingModel model)
        {
            if (!this.IsValidModel(model))
            {
                return(this.BuildErrorView());
            }
            using (this.Context)
            {
                var user      = this.Context.Users.FirstOrDefault(u => u.Username == this.User.Name);
                var youtubeId = GetTubeId(model.YouTubeLink);

                if (string.IsNullOrWhiteSpace(youtubeId))
                {
                    return(this.BuildErrorView());
                }

                var tube = new Tube()
                {
                    Author      = model.Author,
                    Title       = model.Title,
                    Description = model.Description,
                    YoutubeId   = youtubeId,
                    UserId      = user.Id,
                };

                this.Context.Tubes.Add(tube);
                this.Context.SaveChanges();
                return(this.RedirectToAction($"/tubes/details?id={tube.Id}"));
            }
        }
    public virtual bool GetTube(Tube tube)
    {
        if (tubes.Count > tubeCapacity)
        {
            // 인벤토리가 꽉참
            if (OnGetTube != null)
            {
                OnGetTube(null, false);
            }
            return(false);
        }

        if (tube == null)
        {
            if (OnGetTube != null)
            {
                OnGetTube(null, false);
            }
            return(false);
        }

        tubes.Add(tube);
        if (OnGetTube != null)
        {
            OnGetTube(tube, true);
        }
        return(true);
    }
Beispiel #18
0
    // Renders landing procedure
    public void RenderProcedure()
    {
        landingProcedure = new GameObject();
        landingProcedure.transform.SetParent(transform);
        landingProcedure.name = "ILS";
        List <Coordinates> list = dataManager.ils;

        for (int i = 0; i < list.Count - 1; i++)
        {
            Vector3 current = new Vector3((float)list[i].x,
                                          (float)list[i].z,
                                          (float)list[i].y);
            Vector3 next = new Vector3((float)list[i + 1].x,
                                       (float)list[i + 1].z,
                                       (float)list[i + 1].y);
            // Creates a tube object connecting two coordinates
            Tube tube = Instantiate(prefab);
            tube.Settings(Vector3.Distance(current, next), current, next);
            tube.CreateTube(false);
            tube.transform.SetParent(landingProcedure.transform);

            if (i == 0)
            {
                continue;
            }
            // Creates curtain under tube object for better 3D visualization
            GameObject curtain = GameObject.CreatePrimitive(PrimitiveType.Cube);
            curtain.GetComponent <MeshRenderer>().material = curtainMaterial;
            Vector3 curtainOffset = new Vector3(0, tube.transform.position.y / 2 + tube.radius, 0);
            curtain.transform.position   = Vector3.Lerp(current, next, 0.5f) - curtainOffset;
            curtain.transform.rotation   = tube.transform.rotation;
            curtain.transform.localScale = new Vector3(0.01f, Vector3.Distance(current, next), tube.transform.position.y);
            curtain.transform.SetParent(tube.transform);
        }
    }
Beispiel #19
0
    private void CreateLongCylinderWithMove(Vector3 start, Tube tube, float width, float sector_length, int parent_id, int top_id)
    {
        Vector3 end           = new Vector3((tube.start.x + tube.end.x) / 2.0f, (tube.start.y + tube.end.y) / 2.0f, (tube.start.z + tube.end.z) / 2.0f);
        float   no_of_sectors = Mathf.Floor(Mathf.Sqrt(Mathf.Pow(start.x - end.x, 2) + Mathf.Pow(start.y - end.y, 2) + Mathf.Pow(start.z - end.z, 2)) / sector_length);
        Vector3 sector_vec    = new Vector3(-(start.x - end.x) / no_of_sectors, -(start.y - end.y) / no_of_sectors, -(start.z - end.z) / no_of_sectors);
        Vector3 startpoint    = start;
        Vector3 endpoint;

        for (int i = 1; i <= no_of_sectors; i++)
        {
            if (i == 1)
            {
                endpoint = new Vector3(start.x + i * sector_vec.x + Random.Range(-max_curvature, max_curvature), start.y + i * sector_vec.y + Random.Range(0.05f, max_curvature), start.z + i * sector_vec.z + Random.Range(-0.2f, 0.2f));
            }
            else
            {
                endpoint = new Vector3(start.x + i * sector_vec.x + Random.Range(-max_curvature, max_curvature), start.y + i * sector_vec.y + Random.Range(-max_curvature, max_curvature), start.z + i * sector_vec.z + Random.Range(-0.2f, 0.2f));
            }
            CreateCylinderBetweenPoints(startpoint, endpoint, width);
            export_dict.Add(new Tube(id, startpoint, endpoint, width / 2.0f, parent_id));
            parent_id  = id;
            id        += 1;
            startpoint = endpoint;
        }
        CreateCylinderBetweenPoints(startpoint, end, width);
        export_dict.Add(new Tube(id, startpoint, end, width / 2.0f, parent_id, -1, top_id));
        id += 1;
    }
Beispiel #20
0
        public string EditTube(DtoTube dtoTube)
        {
            var uniqeTube = TubeMethods.Instance.GetTubeByCode(dtoTube.Code);

            if (!dtoTube.IsEdit)
            {
                var tube = new Tube()
                {
                    Code   = dtoTube.Code,
                    Name   = dtoTube.Name,
                    Volume = dtoTube.Volume
                };
                return(TubeMethods.Instance.InsertTube(tube));
            }
            else
            {
                var tube = new Tube()
                {
                    Id     = TubeMethods.Instance.GetTubeByCode(dtoTube.Code).Id,
                    Code   = dtoTube.Code,
                    Name   = dtoTube.Name,
                    Volume = dtoTube.Volume
                };
                return(TubeMethods.Instance.UpdateTube(tube));
            }
        }
Beispiel #21
0
    private List <Tube> CreateLongCylinderWithReturnPoints(Vector3 start, Vector3 end, float width, float sector_length)
    {
        float       no_of_sectors = Mathf.Floor(Mathf.Sqrt(Mathf.Pow(start.x - end.x, 2) + Mathf.Pow(start.y - end.y, 2) + Mathf.Pow(start.z - end.z, 2)) / sector_length);
        Vector3     sector_vec    = new Vector3(-(start.x - end.x) / no_of_sectors, -(start.y - end.y) / no_of_sectors, -(start.z - end.z) / no_of_sectors);
        Vector3     startpoint    = start;
        Vector3     endpoint;
        List <Tube> q = new List <Tube>();
        Tube        tube;

        for (int i = 1; i <= no_of_sectors; i++)
        {
            endpoint = new Vector3(start.x + i * sector_vec.x + Random.Range(-max_curvature, max_curvature), start.y + i * sector_vec.y + Random.Range(-max_curvature, max_curvature), start.z + i * sector_vec.z + Random.Range(-max_curvature, max_curvature));
            CreateCylinderBetweenPoints(startpoint, endpoint, width);
            if (i == 1)
            {
                tube = new Tube(id, startpoint, endpoint, width / 2.0f, -1, -1, -1, true, true, -10.0f);
                id  += 1;
            }
            else
            {
                tube = new Tube(id, startpoint, endpoint, width / 2.0f, id - 1);
                id  += 1;
            }

            q.Add(tube);
            startpoint = endpoint;
        }

        CreateCylinderBetweenPoints(startpoint, end, width);
        tube = new Tube(id, startpoint, end, width / 2.0f, id - 1, -1, -1, false, true, 10.0f);
        id  += 1;
        q.Add(tube);
        return(q);
    }
Beispiel #22
0
        public override void SpecialDraw(int i, int j, SpriteBatch spriteBatch)
        {
            TileEntities.EntryPoint entryPoint = Utility.GetTileEntity <TileEntities.EntryPoint>(i, j);
            if (entryPoint == null || !Main.tile[i, j].IsTopLeft())
            {
                return;
            }

            Vector2 position = new Point16(i, j).ToScreenCoordinates();

            Tube tube = TerraFirma.Instance.TubeNetworkLayer[i, j];

            if (tube.GetNeighbor(Side.Top) != null)
            {
                spriteBatch.Draw(ConnectionTexture, position + new Vector2(6, 0));
            }

            if (tube.GetNeighbor(Side.Left) != null)
            {
                spriteBatch.Draw(ConnectionTexture, position + new Vector2(-2, 24), null, Color.White, -MathHelper.PiOver2, ConnectionTexture.Size() * 0.5f, Vector2.One, SpriteEffects.None, 0f);
            }

            if (tube.GetNeighbor(Side.Right) != null)
            {
                spriteBatch.Draw(ConnectionTexture, position + new Vector2(50, 24), null, Color.White, MathHelper.PiOver2, ConnectionTexture.Size() * 0.5f, Vector2.One, SpriteEffects.None, 0f);
            }
        }
    void DebugCreateSkill()
    {
        // Debug Tubes
        Tube styleTube    = new Tube(dataManager.TubeData.StyleData[0]);
        Tube enhancerTube = new Tube(dataManager.TubeData.EnhancerData[0]);
        Tube coolerTube   = new Tube(dataManager.TubeData.CoolerData[0]);

        GetTube(styleTube);
        GetTube(enhancerTube);
        GetTube(coolerTube);

        styleTube    = new Tube(dataManager.TubeData.StyleData[6]);
        enhancerTube = new Tube(dataManager.TubeData.EnhancerData[1]);
        coolerTube   = new Tube(dataManager.TubeData.CoolerData[0]);

        GetTube(styleTube);
        GetTube(enhancerTube);
        GetTube(coolerTube);

        styleTube    = new Tube(dataManager.TubeData.StyleData[3]);
        enhancerTube = new Tube(dataManager.TubeData.EnhancerData[22]);
        coolerTube   = new Tube(dataManager.TubeData.CoolerData[0]);

        GetTube(styleTube);
        GetTube(enhancerTube);
        GetTube(coolerTube);
    }
    // Set mesh data from tube
    public void SetTube(Tube tube)
    {
        // Get tube and data
        //this.tube = tube;
        DestroyImmediate(mesh, true);
        mesh = new Mesh();

        // Set new data
        mesh.vertices  = tube.vertices;
        mesh.triangles = tube.tris;
        mesh.uv        = tube.uv;
        //mesh.colors = tube.colors;

        // Recalculate normals
        mesh.RecalculateNormals();

        // Modify
        Vector3[] normals = mesh.normals;

        for (int i = tube.resolution - 1; i < normals.Length - tube.resolution * 2; i += tube.resolution) //-tube.resolution*2 to be careful with tube endcaps
        {
            normals[i] = normals[i - tube.resolution + 1];
        }

        // assign the array of normals to the mesh
        mesh.normals = normals;

        meshFilter.mesh = mesh;
    }
Beispiel #25
0
        public MeshPreviewSelector()
        {
            InitializeComponent();

            var previewRenderer = new PreviewRenderer(new Size(200, 200));

            previewRenderer.BackgroundColor = new Vector4(0.75f, 0.75f, 0.75f, 1f);

            var meshes = new List <Mesh>();

            meshes.Add(Icosahedron.Create(0.45f, 0));
            meshes.Add(Icosahedron.Create(0.45f, 1));
            meshes.Add(Tube.Create(0.3f, 0.35f, 0.7f, 20));
            meshes.Add(Cloud.Create(CloudShape.Sphere, 0.9f, 50000));
            meshes.Add(Cone.Create(0.3f, 0.8f));
            meshes.Add(TrefoilKnot.Create());

            var rotation = Quaternion.CreateFromYawPitchRoll(0, -0.25f, -0.2f);

            MeshesListBox.ItemsSource = meshes
                                        .Select(_ => new MeshPreviewViewModel(_, previewRenderer.RenderPreview(_, rotation)))
                                        .ToArray();

            previewRenderer.Dispose();
        }
Beispiel #26
0
    // Set mesh data from tube
    public void SetTube(Tube tube)
    {
        // Create mesh and attach
        meshRenderer = gameObject.AddComponent <MeshRenderer>();
        meshRenderer.sharedMaterial = new Material(Shader.Find("Standard"));

        meshFilter = gameObject.AddComponent <MeshFilter>();

        // Get tube and data
        //this.tube = tube;

        mesh = new Mesh();

        // Set new data
        mesh.vertices  = tube.vertices;
        mesh.triangles = tube.tris;
        mesh.uv        = tube.uv;

        // Recalculate normals
        mesh.RecalculateNormals();

        // Modify
        Vector3[] normals = mesh.normals;

        for (int i = tube.resolution - 1; i < normals.Length - tube.resolution * 2; i += tube.resolution) //-tube.resolution*2 to be careful with tube endcaps
        {
            normals[i] = normals[i - tube.resolution + 1];
        }

        // assign the array of normals to the mesh
        mesh.normals = normals;

        meshFilter.mesh = mesh;
    }
Beispiel #27
0
        private static void LooseMass(Materials material)
        {
            var result = false;
            var mass   = 0.0;

            while (!result)
            {
                var dialog = new InputBox
                {
                    Caption       = string.Format("Введите массу {0} в килограммах:", material.ToGenitive()),
                    ShowInTaskbar = false,
                    Topmost       = true
                };

                var showDialog = dialog.ShowDialog();
                if (!showDialog.HasValue || !showDialog.Value)
                {
                    return;
                }

                result = double.TryParse(dialog.ResponseText, NumberStyles.Number, CultureInfo.InstalledUICulture, out mass);
            }

            var substance = Tube.FindSubstance <Навеска>(material);

            substance.G = mass / 1000.0;
        }
Beispiel #28
0
    // Update is called once per frame
    void Update()
    {
        // Generate new tubes and delete old
        int tubes = tubesObject.transform.childCount;

        if (tubes == 0)
        {
            Tube.CreateTubes(character.gameObject.transform.position.x + tubeInitOffset, 10);
        }
        else
        {
            Transform firstTube = tubesObject.transform.GetChild(0);

            if (!Camera.main.IsObjectVisible(Tube.GetBasicGameObject(firstTube.gameObject)))
            {
                Destroy(firstTube.gameObject);
            }

            Transform lastTube = tubesObject.transform.GetChild(tubes - 1);
            if (Camera.main.IsObjectVisible(Tube.GetBasicGameObject(lastTube.gameObject)))
            {
                GameObject newTube = Tube.CreateTubes(tubesObject.transform.GetChild(tubes - 1).transform.position.x + tubeOffset, Random.Range(tubeMinHeight, tubeMaxHeight));
            }
        }

        if (!character.isPlaying)
        {
            return;
        }
        foreach (Transform tube in tubesObject.transform)
        {
            tube.transform.position -= new Vector3(speed, 0, 0) * Time.deltaTime;
        }
    }
        public int Add(
            string title,
            string author,
            string description,
            string videoId,
            string username)
        {
            var userExist = this.db.Users.Any(u => u.Username == username);
            var user      = this.db.Users.FirstOrDefault(u => u.Username == username);

            if (userExist)
            {
                var tube = new Tube
                {
                    Title       = title,
                    Author      = author,
                    Description = description,
                    VideoId     = videoId,
                    UploaderId  = user.Id
                };

                this.db.Tubes.Add(tube);
                this.db.SaveChanges();
                return(tube.Id);
            }

            return(default(int));
        }
        private void CheckTargets()
        {
            while (targets.Count > 0)
            {
                Target target = GetTargetFromQueue();
                if (!(this.previousTarget is null))
                {
                    this.delay = (int)(target.Time - previousTarget.Time).TotalMilliseconds;
                }

                if (previousTarget is null ||
                    (target.Coordinate.Latitude != previousTarget.Coordinate.Latitude &&
                     target.Coordinate.Longitude != previousTarget.Coordinate.Longitude))
                {
                    Task movingTask = Task.Run(() => Move(target.Coordinate));

                    double distance = 0;

                    Tube tube = tubes.Find(t =>
                    {
                        distance = GetDistance(t.Coordinate, target.Coordinate);
                        return(distance < 351);
                    });

                    double speed = previousTarget is null
                        ? 30
                        : speed = CalculateSpeed(previousTarget, target);

                    string reportMessage;
                    if (!(tube is null))
                    {
                        TrafficReport report = new TrafficReport(tube.Name, id, target.Time, speed);
                        reportMessage = CreateSuccessReport(report, distance);
                    }
 public void Update()
 {
     if (active)
     {
         active = false;
         var geometry = new Tube(origin, left, up, size, color);
         var stream = new Single(geometry);
         var factory = new MeshFactory(stream);
         var filter = GetComponent<MeshFilter>();
         filter.mesh = new Mesh();
         factory.Bind(filter.mesh);
   }
 }
        static void Main(string[] args)
        {
            // input
            string input = Console.ReadLine();
            int tubesCount = int.Parse(input);

            input = Console.ReadLine();
            int peopleCount = int.Parse(input);

            Tube[] tubes = new Tube[tubesCount];
            int minIndex = 0;
            for (int i = 0; i < tubes.Length; i++)
            {
                input = Console.ReadLine();
                tubes[i] = new Tube(int.Parse(input));
                if (tubes[i].Value <= tubes[minIndex].Value)
                {
                    minIndex = i;
                }
            }
            int maxLeft = minIndex;
            int resultIndex = 0;
            for (int p = tubesCount; p < peopleCount + 1; p++)
            {
                for (int t = 0; t < tubesCount; t++)
                {
                    tubes[t].Left = tubes[t].Value - tubes[t].Parts * (tubes[maxLeft].Value / tubes[maxLeft].Parts);
                }
                resultIndex = maxLeft;
                for (int t = 0; t < tubesCount; t++)
                {
                    if (tubes[t].Left >= tubes[maxLeft].Left)
                    {
                        maxLeft = t;
                    }

                }

                tubes[maxLeft].Parts++;
            }
            int result = (tubes[resultIndex].Value / tubes[resultIndex].Parts);
            Console.WriteLine(result);
        }