Example #1
0
        public PolyCurveSO Create(SOMaterial defaultMaterial)
        {
            if (curve == null)
            {
                LineGenerator gen = new LineGenerator()
                {
                    Start = Vector3.zero, End = 10.0f * Vector3.up, StepSize = 0.1f
                };
                gen.Generate();
                curve = new DCurve3();
                gen.Make(curve);
            }

            // assumes type identifier is something like BlahBlahSO
            root = new GameObject(UniqueNames.GetNext(Type.identifier.Remove(Type.identifier.Length - 2)));

            if (EnableLineRenderer)
            {
                LineRenderer ren = root.AddComponent <LineRenderer>();
                ren.startWidth    = ren.endWidth = 0.05f;
                ren.useWorldSpace = false;
            }

            AssignSOMaterial(defaultMaterial);       // need to do this to setup BaseSO material stack
            Material useMaterial = CurrentMaterial;

            Create_internal(useMaterial);

            UpdateGeometry();

            increment_timestamp();

            return(this);
        }
Example #2
0
 public void OnMouseClick(IMapItem item)
 {
     if (LineGenerator != null && item != null)
     {
         LineGenerator.OnMapItemClick(item);
     }
 }
Example #3
0
    public override void OnInspectorGUI()
    {
        l = (LineGenerator)target;
        //EditorGUILayout.PropertyField(linesProperty);
        if (l.line == null)
        {
            l.CreateLine();
        }
        //editorLine = l.line;
        DrawDefaultInspector();

        /*if(GUILayout.Button("Add new line with new node"))
         * {
         *  Undo.RecordObject(l, "Add line");
         *  l.AddLine(l.activeNodeIndex, l.newNodePosition);
         * }*/
        if (GUILayout.Button("Add new line with existing node"))
        {
            Undo.RecordObject(l, "Connect line");
            l.ConnectLine(l.activeNodeIndex, l.toIndex);
        }
        if (GUILayout.Button("Initialize points and line"))
        {
            Undo.RecordObject(l, "Initialize lines");
            l.InitializeLine();
        }
    }
Example #4
0
    void SelectRandomPoints()
    {
        GameObject[] points = GameObject.FindGameObjectsWithTag("Point");
        computerSelectedPointCount = 0;

        while (computerSelectedPointCount < 1)
        {
            int        i             = Random.Range(0, points.Length);
            GameObject selectedPoint = points[i];

            if (selectedPoint.GetComponent <SpriteRenderer>().color == DataScript.defaultColor)
            {
                selectedPoint.GetComponent <SpriteRenderer>().color = DataScript.computerColor;
                for (int j = 0; j < 2; j++)
                {
                    selectedPoint.GetComponent <PointScript>().ColorizeThePoint(computerColorStr);
                }

                computerSelectedPointCount++;
                DataScript.pointCountSelectedByComputer++;
            }
        }

        DataScript.inputLock = false;

        if (DataScript.pointCountSelectedByComputer == DataScript.pointCountToSelect)
        {
            lineGenerator = FindObjectOfType(typeof(LineGenerator)) as LineGenerator;
            lineGenerator.GenerateLinesBetweenPoints();
        }
    }
Example #5
0
        public BezierCurve(float offsetX, float offsetY, CurveInitalizeData initData)
        {
            float initX = initData.HandlePosX + offsetX;
            float initY = initData.HandlePosY + offsetY;

            _nextLines = null;
            _nextCurve = null;
            _prevCurve = null;
            _prevLines = null;

            _lineTemplate = new LineGenerator();
            _lineTemplate.V1 = Vector2.Zero;
            _lineTemplate.V2 = Vector2.Zero;
            _lineTemplate.Color = Color.White;
            _lineTemplate.Depth = DepthLevel.Low;

            Vector2 component1 = Common.GetComponentFromAngle(initData.Angle, initData.Length1);
            Vector2 component2 = Common.GetComponentFromAngle((float) (initData.Angle - Math.PI), initData.Length2); // minus math.pi to reverse direction

            #region stuff for generating ui elements

            var buttonTemplate = new ButtonGenerator("HullEditorHandle.json");

            var lineTemplate = new LineGenerator("HullEditorLine.json");

            Handle = new CurveHandle(buttonTemplate, lineTemplate, new Vector2(initX, initY), component1, component2);

            #endregion
        }
