Пример #1
0
    public void Right()
    {
        if (choseChild && !choseChildConnection)
        {
            if (childIndex == -1)
            {
                return;
            }

            childProxies[childIndex].SetActive(false);
            ++childIndex;
            if (childIndex >= childProxies.Count)
            {
                childIndex = 0;
            }

            childProxies[childIndex].SetActive(true);
            childProxies[childIndex].GetComponent <MeshRenderer>().material = MaterialHolder.SelectedMat;
        }
        else if (choseChildConnection)
        {
            Part childPart = childProxies[childIndex].GetComponent <Part>();
            ++conIndex;
            if (conIndex >= childPart.ActiveConnections.Count)
            {
                conIndex = 0;
            }

            if (ConnectionScanning.RuleActive(chosenConnection, childPart.Connections[childPart.ActiveConnections[conIndex]]))
            {
                bool orientCheck = false;
                for (int i = 0; i < 10; ++i)
                {
                    orientCheck = AlignPlane.Orient(childPart.Connections[childPart.ActiveConnections[conIndex]].Pln, chosenConnection.Pln, childProxies[childIndex]);
                    if (orientCheck)
                    {
                        break;
                    }
                }
                if (!orientCheck)
                {
                    Right();
                }
            }
            else
            {
                Right();
            }

            childProxies[childIndex].GetComponent <MeshRenderer>().material = MaterialHolder.SelectedMat;
        }
    }
Пример #2
0
    public void Left()
    {
        if (choseChild && !choseChildConnection)
        {
            if (childIndex == -1)
            {
                return;
            }

            childProxies[childIndex].SetActive(false);
            --childIndex;
            if (childIndex < 0)
            {
                childIndex = childProxies.Count - 1;
            }

            childProxies[childIndex].SetActive(true);
        }
        else if (choseChildConnection)
        {
            Part childPart = childProxies[childIndex].GetComponent <Part>();
            --conIndex;
            if (conIndex < 0)
            {
                conIndex = childPart.ActiveConnections.Count - 1;
            }

            if (ConnectionScanning.RuleActive(chosenConnection, childPart.Connections[childPart.ActiveConnections[conIndex]]))
            {
                bool orientCheck = false;
                for (int i = 0; i < 10; ++i)
                {
                    orientCheck = AlignPlane.Orient(childPart.Connections[childPart.ActiveConnections[conIndex]].Pln, chosenConnection.Pln, childProxies[childIndex]);
                    if (orientCheck)
                    {
                        break;
                    }
                }
                if (!orientCheck)
                {
                    Left();
                }
            }
            else
            {
                Left();
            }
        }
    }
Пример #3
0
    List <GameObject> SpawnChildProxies(Connection c)
    {
        List <GameObject> childPartsProxies = new List <GameObject>();

        for (int i = 0; i < GlobalReferences.TemplateParts.Count; ++i)
        {
            GameObject go = PartsHolder.Holder.SpawnGhostPart(i);
            go.AddComponent <CheckGrowCollision>();
            Destroy(go.GetComponent <ConnectionScanning>());

            List <Connection> templateCons = new List <Connection>();
            Part templatePart = go.GetComponent <Part>();

            foreach (int id in templatePart.ActiveConnections)
            {
                templateCons.Add(templatePart.Connections[id]);
            }

            foreach (Connection templateC in templateCons)
            {
                if (ConnectionScanning.RuleActive(templateC, c))
                {
                    AlignPlane.Orient(templateC.Pln, c.Pln, go);
                    go.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeAll;
                    childPartsProxies.Add(go);
                    go.SetActive(false);
                    break;
                }
            }

            if (!childPartsProxies.Contains(go))
            {
                Destroy(go);
            }
        }

        if (childPartsProxies.Count > 0)
        {
            childPartsProxies[0].SetActive(true);
            childIndex = 0;
        }

        return(childPartsProxies);
    }