Exemplo n.º 1
0
        private void RegisterPartRandom(BugPart part, Connection[] posibleConnections, IConnectable parent)
        {
            if (part.SetConnection(M.Mathn.SelectRandmo(posibleConnections, GeneratorController.SafeRandom()), parent, ((MonoBehaviour)parent).gameObject, this))
            {
                Locations.Add(part.transform.position);
                mBugParts.Add(part);

                if (part is IConnectable)
                {
                    mConnectables.Add(part as IConnectable);
                }

                if (mFuctionParts.ContainsKey(part.GetType()))
                {
                    mFuctionParts[part.GetType()].Add(part);
                }
            }
        }
        private async Task <Tuple <IConnectable, Connection[]> > GetRandomConnector()
        {
            IConnectable Connector = M.Mathn.SelectRandmo(mConnectables.ToArray(), GeneratorController.SafeRandom());

            Connection[] openConnections = await Connector.GetOpenConnections();

            for (int d = 0; d < 10; d++)
            {
                if (openConnections[0] != Connection.None)
                {
                    break;
                }

                Connector       = M.Mathn.SelectRandmo(mConnectables.ToArray(), GeneratorController.SafeRandom());
                openConnections = await Connector.GetOpenConnections();
            }
            return(new Tuple <IConnectable, Connection[]>(Connector, openConnections));
        }