Example #6
0
        public static LineGenerator Initialize() //helps to generate random lines
        {
            if (generator == null)
            {
                generator = new LineGenerator();
            }

            return(generator);
        }
Example #7
0
    // Use this for initialization
    void Start()
    {
        Physics2D.gravity   = Vector2.zero;
        multiplierText.text = "Multiplier: ";

        line = lineObject.GetComponent <LineGenerator>();
        notificationScript = GameObject.Find("NotificationText").GetComponent <TutScript> ();
        notificationScript.displayText("Place your finger on the circle!", 60);
    }
Example #8
0
 public void OnEnable()
 {
     l = (LineGenerator)target;
     if (l.line == null)
     {
         l.CreateLine();
     }
     lines = l.line;
 }
 //Instantiates a number of lines GO's according to how many lines are requested;
 void CreateLineGameObjects()
 {
     for (int i = 0; i < numberOfLines; i++)
     {
         //Setting color of line equal to its extremity nodes and number each line;
         GameObject    lineObject = Instantiate(linePrefab);
         LineGenerator lineGen    = lineObject.GetComponent <LineGenerator>();
         lineGen.SetupLine(specialPositions[i * 2], specialPositions[i * 2 + 1], i, colors[i]);
         lines.Add(lineGen); //Store each instantiated line on List 'lines';
     }
 }
Example #10
0
    protected override void OnEnable()
    {
        base.OnEnable();
        if (target == null)
        {
            return;
        }
        lineGen = (LineGenerator)target;

        listGUI = new ReorderableList(serializedObject, serializedObject.FindProperty("addedObjects"), true, true, true, true);
        listGUI.drawElementCallback = BuildGUI;
        listGUI.drawHeaderCallback  = BuildTitle;
    }
Example #11
0
        /*
        **	Method Name:	StartTaskSpawner()
        **	Parameters:		None.
        **	Return Values:	Void.
        **	Description:	This method is used to spawn (start/create) a worker task that will continue to loop until the _StopFlag is changed to true.
        **                  The task can be paused with the _PauseFlag. When operating in active mode it constantly generates lines and passes them to the UI thread's dispatcher.
        **                  The task will allow lines to remain on the screen according to the _TailLength variable, lines beyond this value will be removed.
        **                  After the line has been drawn the task sleeps for a time determined by the value of _SleepTimeInMilliSeconds.
        **                  Also, a reference to the task will be placed into the list called TaskPool, so it can be referenced later.
        */
        public void StartTaskSpawner()
        {
            LineGenerator myLineGenerator = new LineGenerator();
            Brush         ThreadColour    = GetRandomBrushColour();

            // Spawning the task (thread) that will perform the work of constantly generating new lines and sending them to the UI thread. Can be stopped via _StopFlag.
            Task t = Task.Run(() =>
            {
                Queue <Line> LineQue = new Queue <Line>();

                while (_StopFlag == false)
                {
                    while (_PauseFlag == true)
                    {
                        Thread.Sleep(_SpawnTimeInMilliSeconds);
                    }

                    // I am putting this check in to ensure that no more lines are drawn once the stop flag has tripped.
                    if (_StopFlag == true)
                    {
                        break;
                    }

                    // This use of the dispatcher is necessary to have the UI thread access and told to draw the lines that we are generating.
                    ActiveCanvas.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Send, (Action)(() =>
                    {
                        // Generate a new line.
                        Line myLine = new Line();
                        myLineGenerator.CalculateNewLinePoints(myLine);
                        myLine.Stroke = ThreadColour;

                        // Add the line to the collection of elements for the ActiveCanvas.
                        ActiveCanvas.Children.Add(myLine);

                        // Add the line to the que of lines.
                        LineQue.Enqueue(myLine);

                        // This code clears up the extra lines, once the desired number of tails has been reached.
                        while (LineQue.Count >= (_TailLength + 1))
                        {
                            ActiveCanvas.Children.Remove(LineQue.Dequeue());
                        }
                    }));

                    // This sleep command determines how fast the lines are generated, reducing the time here equals faster line generation.
                    Thread.Sleep(_SpawnTimeInMilliSeconds);
                }
            });

            TaskPool.Add(t);
        }
