public ConstructionSiteDisplayObject ShowConstructionSite(ConstructionSite newSite)
    {
        Building building = newSite.Building;

        GameObject siteObjectPrefab = null;
        for (int i = 0; i < buildingDisplay.Length; i++)
        {
            if (buildingDisplay[i] != null && buildingDisplay[i].Type == building.Type)
            {
                siteObjectPrefab = buildingDisplay[i].ConstructionSiteObject;
                break;
            }
        }

        if (siteObjectPrefab == null)
        {
            return null;
        }

        GameObject gameObject = GameObject.Instantiate(
            siteObjectPrefab,
            new Vector3(building.Tiles[0].Position.X,
                        building.Tiles[0].Position.Height * LevelHeightOffset,
                        building.Tiles[0].Position.Y),
            Quaternion.identity,
            ConstructionSitesParent.transform
            );

        RotateGameObject(gameObject, building.Rotation);

        bool builtOnSecondLevel = (building.Tiles[0].Position.Height > 0);

        ConstructionSiteDisplayObject selectableObject = gameObject.GetComponentInChildren<ConstructionSiteDisplayObject>();

        building.AssignDisplayObject(selectableObject);
        selectableObject.AssignConstructionSite(newSite, builtOnSecondLevel);

        return selectableObject;
    }
Example #2
0
    public void AssignSelectedObject(ISelectable obj)
    {
        HidePanels();

        if (obj is Building)
        {
            PanelVisible = true;

            Building building = (Building)obj;

            if (building.Module == null)
            {
                if (building.GetDisplayObject() is ConstructionSiteDisplayObject)
                {
                    ConstructionSiteDisplayObject cds = (ConstructionSiteDisplayObject)building.GetDisplayObject();
                    ConstructionPanel.gameObject.SetActive(true);
                    ConstructionPanel.SetConstructionSite(cds.ConstructionSite);

                    BuildingModulePanel.gameObject.SetActive(true);
                    BuildingModulePanel.SetModule(cds.ConstructionSite);
                }
                else if (building.Type == "Stairs" ||
                         building.Type == "Platform" ||
                         building.Type == "Slab")
                {
                    OtherBuildingPanel.gameObject.SetActive(true);
                    OtherBuildingPanel.SetOtherBuilding(building);
                }
            }
            else
            {
                if (building.Module is Storage)
                {
                    StoragePanel.gameObject.SetActive(true);
                    StoragePanel.SetStorage((Storage)building.Module);
                }
                else if (building.Module is Factory)
                {
                    if (((Factory)building.Module).IsNaturalDeposit)
                    {
                        NaturalDepositPanel.gameObject.SetActive(true);
                        NaturalDepositPanel.SetDeposit((Factory)building.Module);
                    }
                    else
                    {
                        FactoryPanel.gameObject.SetActive(true);
                        FactoryPanel.SetFactory((Factory)building.Module);
                    }
                }
                else if (building.Module is Service)
                {
                    ServicePanel.gameObject.SetActive(true);
                    ServicePanel.SetService((Service)building.Module);
                }

                if (building.Prototype.IsNaturalDeposit)
                {
                    return;
                }

                BuildingModulePanel.gameObject.SetActive(true);
                BuildingModulePanel.SetModule(building.Module);
            }
        }
        else
        if (obj is Character)
        {
            PanelVisible = true;

            Character c = (Character)obj;
            if (c.IsRobot)
            {
                RobotPanel.gameObject.SetActive(true);
                RobotPanel.SetRobot(c);
            }
            else
            {
                CharacterPanel.gameObject.SetActive(true);
                CharacterPanel.SetCharacter(c);
            }
        }
    }