Exemplo n.º 1
0
    /// <summary>
    /// Creates a new way object
    /// </summary>
    void CreateWay(RegFile regFile)
    {
        if (regFile.HType == H.Trail)
        {
            trail = (Trail)Way.CreateWayObj(Root.trail, regFile.IniPos,
                                            previewObjRoot: Root.previewTrail, hType: H.Trail, isLoadingFromFile: true
                                            , container: Program.BuildsContainer.transform);
        }
        else if (regFile.HType == H.BridgeTrail)
        {
            trail = (Bridge)
                    Way.CreateWayObj(Root.bridge, regFile.IniPos, previewObjRoot: Root.previewTrail,
                                     hType: H.BridgeTrail, isLoadingFromFile: true
                                     , container: Program.BuildsContainer.transform);
        }
        else if (regFile.HType == H.BridgeRoad)
        {
            trail = (Bridge)
                    Way.CreateWayObj(Root.bridge, regFile.IniPos, previewObjRoot: Root.previewRoad,
                                     hType: H.BridgeRoad, wideSquare: 5, radius: 5f, planeScale: 0.11f, maxStepsWay: 20,
                                     isLoadingFromFile: true
                                     , container: Program.BuildsContainer.transform);
        }

        trail.CurrentLoop = H.Done;
        trail.FinishPlacingMode(H.Done);

        if (regFile.HType.ToString().Contains(H.Bridge.ToString()))
        {
            trail.Pieces = CreateBridgePartList(regFile, trail.transform);
        }

        trail.name        = regFile.MyId;
        trail.MyId        = regFile.MyId;
        trail.PeopleDict  = regFile.PeopleDict;
        trail.LandZone1   = regFile.LandZone1;
        trail.Instruction = regFile.Instruction;
        trail.MaterialKey = regFile.MaterialKey;
        trail.Anchors     = regFile.Anchors.ToList();

        //if (trail.name.Contains("Bridge"))
        //{
        //    UVisHelp.CreateHelpers(trail.Anchors, Root.blueCube);

        //}

        trail.StartingStage = regFile.StartingStage;

        //if is not a bridge
        if (!regFile.HType.ToString().Contains(H.Bridge.ToString()))
        {
            trail.PlanesListVertic = CreatePlanesVertAndHor(regFile, H.Vertic, trail.transform, trail);
            trail.PlanesListHor    = CreatePlanesVertAndHor(regFile, H.Horiz, trail.transform, trail);
        }
        else
        {
            trail = CreateBridgePlanes(trail, regFile);
            trail.AddBoxCollider(regFile.Min, regFile.Max);
            //trail.LandZoningBridge();
        }

        Program.gameScene.BatchAdd(trail);

        Control.CurrentSpawnBuild = trail;
        Control.Registro.Ways.Add(trail.MyId, Control.CurrentSpawnBuild as Way);
        Control.Registro.AllBuilding.Add(trail.MyId, Control.CurrentSpawnBuild);
        Control.CurrentSpawnBuild = null;
    }