Example #12
0
    // Use this for initialization
    void Start()
    {
        gObj = GameObject.Find("Smooth Line Renderer");
        //MeshRenderer sr = GetComponent<MeshRenderer>();
        Vector3 lowerLeft  = mainCamera.ScreenToWorldPoint(new Vector3(0, 0, 0));
        Vector3 upperRight = mainCamera.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height, 0));

        float height = 2 * Camera.main.orthographicSize;
        float width  = height * Camera.main.aspect;

        transform.localScale = new Vector3(width, height, 1);
        rend    = GetComponent <Renderer>();
        lineGen = gObj.GetComponent <LineGenerator>();
    }
Example #13
0
 public void OnValidate()
 {
     _lineGenerator = gameObject.GetComponent <LineGenerator>();
     _voxel         = gameObject.GetComponent <Voxel>();
     if (isLoaded == false)
     {
         isLoaded = true;
         EditorApplication.quitting += ReleaseBuffers;
     }
     numVoxelPerThread = Mathf.Clamp(numVoxelPerThread, 1, _voxel.numVoxel.x);
     numVoxelPerThread = Mathf.Clamp(numVoxelPerThread, 1, _voxel.numVoxel.y);
     numVoxelPerThread = Mathf.Clamp(numVoxelPerThread, 1, _voxel.numVoxel.z);
     GenerateDensity();
 }
Example #14
0
        /// <summary>
        /// </summary>
        /// <param name="buttonTemplate"> </param>
        /// <param name="lineTemplate"> </param>
        /// <param name="pos"> </param>
        /// <param name="prevComponent"> </param>
        /// <param name="nextComponent"> </param>
        public CurveHandle(ButtonGenerator buttonTemplate, LineGenerator lineTemplate, Vector2 pos, Vector2 prevComponent, Vector2 nextComponent)
        {
            buttonTemplate = new ButtonGenerator("HullEditorHandle.json");
            buttonTemplate.Identifier = (int) HandleType.Center;
            buttonTemplate.X = pos.X;
            buttonTemplate.Y = pos.Y;

            _centerButton = buttonTemplate.GenerateButton();
            _centerButton.GetComponent<DraggableComponent>().DragMovementDispatcher += TranslateToLinks;
            _centerButton.GetComponent<DraggableComponent>().DragMovementClamp += ClampHandleMovement;

            buttonTemplate.Identifier = (int) HandleType.Prev;
            buttonTemplate.X = prevComponent.X + pos.X;
            buttonTemplate.Y = prevComponent.Y + pos.Y;
            _prevButton = buttonTemplate.GenerateButton();
            _prevButton.GetComponent<DraggableComponent>().DragMovementDispatcher += TranslateToLinks;
            _prevButton.GetComponent<DraggableComponent>().DragMovementClamp += ClampHandleMovement;

            buttonTemplate.Identifier = (int) HandleType.Next;
            buttonTemplate.X = nextComponent.X + pos.X;
            buttonTemplate.Y = nextComponent.Y + pos.Y;
            _nextButton = buttonTemplate.GenerateButton();
            _nextButton.GetComponent<DraggableComponent>().DragMovementDispatcher += TranslateToLinks;
            _nextButton.GetComponent<DraggableComponent>().DragMovementClamp += ClampHandleMovement;

            _prevLine = lineTemplate.GenerateLine();
            _nextLine = lineTemplate.GenerateLine();

            _prevLine.OriginPoint = _centerButton.CentPosition;
            _prevLine.DestPoint = _prevButton.CentPosition;

            _nextLine.OriginPoint = _centerButton.CentPosition;
            _nextLine.DestPoint = _nextButton.CentPosition;

            _nextButton.GetComponent<FadeComponent>().ForceFadeout();
            _prevButton.GetComponent<FadeComponent>().ForceFadeout();
            _centerButton.GetComponent<FadeComponent>().ForceFadeout();

            _prevLine.GetComponent<FadeComponent>().ForceFadeout();
            _nextLine.GetComponent<FadeComponent>().ForceFadeout();

            _nextButton.GetComponent<FadeComponent>().ForceFadeout();
            _prevButton.GetComponent<FadeComponent>().ForceFadeout();
            _centerButton.GetComponent<FadeComponent>().ForceFadeout();

            _prevLine.GetComponent<FadeComponent>().ForceFadeout();
            _nextLine.GetComponent<FadeComponent>().ForceFadeout();

            InterlinkButtonEvents();
        }
        public async Task L01_HorseshoeMesaLineContent()
        {
            var testFile = new FileInfo(Path.Combine(Directory.GetCurrentDirectory(), "TestMedia",
                                                     "GrandCanyonHorseShoeMesaEastSideLoop.gpx"));

            Assert.True(testFile.Exists, "GPX Test File Found");

            var lineTest = new LineContent
            {
                ContentId         = Guid.NewGuid(),
                BodyContent       = "Horseshoe Mesa East Side Loop",
                BodyContentFormat = ContentFormatDefaults.Content.ToString(),
                CreatedOn         = DateTime.Now,
                CreatedBy         = "GPX Import Test",
                Folder            = "GrandCanyon",
                Title             = "Horseshoe Mesa East Side Loop",
                Slug = "horseshoe-mesa-east-side-loop",
                ShowInMainSiteFeed = true,
                Summary            = "Horseshoe Mesa East Side Loop",
                Tags = "grand-canyon, horse-shoe-mesa",
                UpdateNotesFormat = ContentFormatDefaults.Content.ToString()
            };

            var track = (await SpatialHelpers.TracksFromGpxFile(testFile, DebugTrackers.DebugProgressTracker()))
                        .First();

            var stats = SpatialHelpers.LineStatsInMetricFromCoordinateList(track.track);

            lineTest.ClimbElevation   = stats.ElevationClimb;
            lineTest.DescentElevation = stats.ElevationDescent;
            lineTest.MinimumElevation = stats.MinimumElevation;
            lineTest.MaximumElevation = stats.MaximumElevation;
            lineTest.LineDistance     = stats.Length;

            lineTest.Line =
                await SpatialHelpers.GeoJsonWithLineStringFromCoordinateList(track.track, false,
                                                                             DebugTrackers.DebugProgressTracker());

            var validationResult = await LineGenerator.Validate(lineTest);

            Assert.IsFalse(validationResult.HasError);

            var saveResult =
                await LineGenerator.SaveAndGenerateHtml(lineTest, null, DebugTrackers.DebugProgressTracker());

            Assert.IsFalse(saveResult.generationReturn.HasError);
        }
    private void Awake()
    {
        if (Instance != null && Instance != this)
        {
            // destroy the duplicate
            Destroy(gameObject);
        }
        else
        {
            Instance = this;
        }

        if (TutorialManager.Instance != null)
        {
            isTutorial = true;
        }
    }
