Esempio n. 1
0
    /// <summary>
    /// Creates the  parts of a bridge visualiiy. This is the part thats is on the ground
    /// </summary>
    /// <param name="iniPos"></param>
    public List <StructureParent> CreatePartListOnGround(List <Vector3> iniPos, List <int> partsP, Transform containerP, H dominantSideP)
    {
        List <StructureParent> res = new List <StructureParent>();
        StructureParent        g   = null;

        for (int i = 0; i < partsP.Count; i++)
        {
            if (partsP[i] == 10)
            {
                g = StructureParent.CreateStructureParent(ReturnBridgePartRoot(partsP[i]), iniPos[i], BridgeUnit(), container: containerP,
                                                          startingStage: StartingStageForPieces);
                g.transform.Rotate(new Vector3(0, 180, 0));
            }
            else if (partsP[i] == 11)
            {
                g = StructureParent.CreateStructureParent(ReturnBridgePartRoot(partsP[i]), iniPos[i], BridgeUnit(), container: containerP,
                                                          startingStage: StartingStageForPieces);
            }
            else if (partsP[i] == 12)
            {
                g = StructureParent.CreateStructureParent(ReturnBridgePartRoot(partsP[i]), iniPos[i], BridgeUnit(), container: containerP,
                                                          startingStage: StartingStageForPieces);
            }

            if (dominantSideP == H.Vertic)
            {
                g.transform.Rotate(new Vector3(0, 270, 0));
            }
            g = ReSizeObj(g, partsP[i], dominantSideP);
            res.Add(g);
        }
        return(res);
    }
Esempio n. 2
0
    static public StructureParent CreateStructureParent(string root, Vector3 origen, H hType, string name = "", Transform container = null,
                                                        bool isLoadingFromFile = false, string materialKey = "", H startingStage = H.None)
    {
        WAKEUP = true;
        StructureParent obj = null;

        obj                   = (StructureParent)Resources.Load(root, typeof(Building));
        obj                   = (StructureParent)Instantiate(obj, origen, Quaternion.identity);
        obj.HType             = hType;
        obj.transform.name    = obj.MyId = obj.Rename(obj.transform.name, obj.Id, obj.HType, name);
        obj.IsLoadingFromFile = isLoadingFromFile;

        obj.ClosestSubMeshVert = origen;
        if (name != "")
        {
            obj.name = name;
        }
        if (container != null)
        {
            obj.transform.SetParent(container);
        }

        if (materialKey == "")
        {
            materialKey = hType + "." + Ma.matBuildBase;
        }

        obj.StartingStage = startingStage;
        //obj.MaterialKey = materialKey;
        //obj.Geometry.GetComponent<Renderer>().sharedMaterial = Resources.Load(Root.RetMaterialRoot(materialKey)) as Material;

        return(obj);
    }
Esempio n. 3
0
    /// <summary>
    /// If is in construction will add percentage of completion
    /// </summary>
    /// <returns></returns>
    private string IfInConstructionAddPercentageOfCompletion()
    {
        StructureParent sP = Building.ReturnCurrentStructureParent();

        if (sP.CurrentStage != 4)
        {
            var percentage = sP.PercentageBuiltCured();
            return("Construction progress at: " + percentage + "%\n" +
                   MaterialsGathered() + "\n" + MaterialsIsMissing() + "\n\n");
        }
        return("");
    }
Esempio n. 4
0
    private List <Vector3> GiveTwoTops(Vector3 from)
    {
        List <StructureParent> parts = GiveTheTwoEndsParts10and12();

        StructureParent close = null;
        StructureParent far   = null;

        FindCloseAndFar(from, parts, out close, out far);

        return(new List <Vector3>()
        {
            close.TopIn(), far.TopOut()
        });
    }
Esempio n. 5
0
    /// <summary>
    /// Will give the 2 ends of a brdige
    /// </summary>
    /// <returns></returns>
    public List <Vector3> GiveTwoBottoms(Vector3 from)
    {
        List <StructureParent> parts = GiveTheTwoEndsParts10and12();

        StructureParent close = null;
        StructureParent far   = null;

        FindCloseAndFar(from, parts, out close, out far);

        return(new List <Vector3>()
        {
            close.BottonIn(), far.BottonOut()
        });
    }
