Ejemplo n.º 1
0
 public void DigCube()
 {
     if (chosenCube == null)
     {
         return;
     }
     else
     {
         if (faceIndex == 4)
         {
             SurfaceBlock sb = chosenCube.myChunk.GetBlock(chosenCube.pos.x, chosenCube.pos.y + 1, chosenCube.pos.z) as SurfaceBlock;
             if (sb == null)
             {
                 DigSite ds = chosenCube.gameObject.AddComponent <DigSite>();
                 ds.Set(chosenCube, true);
                 workingObserver = ds.ShowOnGUI(); // вообще они должны сами в конце цепочки устанавливать здесь workingObserver, не?
             }
             else
             {
                 CleanSite cs = chosenCube.gameObject.AddComponent <CleanSite>();
                 cs.Set(sb, true);
                 workingObserver = cs.ShowOnGUI();
             }
         }
         else
         {
             if (faceIndex < 4)
             {
                 TunnelBuildingSite tbs = chosenCube.gameObject.AddComponent <TunnelBuildingSite>();
                 tbs.Set(chosenCube);
                 tbs.CreateSign(faceIndex);
                 workingObserver = tbs.ShowOnGUI();
             }
         }
     }
 }
Ejemplo n.º 2
0
    public void ChangeChosenObject(ChosenObjectType newChosenType)
    {
        if (hospitalPanel.activeSelf)
        {
            DeactivateHospitalPanel();
        }
        else
        {
            if (expeditionCorpusPanel.activeSelf)
            {
                DeactivateExpeditionCorpusPanel();
            }
            else
            {
                if (rollingShopPanel.activeSelf)
                {
                    DeactivateRollingShopPanel();
                }
            }
        }

        //отключение предыдущего observer
        if (workingObserver != null)
        {
            workingObserver.ShutOff();
            workingObserver = null;
        }
        bool disableCubeMenuButtons = true, changeFrameColor = true;

        if (newChosenType == ChosenObjectType.None)
        {
            rightPanel.SetActive(false);
            selectionFrame.gameObject.SetActive(false);
            chosenObjectType = ChosenObjectType.None;
            chosenWorksite   = null;
            chosenStructure  = null;
            chosenCube       = null;
            chosenSurface    = null;
            faceIndex        = 10;
            changeFrameColor = false;
        }
        else
        {
            chosenObjectType = newChosenType;
            rightPanel.transform.SetAsLastSibling();
            rightPanel.SetActive(true);
            disableCubeMenuButtons = true;
            selectionFrame.gameObject.SetActive(true);
            if (showMenuWindow)
            {
                MenuButton();
            }
        }

        Vector3 sframeColor = Vector3.one;

        switch (chosenObjectType)
        {
        case ChosenObjectType.Surface:
        {
            faceIndex = 10;         // вспомогательная дата для chosenCube
            selectionFrame.position   = chosenSurface.transform.position + Vector3.down * Block.QUAD_SIZE / 2f;
            selectionFrame.rotation   = Quaternion.identity;
            selectionFrame.localScale = new Vector3(SurfaceBlock.INNER_RESOLUTION, 1, SurfaceBlock.INNER_RESOLUTION);
            sframeColor = new Vector3(140f / 255f, 1, 1);

            workingObserver = chosenSurface.ShowOnGUI();
            FollowingCamera.main.SetLookPoint(chosenSurface.transform.position);
        }
        break;

        case ChosenObjectType.Cube:
        {
            selectionFrame.position = chosenCube.faces[faceIndex].transform.position;
            switch (faceIndex)
            {
            case 0: selectionFrame.transform.rotation = Quaternion.Euler(90, 0, 0); break;

            case 1: selectionFrame.transform.rotation = Quaternion.Euler(0, 0, -90); break;

            case 2: selectionFrame.transform.rotation = Quaternion.Euler(-90, 0, 0); break;

            case 3: selectionFrame.transform.rotation = Quaternion.Euler(0, 0, 90); break;

            case 4: selectionFrame.transform.rotation = Quaternion.identity; break;

            case 5: selectionFrame.transform.rotation = Quaternion.Euler(-180, 0, 0); break;
            }
            selectionFrame.localScale = new Vector3(SurfaceBlock.INNER_RESOLUTION, 1, SurfaceBlock.INNER_RESOLUTION);
            sframeColor = new Vector3(140f / 255f, 1, 0.9f);
            FollowingCamera.main.SetLookPoint(chosenCube.transform.position);

            Transform t = rightPanel.transform;
            t.GetChild(RPANEL_CUBE_DIG_BUTTON_INDEX).gameObject.SetActive(true);
            if (chosenCube.excavatingStatus != 0)
            {
                t.GetChild(RPANEL_CUBE_DIG_BUTTON_INDEX + 1).gameObject.SetActive(true);
            }
            else
            {
                t.GetChild(RPANEL_CUBE_DIG_BUTTON_INDEX + 1).gameObject.SetActive(false);
            }
            disableCubeMenuButtons = false;
        }
        break;

        case ChosenObjectType.Structure:
            faceIndex = 10;     // вспомогательная дата для chosenCube
            selectionFrame.position   = chosenStructure.transform.position;
            selectionFrame.rotation   = chosenStructure.transform.rotation;
            selectionFrame.localScale = new Vector3(chosenStructure.innerPosition.size, 1, chosenStructure.innerPosition.size);
            sframeColor     = new Vector3(1, 0, 1);
            workingObserver = chosenStructure.ShowOnGUI();
            FollowingCamera.main.SetLookPoint(chosenStructure.transform.position);
            break;

        case ChosenObjectType.Worksite:
            faceIndex = 10;     // вспомогательная дата для chosenCube
            selectionFrame.gameObject.SetActive(false);
            changeFrameColor = false;
            workingObserver  = chosenWorksite.ShowOnGUI();
            FollowingCamera.main.SetLookPoint(chosenWorksite.sign.transform.position);
            break;
        }
        if (disableCubeMenuButtons)
        {
            Transform t = rightPanel.transform;
            t.GetChild(RPANEL_CUBE_DIG_BUTTON_INDEX).gameObject.SetActive(false);
            t.GetChild(RPANEL_CUBE_DIG_BUTTON_INDEX + 1).gameObject.SetActive(false);
        }
        if (changeFrameColor)
        {
            selectionFrameMaterial.SetColor("_TintColor", Color.HSVToRGB(sframeColor.x, sframeColor.y, sframeColor.z));
            selectionFrame.gameObject.SetActive(true);
        }
    }