Example #17
0
        public void Test()
        {
            var settings = new LineGeneratorSettings(1, 5, 10, 128, ". ");

            const int expectedStringLength     = 10;
            const int expectedNumberPartLength = 1;

            var expectedNextBytes = Enumerable.Range(1, expectedStringLength).Select(x => (byte)x).ToArray();

            var expectedNumberPart = "2";
            var expectedStringPart = "456789a";

            var expectedString = $"{expectedNumberPart}{Encoding.ASCII.GetString(settings.PartsSeparatorBytes)}{expectedStringPart}";

            var randomGenerator = Substitute.For <IRandomGenerator>();

            randomGenerator
            .Next(settings.MinLineLength, settings.MaxLineLength + 1)
            .Returns(expectedStringLength);
            randomGenerator
            .Next(settings.MinNumberLength, settings.MaxNumberLength + 1)
            .Returns(expectedNumberPartLength);

            randomGenerator
            .When(x => x.NextBytes(Arg.Any <byte[]>(), Arg.Any <int>(), Arg.Any <int>()))
            .Do(callInfo => expectedNextBytes.CopyTo(callInfo.ArgAt <byte[]>(0), 0));

            var stream = Substitute.For <Stream>();

            var lineWriter = new LineGenerator(
                randomGenerator,
                settings,
                new NumberPartGenerator(),
                new StringPartGenerator());
            var lineInfo = lineWriter.GetNewLine();

            Assert.That(
                Encoding.ASCII.GetString(lineInfo.Line),
                Is.EqualTo(expectedString));
            Assert.That(
                Encoding.ASCII.GetString(lineInfo.NumberPart),
                Is.EqualTo(expectedNumberPart));
            Assert.That(
                Encoding.ASCII.GetString(lineInfo.StringPart),
                Is.EqualTo(expectedStringPart));
        }