Esempio n. 6
0
    private void FindCloseAndFar(Vector3 from, List <StructureParent> list, out StructureParent close,
                                 out StructureParent far)
    {
        float dist0 = Vector3.Distance(from, list[0].transform.position);
        float dist1 = Vector3.Distance(from, list[1].transform.position);

        if (dist0 < dist1)
        {
            close = list[0];
            far   = list[1];
        }
        else
        {
            close = list[1];
            far   = list[0];
        }
    }
Esempio n. 7
0
    /// <summary>
    /// Creates the parts list on air
    /// </summary>
    private void CreatePartListOnAir()
    {
        if (loopCounter < PartsOnAir.Count)
        {
            StructureParent sP   = null;
            string          root = "";
            if (PartsOnAir[loopCounter] == 1)
            {
                root = ReturnBridgePartRoot(PartsOnAir[loopCounter]);
            }
            else if (PartsOnAir[loopCounter] == 2)
            {
                root = ReturnBridgePartRoot(PartsOnAir[loopCounter]);
            }
            else if (PartsOnAir[loopCounter] == 3)
            {
                root = ReturnBridgePartRoot(PartsOnAir[loopCounter]);
            }
            else if (PartsOnAir[loopCounter] == 4)
            {
                root = ReturnBridgePartRoot(PartsOnAir[loopCounter]);
            }

            sP = StructureParent.CreateStructureParent(root, PlanesOnAirPos[loopCounter], BridgeUnit(),
                                                       container: transform,
                                                       startingStage: StartingStageForPieces);

            if (_dominantSide == H.Vertic)
            {
                sP.transform.Rotate(new Vector3(0, 270, 0));
            }
            sP = ReSizeObj(sP, PartsOnAir[loopCounter], _dominantSide);
            Pieces.Add(sP);
            loopCounter++;
        }
        else
        {
            createAirPartsNow  = false;
            loopCounter        = 0;
            createSoilPartsNow = true;

            //so crystals are added to ground right away
            PrivHandleZoningAddCrystalsForBridge();
        }
    }
Esempio n. 8
0
    /// <summary>
    /// Creates the parts on ground
    /// </summary>
    private void CreatePartListOnGround()
    {
        StructureParent g = null;

        if (loopCounter < PartsOnSoil.Count)
        {
            if (PartsOnSoil[loopCounter] == 10)
            {
                g = StructureParent.CreateStructureParent(ReturnBridgePartRoot(PartsOnSoil[loopCounter]), PlanesOnSoil[loopCounter],
                                                          BridgeUnit(), container: transform,
                                                          startingStage: StartingStageForPieces);
                g.transform.Rotate(new Vector3(0, 180, 0));
            }
            else if (PartsOnSoil[loopCounter] == 11)
            {
                g = StructureParent.CreateStructureParent(ReturnBridgePartRoot(PartsOnSoil[loopCounter]), PlanesOnSoil[loopCounter],
                                                          BridgeUnit(), container: transform,
                                                          startingStage: StartingStageForPieces);
            }
            else if (PartsOnSoil[loopCounter] == 12)
            {
                g = StructureParent.CreateStructureParent(ReturnBridgePartRoot(PartsOnSoil[loopCounter]), PlanesOnSoil[loopCounter],
                                                          BridgeUnit(),
                                                          container: transform,
                                                          startingStage: StartingStageForPieces);
            }

            if (_dominantSide == H.Vertic)
            {
                g.transform.Rotate(new Vector3(0, 270, 0));
            }
            g = ReSizeObj(g, PartsOnSoil[loopCounter], _dominantSide);
            Pieces.Add(g);
            loopCounter++;
        }
        else
        {
            createSoilPartsNow = false;
            loopCounter        = 0;
        }
    }
