コード例 #1
0
ファイル: RoomSpawning.cs プロジェクト: ADRC4-2019-2020/Lith
        public ParseSharedSpace(string spaceFunction, List <string> spaceRequired, List <string[]> timeSchedule, List <SpatialVoidVoxel> theseSpacesExist)
        {
            int SharingIndex = 2;

            // Since the schedule always has the same number of hours for all user( the schedule can have 24 hours rather than just 12, its easier to keep track right now)
            for (int index = 0; index < timeSchedule[0].Length; index++)
            {
                List <string> temp = new List <string>();

                foreach (var item in timeSchedule)
                {
                    temp.Add(item[index]);

                    if (item[index] == spaceFunction && temp.Count(t => t == spaceFunction) > spaceRequired.Count)
                    {
                        spaceRequired.Add(item[index]);
                    }
                }
            }

            for (int i = 0; i < spaceRequired.Count / SharingIndex; i++)
            {
                var Room = new SpatialVoidVoxel(1, spaceFunction, Vector3Int.zero + new Vector3Int(Random.Range(-5, 5), Random.Range(-3, 3), Random.Range(-8, 8)), Quaternion.identity);
                theseSpacesExist.Add(Room);
            }
        }
コード例 #2
0
ファイル: RoomSpawning.cs プロジェクト: ADRC4-2019-2020/Lith
    void SpaceParser()
    {
        int Xoffset = 0;

        // For Private functions for each user check if the user has the spaceFunction Bed or Bath in his Schedule if he does then make that spaceFunction once for that user
        foreach (var User in Schedule)
        {
            List <string> Spacethere = new List <string> {
            };

            foreach (var spaceFunction in User)
            {
                if (spaceFunction == "Bath" || spaceFunction == "Bed")
                {
                    if (!Spacethere.Any(s => s == spaceFunction))
                    {
                        space = new SpatialVoidVoxel(Schedule.IndexOf(User), SpaceObject, Vector3Int.zero + new Vector3Int(Random.Range(-8, 8), Random.Range(-3, 3), Random.Range(-10, 10)), Quaternion.identity);
                        ListOfSpaces.Add(space);
                        Spacethere.Add(spaceFunction);
                    }
                }
            }
        }

        // For public functions in the Schedule check which time has the largest need for that function then divide that need by sharing index(how many people share spaceFunction) to make the spaceFunction
        // create a list for requirement of each function
        List <string> NumKitchen    = new List <string> {
        };
        List <string> NumWorkspace  = new List <string> {
        };
        List <string> NumOut        = new List <string> {
        };
        List <string> NumLivingRoom = new List <string> {
        };


        // use the logic of sorting through schedule to find how many spaceFunction
        ParseSharedSpace LivingRoom = new ParseSharedSpace(SpaceObject, NumLivingRoom, Schedule, ListOfSpaces);
        ParseSharedSpace Workspace  = new ParseSharedSpace(SpaceObject, NumWorkspace, Schedule, ListOfSpaces);
        ParseSharedSpace Kitchen    = new ParseSharedSpace(SpaceObject, NumKitchen, Schedule, ListOfSpaces);
        ParseSharedSpace Out        = new ParseSharedSpace(SpaceObject, NumOut, Schedule, ListOfSpaces);


        // Both Private and Public spaces which need to exist are instantiated as game objects and stored in gameobject list go
        // each function is right now a single voxel, but would make that into a bunch of voxels defined by their relation to each other later
        foreach (var Space in ListOfSpaces)
        {
            SpaceAsVoxel = Instantiate(Resources.Load <GameObject>(Space.FunctionTypes), Space.Location, Space.Rotation);
            go.Add(SpaceAsVoxel);
        }
    }