Example #18
0
        public void WinAllGamesUsingMaximumFiveGuesses()
        {
            const int NumberOfDifferentPegs = 6;
            const int NumberOfPegsPerLine   = 4;
            const int MaxNumberOfGuesses    = 5;
            var       player = new FiveGuessAlgorithmPlayer();
            var       lines  = LineGenerator.GenerateAllLines(NumberOfDifferentPegs, NumberOfPegsPerLine);
            // it is too slow to test all lines
            // we only test on average 1% of all the different lines (roughly 13 out of 1296)
            var random = new Random();

            lines = lines.Where(l => random.Next(100) == 10).ToList();
            Assert.All(lines,
                       secret =>
            {
                var game   = new Game(NumberOfDifferentPegs, NumberOfPegsPerLine, MaxNumberOfGuesses, secret);
                var result = game.Play(player);
                Assert.True(result.WasTheSecretGuessed);
            });
        }
Example #19
0
 List <Vector3> pathPosList;//路径上按序所有点的坐标
 // Start is called before the first frame update
 void Start()
 {
     lineGenerator = GetComponent <LineGenerator>();
 }
 public static SimpleSurfaceGenerator Lathe(LineGenerator original)
 {
     return(Lathe((input) => new Vector2d(original(input), input)));
 }
Example #21
0
    public void NewGame(bool reset = true)
    {
        // Reset some stuff
        if (reset)
        {
            score        = 0;
            livesCurrent = livesMax;
        }

        // Set these to active (only useful on first start)
        elapsedGameTimeText.SetActive(true);
        scoreText.SetActive(true);
        livesText.SetActive(true);

        // Fake
        float screenLeftEdge   = -30;
        float screenRightEdge  = 30;
        float screenTopEdge    = 20;
        float screenBottomEdge = -10;
        // float screenWidth = Mathf.Abs(screenLeftEdge - screenRightEdge);
        float screenHeight = Mathf.Abs(screenTopEdge - screenBottomEdge);

        Debug.Log("New Game");
        EndGame();  // Deletes everything and sets up our scene again
        elapsedGameTime = 0f;
        gameInProgress  = true;
        if (paused)
        {
            Pause();
        }

        // Instantiate Terrain
        // Done first so we know heights for the laser base and landing pad
        Vector3 terrainPosition = new Vector3(0, 0, 0);

        terrain = Instantiate(terrainPrefab, terrainPosition, Quaternion.identity);

        // Adjust terrain settings
        LineGenerator lineGenerator = terrain.GetComponent <LineGenerator>();

        lineGenerator.offset = Random.Range(5, 500);
        // Tuned so that there is 1 segment per unit (makes the landing pad and laser height calculations easer)
        lineGenerator.leftEdge  = -1000;
        lineGenerator.rightEdge = 1000;
        lineGenerator.segments  = 2000;
        lineGenerator.GenerateLine();
        var vertices = lineGenerator.edgeVertices.ToArray();
        // Heights is reused for setting the landing pad and laser heights
        List <float> heights = new List <float>();

        for (int i = 0; i < vertices.Length; i++)
        {
            heights.Add(vertices[i].y);
        }
        float maxHeight = Mathf.Max(heights.ToArray());

        // float minHeight = Mathf.Min(heights.ToArray());

        terrain.transform.position = new Vector3(0, maxHeight * -1, 0.2f);

        // Instantiate Lander
        float   landerX        = Random.Range(screenLeftEdge / 2, screenRightEdge / 2);
        float   landerY        = Random.Range(screenTopEdge - screenHeight / 10, screenTopEdge);
        Vector3 landerPosition = new Vector3(landerX, landerY, 0);

        lander = Instantiate(landerPrefab, landerPosition, Quaternion.identity);

        // Base random position
        float baseX = Random.Range(screenLeftEdge, screenRightEdge);

        // Instantiate Landing Pad
        float landingPadX = baseX;
        int   landingPadTerrainVertexIndex = Mathf.RoundToInt(landingPadX - lineGenerator.leftEdge);

        Debug.Log(landingPadTerrainVertexIndex);
        int   landingPadWidth      = 8;
        int   landingPadHeight     = 10;
        float landingPadTerrainSum = 0f;

        for (int i = landingPadWidth * -1 / 2; i < landingPadWidth / 2; i++)
        {
            landingPadTerrainSum += heights[landingPadTerrainVertexIndex + i];
        }
        float   landingPadTerrainAverage = landingPadTerrainSum / landingPadWidth;
        float   landingPadY        = landingPadTerrainAverage + maxHeight * -1 + landingPadHeight / 2;
        Vector3 landingPadPosition = new Vector3(landingPadX, landingPadY, 0);

        landingPad = Instantiate(landingPadPrefab, landingPadPosition, Quaternion.identity);
        // Instantiate Laser Base
        float laserOffset = Random.Range(15f, 50f);

        // Randomize side laser is on
        if (Random.Range(0, 1) < 0.5f)
        {
            laserOffset *= -1;
        }
        // Make sure laser doesn't go off screen
        if (laserOffset + baseX < screenLeftEdge || laserOffset + baseX > screenRightEdge)
        {
            laserOffset *= -1;
        }
        float laserBaseX = baseX + laserOffset;
        int   laserBaseTerrainVertexIndex = Mathf.RoundToInt(laserBaseX - lineGenerator.leftEdge);

        Debug.Log(laserBaseTerrainVertexIndex);
        int   laserBaseWidth      = 14;
        int   laserBaseHeight     = 10;
        float laserBaseTerrainSum = 0f;

        for (int i = laserBaseWidth * -1 / 2; i < laserBaseWidth / 2; i++)
        {
            laserBaseTerrainSum += heights[laserBaseTerrainVertexIndex + i];
        }
        float   laserBaseTerrainAverage = laserBaseTerrainSum / laserBaseWidth;
        float   laserBaseY        = laserBaseTerrainAverage + maxHeight * -1 + laserBaseHeight / 2;
        Vector3 laserBasePosition = new Vector3(laserBaseX, laserBaseY, 0);

        laserBase = Instantiate(laserBasePrefab, laserBasePosition, Quaternion.identity);
    }
    // Generates a gridSize x gridSize grid centered on the screen, and adds N-times two points to be connected
    private void GenerateGrid(int level)
    {
        //Create all GameObjects that will compose a level
        var GO = new GameObject();

        GO.name = "Level " + level;

        var Grid = new GameObject();

        Grid.name = "Grid";

        var Lines = new GameObject();

        Lines.name = "Lines";

        LevelLineManager levelLineManager = Grid.AddComponent <LevelLineManager>();

        levelLineManager.lines = new List <LineGenerator>();

        Grid.transform.parent  = GO.transform;
        Lines.transform.parent = GO.transform;

        levelLineManager.allNodes = new GameObject[gridSize * gridSize];
        specialPositions          = new List <int>();

        //Add and setup lines
        for (int i = 0; i < numberOfLines; i++)
        {
            var           line    = Instantiate(linePrefab, Lines.transform);
            LineGenerator lineGen = line.GetComponent <LineGenerator>();
            lineGen.SetupLine((int)extremity[i].x, (int)extremity[i].y, i, colors[i]);
            levelLineManager.lines.Add(lineGen);

            specialPositions.Add(lineGen.lineExtremities[0]);
            specialPositions.Add(lineGen.lineExtremities[1]);
        }

        levelLineManager.gridLayer = gridLayer;

        //DistanceFactor makes the distance between points smaller for larger grids;
        distanceFactor = 4.5f / gridSize;

        //Generate Grid based on gridSize and number of lines
        for (int x = 0; x < gridSize; x++)
        {
            for (int y = 0; y < gridSize; y++)
            {
                GameObject gridSquare, node;

                int currentPos = x * gridSize + y; //Array position (between 0 and gridSize*gridSize - 1)

                //Actual world position of nodes / square grids
                float xWorldPos = (x - (gridSize - 1) / 2.0f) * distanceFactor;
                float yWorldPos = (y - (gridSize - 1) / 2.0f) * distanceFactor;

                gridSquare = Instantiate(gridUnit, new Vector3(xWorldPos, yWorldPos, 0), Quaternion.identity);

                if (specialPositions.Contains(currentPos))
                {
                    //Color of special nodes. Nodes of the same color are paired: [0,1] - Color1, [2,3] - Color2, etc....
                    var   listIndex = specialPositions.FindIndex(i => i == currentPos);
                    Color nodeColor = colors[(int)Mathf.Floor((float)listIndex / 2)];

                    node = Instantiate(specialNode, new Vector3(xWorldPos, yWorldPos, 0), Quaternion.identity);
                    node.GetComponent <SpriteRenderer>().color = nodeColor;
                }

                else
                {
                    node = Instantiate(standardNode, new Vector3(xWorldPos, yWorldPos, 0), Quaternion.identity);
                }

                //Parent grid to this GameObject and parent individual node to each grid space;
                gridSquare.transform.parent      = Grid.transform;
                node.transform.parent            = gridSquare.transform;
                gridSquare.transform.localScale *= 5.0f / gridSize;

                gridSquare.name = (currentPos).ToString();

                //Relation between array position with world (x,y) position stored in centerPositions
                levelLineManager.allNodes[currentPos] = node;
            }
        }
    }