Esempio n. 9
0
    /// <summary>
    /// If is in construction will add percentage of completion
    /// </summary>
    /// <returns></returns>
    private string IfInConstructionAddPercentageOfCompletion()
    {
        if (_building.HType == H.Road)
        {
            return("");
        }

        StructureParent sP = Building.ReturnCurrentStructureParent();

        if (sP.CurrentStage != 4)
        {
            ShowPriorityControls();

            var percentage = sP.PercentageBuiltCured();
            return("\n\n" + Languages.ReturnString("Construction.Progress") + percentage + "%\n" +
                   MaterialsGathered() + "\n" + MaterialsIsMissing() + "\n\n");
        }
        HidePriorityControls();

        return("");
    }
Esempio n. 10
0
    /// <summary>
    /// Created to resize the vertical dominant side bridges bz they are slightly smaller
    /// and rezised part 11 on the horizontal
    /// </summary>
    private StructureParent ReSizeObj(StructureParent current, int objPart, H dominantSideP)
    {
        StructureParent res = null;
        //the percent from a horizntal
        float percentForVertic       = 0.888889f;
        float percentForVerticPart11 = 0.82f;//0.8333333f;

        Vector3 t = current.transform.localScale;

        if (dominantSideP == H.Vertic)
        {
            if (objPart != 11)
            {
                t.x *= percentForVertic;
            }
            else
            {
                t.x *= percentForVerticPart11;
            }
        }

        //so in horizontal the 11 is smaller too
        if (dominantSideP == H.Horiz && objPart == 11)
        {
            t.x *= 0.9055f;
        }

        if (HType == H.BridgeTrail)
        {
            t.x /= 5;
            t.y /= 5;
            t.z /= 5;
        }
        if (HType == H.None)
        {
            throw new Exception("HType cant be None");
        }
        current.transform.localScale = t;
        return(current);
    }
Esempio n. 11
0
    /// <summary>
    /// Show next stage of all Pieces... as loopCounter adds...
    /// This is called from Update if showNextStage = true
    /// </summary>
    private void ShowNextStageOfPartsRoutine()
    {
        if (loopCounter < Pieces.Count)
        {
            Pieces[loopCounter].ShowNextStage();
            loopCounter++;
        }
        else
        {
            if (Pieces[0].StartingStage == H.Done)
            {
                //will be added to BrdigeManager only when is fully built
                BuildingPot.Control.BridgeManager1.AddBridge(LandZone1[0].LandZone, LandZone1[1].LandZone,
                                                             transform.position, MyId);
            }

            StructureParent sP = new StructureParent();
            sP.ResaveOnRegistro(Pieces[0].StartingStage, MyId);
            showNextStage = false;
            loopCounter   = 0;
            RemoveFromBuildersManager();
        }
    }
Esempio n. 12
0
    /// <summary>
    /// Creates the  parts of a bridge visualiiy. This is the part thats is above the river
    /// </summary>
    /// <param name="iniPos"></param>
    public List <StructureParent> CreatePartListOnAir(List <Vector3> iniPos, List <int> partsP, Transform containerP, H dominantSideP)
    {
        List <StructureParent> res = new List <StructureParent>();

        for (int i = 0; i < partsP.Count; i++)
        {
            StructureParent sP   = null;
            string          root = "";
            if (partsP[i] == 1)
            {
                root = ReturnBridgePartRoot(partsP[i]);
            }
            else if (partsP[i] == 2)
            {
                root = ReturnBridgePartRoot(partsP[i]);
            }
            else if (partsP[i] == 3)
            {
                root = ReturnBridgePartRoot(partsP[i]);
            }
            else if (partsP[i] == 4)
            {
                root = ReturnBridgePartRoot(partsP[i]);
            }

            sP = StructureParent.CreateStructureParent(root, iniPos[i], BridgeUnit(), container: containerP,
                                                       startingStage: StartingStageForPieces);

            if (dominantSideP == H.Vertic)
            {
                sP.transform.Rotate(new Vector3(0, 270, 0));
            }
            sP = ReSizeObj(sP, partsP[i], dominantSideP);
            res.Add(sP);
        }
        return(res);
    }