コード例 #3
0
ファイル: Matrix.cs プロジェクト: ADRC4-2019-2020/Lith
    // Defining what score each space gets to move closer to every other space,
    // would have to localize its effects as optimization halts currently
    // Also I know this is probably a terrible way of defining these. Couldn't figure out a better way yet, but will soon.

    public Matrix(SpatialVoidVoxel sVVoxel, List <SpatialVoidVoxel> mBuiltSpaces, Vector3Int changedPos)
    {
        SVoidVoxel   = sVVoxel;
        MBuiltSpaces = mBuiltSpaces;


        foreach (var item in mBuiltSpaces)
        {
            var initialDist = item.Location - sVVoxel.Location;
            var changedDist = item.Location - changedPos;


            if (sVVoxel.FunctionTypes == "Bed")
            {
                //
                if (item.FunctionTypes == "Bed")
                {
                    fitness     = initialDist.magnitude < changedDist.magnitude ? 2 : 0;
                    fitnessSum += fitness;
                }
                if (item.FunctionTypes == "Bath")
                {
                    fitness     = initialDist.magnitude < changedDist.magnitude ? 0 : 6;
                    fitnessSum += fitness;
                }
                if (item.FunctionTypes == "LivingRoom")
                {
                    fitness     = initialDist.magnitude < changedDist.magnitude ? 0 : 2;
                    fitnessSum += fitness;
                }
                if (item.FunctionTypes == "WorkSpace")
                {
                    fitness     = initialDist.magnitude < changedDist.magnitude ? 0 : 0;
                    fitnessSum += fitness;
                }
                if (item.FunctionTypes == "Kitchen")
                {
                    fitness     = initialDist.magnitude < changedDist.magnitude ? 0 : 1;
                    fitnessSum += fitness;
                }
                if (item.FunctionTypes == "Out")
                {
                    fitness     = initialDist.magnitude < changedDist.magnitude ? 0 : 0;
                    fitnessSum += fitness;
                }
            }


            if (sVVoxel.FunctionTypes == "Bath")
            {
                if (item.FunctionTypes == "Bed")
                {
                    fitness     = initialDist.magnitude < changedDist.magnitude ? 0: 4;
                    fitnessSum += fitness;
                }
                if (item.FunctionTypes == "Bath")
                {
                    fitness     = initialDist.magnitude < changedDist.magnitude ? 4 : 0;
                    fitnessSum += fitness;
                }
                if (item.FunctionTypes == "LivingRoom")
                {
                    fitness     = initialDist.magnitude < changedDist.magnitude ? 0 : 0;
                    fitnessSum += fitness;
                }
                if (item.FunctionTypes == "WorkSpace")
                {
                    fitness     = initialDist.magnitude < changedDist.magnitude ? 0 : 0;
                    fitnessSum += fitness;
                }
                if (item.FunctionTypes == "Kitchen")
                {
                    fitness     = initialDist.magnitude < changedDist.magnitude ? 0 : 0;
                    fitnessSum += fitness;
                }
                if (item.FunctionTypes == "Out")
                {
                    fitness     = initialDist.magnitude < changedDist.magnitude ? 0 : 0;
                    fitnessSum += fitness;
                }
            }


            if (sVVoxel.FunctionTypes == "LivingRoom")
            {
                if (item.FunctionTypes == "Bed")
                {
                    fitness     = initialDist.magnitude < changedDist.magnitude ? 0 : 3;
                    fitnessSum += fitness;
                }


                if (item.FunctionTypes == "Bath")
                {
                    fitness     = initialDist.magnitude < changedDist.magnitude ? 0 : 1;
                    fitnessSum += fitness;
                }


                if (item.FunctionTypes == "LivingRoom")
                {
                    fitness     = initialDist.magnitude < changedDist.magnitude ? 6 : 0;
                    fitnessSum += fitness;
                }


                if (item.FunctionTypes == "WorkSpace")
                {
                    fitness     = initialDist.magnitude < changedDist.magnitude ? 0 : 2;
                    fitnessSum += fitness;
                }


                if (item.FunctionTypes == "Kitchen")
                {
                    fitness     = initialDist.magnitude < changedDist.magnitude ? 0 : 3;
                    fitnessSum += fitness;
                }


                if (item.FunctionTypes == "Out")
                {
                    fitness     = initialDist.magnitude < changedDist.magnitude ? 0 : 2;
                    fitnessSum += fitness;
                }
            }


            if (sVVoxel.FunctionTypes == "WorkSpace")
            {
                if (item.FunctionTypes == "Bed")
                {
                    fitness     = initialDist.magnitude < changedDist.magnitude ? 0 : 2;
                    fitnessSum += fitness;
                }


                if (item.FunctionTypes == "Bath")
                {
                    fitness     = initialDist.magnitude < changedDist.magnitude ? 0 : 0;
                    fitnessSum += fitness;
                }


                if (item.FunctionTypes == "LivingRoom")
                {
                    fitness     = initialDist.magnitude < changedDist.magnitude ? 0 : 4;
                    fitnessSum += fitness;
                }


                if (item.FunctionTypes == "WorkSpace")
                {
                    fitness     = initialDist.magnitude < changedDist.magnitude ? 6 : 0;
                    fitnessSum += fitness;
                }


                if (item.FunctionTypes == "Kitchen")
                {
                    fitness     = initialDist.magnitude < changedDist.magnitude ? 0 : 2;
                    fitnessSum += fitness;
                }


                if (item.FunctionTypes == "Out")
                {
                    fitness     = initialDist.magnitude < changedDist.magnitude ? 0 : 0;
                    fitnessSum += fitness;
                }
            }



            if (sVVoxel.FunctionTypes == "Kitchen")
            {
                if (item.FunctionTypes == "Bed")
                {
                    fitness     = initialDist.magnitude < changedDist.magnitude ? 0 : 2;
                    fitnessSum += fitness;
                }
                if (item.FunctionTypes == "Bath")
                {
                    fitness     = initialDist.magnitude < changedDist.magnitude ? 0 : 0;
                    fitnessSum += fitness;
                }
                if (item.FunctionTypes == "LivingRoom")
                {
                    fitness     = initialDist.magnitude < changedDist.magnitude ? 0 : 4;
                    fitnessSum += fitness;
                }
                if (item.FunctionTypes == "WorkSpace")
                {
                    fitness     = initialDist.magnitude < changedDist.magnitude ? 0 : 3;
                    fitnessSum += fitness;
                }
                if (item.FunctionTypes == "Kitchen")
                {
                    fitness     = initialDist.magnitude < changedDist.magnitude ? 6 : 0;
                    fitnessSum += fitness;
                }
                if (item.FunctionTypes == "Out")
                {
                    fitness     = initialDist.magnitude < changedDist.magnitude ? 0 : 0;
                    fitnessSum += fitness;
                }
            }



            if (sVVoxel.FunctionTypes == "Out")
            {
                if (item.FunctionTypes == "Bed")
                {
                    fitness    = initialDist.magnitude < changedDist.magnitude ? 0 : 0;
                    fitnessSum = fitnessSum + fitness;
                }
                else if (item.FunctionTypes == "Bath")
                {
                    fitness    = initialDist.magnitude < changedDist.magnitude ? 0 : 0;
                    fitnessSum = fitnessSum + fitness;
                }
                else if (item.FunctionTypes == "LivingRoom")
                {
                    fitness    = initialDist.magnitude < changedDist.magnitude ? 0 : 3;
                    fitnessSum = fitnessSum + fitness;
                }
                else if (item.FunctionTypes == "WorkSpace")
                {
                    fitness    = initialDist.magnitude < changedDist.magnitude ? 0 : 0;
                    fitnessSum = fitnessSum + fitness;
                }
                else if (item.FunctionTypes == "Kitchen")
                {
                    fitness    = initialDist.magnitude < changedDist.magnitude ? 0 : 0;
                    fitnessSum = fitnessSum + fitness;
                }
                else if (item.FunctionTypes == "Out")
                {
                    fitness    = initialDist.magnitude < changedDist.magnitude ? 1 : 0;
                    fitnessSum = fitnessSum + fitness;
                }
            }
        }
    }