Example #23
0
 public void Dispose()
 {
     Handle.Dispose();
     _lineTemplate = null;
     _nextCurve = null;
     _prevCurve = null;
     /*foreach (var line in _nextLines){
         line.Dispose();
     }
     foreach (var line in _prevLines) {
         line.Dispose();
     }
     _nextCurve.Dispose();
     _prevCurve.Dispose();*/
 }
 public ProceduralParameters StartLathe(LineGenerator original)
 {
     return(StartProcedural(SurfaceGenerators.Lathe(original)));
 }
 public static SimpleSurfaceGenerator Lathe(LineGenerator original)
 {
     return Lathe((input) => new Vector2d(original(input), input));
 }
 public ProceduralParameters StartLathe(LineGenerator original)
 {
     return StartProcedural(SurfaceGenerators.Lathe(original));
 }
    //UpdateLine
    void UpdateLine(Vector3 housePosition, string touchedHouse, Touch touch)
    {
        int hitPosition = int.Parse(touchedHouse);

        //If begin a touch, check if the touch is in a Extremety (SpecialPositions) or on the tip of an unfinished line
        if (touch.phase.ToString() == "Began")
        {
            if (specialPositions.Contains(hitPosition))
            {
                var listIndex   = specialPositions.FindIndex(i => i == hitPosition);
                int currentLine = (int)Mathf.Floor((float)listIndex / 2);

                line = lines[currentLine];
                line.ResetLine(housePosition, hitPosition, allNodes);

                generatingLine = true;
            }
            else
            {
                foreach (LineGenerator lineGen in lines)
                {
                    if ((lineGen.arrayPos.Count != 0) ? (hitPosition == lineGen.arrayPos.Last()) : false)
                    {
                        line           = lineGen;
                        generatingLine = true;
                        break;
                    }
                }
            }
        }

        //If person is moving its pressed finger, check if it went to a new unused position;
        else if (touch.phase.ToString() == "Moved" && generatingLine)
        {
            bool readyToAdd = true;
            if (!specialPositions.Contains(hitPosition) || hitPosition == line.lineExtremities[0] || hitPosition == line.lineExtremities[1])
            {
                foreach (LineGenerator lineGen in lines)
                {
                    if (lineGen.arrayPos.Contains(hitPosition) && lineGen.lineId != line.lineId)
                    {
                        readyToAdd = false;
                    }
                }
                if (readyToAdd)
                {
                    line.AddLinePoint(housePosition, hitPosition, true);
                }

                else
                {
                    generatingLine = false;
                }
            }

            else
            {
                generatingLine = false;
            }

            if (!line.lineStatus)
            {
                line.CheckLineStatus(allNodes);
            }

            if (line.lineStatus)
            {
                generatingLine = false;
            }

            CheckVictory();
        }

        else if (touch.phase.ToString() == "Ended")
        {
            generatingLine = false;
        }
    }
Example #28
0
 void OnEnable()
 {
     _lineGenerator = gameObject.GetComponent <LineGenerator>();
     totalVoxel     = (int)(boundaryLength / voxelSize) * (int)(boundaryWidth / voxelSize) * (int)(boundaryHeight / voxelSize);
 }