コード例 #1
0
ファイル: TIGrow.cs プロジェクト: jpdrude/DisCo-Code
    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
ファイル: TIGrow.cs プロジェクト: jpdrude/DisCo-Code
    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
    private void RealizeConnection()
    {
        if (lastDistAngle < connectionThreshold && ConnectionVoxelContainer.RevealConnections(bestOnPart).Contains(closestConnection))
        {
            Vector3    pos = gameObject.transform.position;
            Quaternion rot = gameObject.transform.rotation;

            AlignPlane.Orient(bestOnPart.Pln, closestConnection.Pln, gameObject);

            if (!CollisionDetection())
            {
                Part p = gameObject.GetComponent <Part>();
                p.FreezePart();
                p.Parent    = closestConnection.ParentPart.ID;
                p.ParentCon = closestConnection.ParentPart.Connections.IndexOf(closestConnection);

                ConnectionVoxelContainer.RemoveConnection(closestConnection);
                ConnectionVoxelContainer.RemoveConnection(bestOnPart);

                bestOnPart.ParentPart.SetInactive(bestOnPart);
                closestConnection.ParentPart.SetInactive(closestConnection);
                closestConnection.ParentPart.ChildCons.Add(bestOnPart.ParentPart.Connections.IndexOf(bestOnPart));

                closestConnection.ParentPart.Children.Add((int)p.ID);

                GameObject _g = PartsHolder.SpawnPart(p.TemplateID);
                _g.SetActive(true);
                if (GlobalReferences.PlacementType == PlacementTypeTool.PlaceChoreo.Choreo)
                {
                    GlobalReferences.AffectPart(_g);
                    GlobalReferences.FreeParts.Remove(_g);
                }

                ConnectionScanningHandler handler = gameObject.GetComponent <ConnectionScanningHandler>();
                if (handler != null)
                {
                    handler.TerminateConnection();
                }
            }
            else
            {
                gameObject.transform.position = pos;
                gameObject.transform.rotation = rot;
            }
        }
    }
コード例 #4
0
ファイル: TIGrow.cs プロジェクト: jpdrude/DisCo-Code
    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);
    }
コード例 #5
0
    private void RealizeConnection()
    {
        if (lastDistAngle < connectionThreshold && ConnectionVoxelContainer.RevealConnections(bestOnPart).Contains(closestConnection))
        {
            Vector3    pos = gameObject.transform.position;
            Quaternion rot = gameObject.transform.rotation;

            if (!AlignPlane.Orient(bestOnPart.Pln, closestConnection.Pln, gameObject))
            {
                gameObject.transform.position = pos;
                gameObject.transform.rotation = rot;
                return;
            }

            //PlacementBehaviour.ReleasePart(true);


            Destroy(gameObject.GetComponent <ConstantForce>());
            Destroy(gameObject.GetComponent <PartBehaviour>());
            Destroy(gameObject.GetComponent <ConnectionScanning>());

            gameObject.layer = 13;


            var check = gameObject.AddComponent <CheckCollision>();
            check.respawnPosition   = pos;
            check.respawnRotation   = rot;
            check.closestConnection = closestConnection;
            check.bestOnPart        = bestOnPart;

            if (transform.parent != null)
            {
                transform.parent = null;
            }

            GetComponent <Rigidbody>().constraints            = RigidbodyConstraints.FreezeAll;
            GetComponent <Rigidbody>().collisionDetectionMode = CollisionDetectionMode.Continuous;
            Destroy(this);

            /*
             * if (BoltNetwork.IsRunning)
             * {
             *  var checkFreeze = CheckBlockFreeze.Create(gameObject.GetComponent<NetworkBlockBehaviour>().entity);
             *  checkFreeze.BlockPosition = gameObject.transform.position;
             *  checkFreeze.BlockRotation = gameObject.transform.rotation;
             *
             *  checkFreeze.OldBlockPosition = pos;
             *  checkFreeze.OldBlockRotation = rot;
             *
             *  if (closestConnection.ParentPart.ID != null)
             *  {
             *      checkFreeze.ParentID = (int)closestConnection.ParentPart.ID;
             *  }
             *  else
             *  {
             *      checkFreeze.ParentID = -1;
             *  }
             *
             *  checkFreeze.ParentCon = closestConnection.ParentPart.Connections.IndexOf(closestConnection);
             *  checkFreeze.ConnectionID = gameObject.GetComponent<Part>().Connections.IndexOf(bestOnPart);
             *
             *  checkFreeze.Send();
             * }
             */
        }
    }