コード例 #1
0
    public Building CreateBuilding(TriDirection dir, TriCell cell, Building prefab)
    {
        List <BuildState> result = prefab.GetBuildStatus(cell.coordinates, dir);
        bool buildable           = true;

        foreach (BuildState i in result)
        {
            if (!i.value)
            {
                buildable = false;
            }
        }
        if (cell && buildable)
        {
            Building ret = Instantiate(prefab);
            ret.ID       = entities.BuildingCount;
            ret.Location = cell;
            switch (ret.sizeType)
            {
            case SizeType.SINGLE:
                cell.Statics = ret;
                break;

            case SizeType.HEX:
                TriCell      k    = cell;
                TriDirection tDir = dir.Previous();
                for (int i = 0; i < 6; i++)
                {
                    if (!k)
                    {
                        break;
                    }
                    k.Statics = ret;
                    k         = k.GetNeighbor(tDir);
                    tDir      = tDir.Next();
                }
                break;
            }
            ret.EntranceDirection = dir;
            ret.personList        = personList;
            entities.AddBuilding(ret);
            island.ShowSummary = island.ShowSummary;
            Debug.Log(ret + " built");
            return(ret);
        }
        else
        {
            Debug.Log("building failed");
            return(null);
        }
    }
コード例 #2
0
    public Building CreateBuilding(TriDirection dir, TriCell cell, Building prefab)
    {
        if (cell && Entity.IsBuildable(dir, cell.coordinates, prefab.sizeType))
        {
            Building ret = Instantiate(prefab);
            ret.ID       = entities.BuildingCount;
            ret.Location = cell;
            switch (ret.sizeType)
            {
            case SizeType.SINGLE:
                cell.Statics = ret;
                break;

            case SizeType.HEX:
                TriCell      k    = cell;
                TriDirection tDir = dir.Previous();
                for (int i = 0; i < 6; i++)
                {
                    if (!k)
                    {
                        break;
                    }
                    k.Statics = ret;
                    k         = k.GetNeighbor(tDir);
                    tDir      = tDir.Next();
                }
                break;
            }
            ret.EntranceDirection = dir;
            ret.personList        = personList;
            entities.AddBuilding(ret);
            Debug.Log("camp built");
            return(ret);
        }
        else
        {
            Debug.Log("building failed");
            return(null);
        }
    }