Example #1
0
    private void CreateFencePiece(Vector3 startPos, Vector3 endPos)
    {
        float      yRot = GetYRotation(startPos, endPos);
        GameObject g    = (GameObject)Instantiate(wallObject, startPos, Quaternion.Euler(new Vector3(0, (yRot + 90) + 180, 0)));

        g.transform.localScale = new Vector3(Vector3.Distance(startPos, endPos), g.transform.localScale.y, g.transform.localScale.z);
        if (animate)
        {
            PopupAnimation pA = g.AddComponent <PopupAnimation>();
            pA.SetInitialScales(g.transform.localScale, 0);
        }
    }
Example #2
0
    // TODO: If node at pathpoint and to pathpoint are blocked ignore spawning
    private void PathDone()
    {
        if (pathPoints.Count < 2)
        {
            return;
        }

        for (int i = 0; i < pathPoints.Count - 1; i++)
        {
            float      yRot = GetYRotation(pathPoints[i], pathPoints[i + 1]);
            GameObject g    = (GameObject)Instantiate(wallObject, pathPoints[i], Quaternion.Euler(new Vector3(0, (yRot + 90) + 180, 0)));
            g.transform.localScale = new Vector3(Vector3.Distance(pathPoints[i], pathPoints[i + 1]), 1, 1);
            if (animate)
            {
                PopupAnimation pA = g.AddComponent <PopupAnimation>();
                pA.SetInitialScales(g.transform.localScale, i);
            }
        }

        for (int i = 1; i < pathPoints.Count; i++)
        {
            Wall wall = new Wall();
            foreach (TileNode n in worldController._grid)
            {
                n.SetWall(worldController.GetAnchorFromPos(pathPoints[i - 1]), worldController.GetAnchorFromPos(pathPoints[i]), wall);
            }
        }

        foreach (AnchorNode a in worldController._anchors)
        {
            a.SetAnchorState(AnchorState.None);
        }

        pathPoints.Clear();
        startPos = Vector3.zero;
        nextPos  = Vector3.zero;
        canBuild = true;
    }