Пример #1
0
Файл: Way.cs Проект: Cdrix/SM
    /// <summary>
    /// Checks if Terrain below the build _isEven or _isColliding, and is tall enough
    /// </summary>
    /// <returns>True if terrain is even, not colliding and not on the sea. if is a bridge will evealuate
    /// if is the bridge tall enoguth</returns>
    public override bool CheckEvenTerraCollWater()
    {
        bool res = false;

        _isWayAboveWater = FindIFWayAboveWater();

        //if is not a Bridge ...
        if (!HType.ToString().Contains(H.Bridge.ToString()))
        {
            _isWayEven = CheckIfIsEvenRoutine();
            res        = _isWayEven && !IsWayColliding && _isWayAboveWater;
        }
        //if is a bridge
        else if (HType.ToString().Contains(H.Bridge.ToString()))
        {
            _isWayEven = IsBridgeEven();
            //if (_isWayEven) { _isWayEven = CheckIfAllRealVerticesUnderneathBridgeAreEven(); }
            //CheckIfAllRealVerticesUnderneathBridgeAreEven();
            if (_isWayEven)
            {
                _isBridgeTallEnough = IsBrideTallEnought(3f);
            }
            res = _isWayEven && !IsWayColliding && _isWayAboveWater && _isBridgeTallEnough;
        }

        //print("way: _even:" + _isWayEven+"._isColl: "+IsWayColliding + "._isAboveWater: "+ _isWayAboveWater +
        //   "._isBridgTall: " + _isBridgeTallEnough + "._areTheTilesEven:"+AreAllTilesEven());

        return(res);
    }
Пример #2
0
    /// <
    /// summary>
    /// For unity eventTrigger
    ///
    /// </summary>
    private void PublicSpawnHelp()
    {
        if (hoverWindowMed == null)
        {
            hoverWindow    = FindObjectOfType <HoverWindow>();
            hoverWindowMed = FindObjectOfType <HoverWindowMed>();
        }

        if (hoverWindowMed == null)
        {
            return;
        }

        if (Category == Ca.Structure || Category == Ca.Shore || Category == Ca.Way ||
            //Category == Ca.Spawn ||
            HType == H.BuyRegion)
        {
            hoverWindow.ShowMsg(HType.ToString());
        }
        else if (HType == H.Person)
        {
            hoverWindow.ShowExplicitThis(Name);
        }
        //Construction Sign
        //bz if more than 6 he know how to build already
        else if (transform.name == "Construction" && BuildingPot.Control.Registro.AllBuilding.Count < 10)
        {
            hoverWindowMed.Show(MousePositionTowardsScreenCenter(), transform.name);
        }
        //Demolition Sign
        else if (transform.name == "Demolition")
        {
            hoverWindowMed.Show(MousePositionTowardsScreenCenter(), transform.name);
        }
    }
Пример #3
0
Файл: Way.cs Проект: Cdrix/SM
    void UpdateBigBoxesPrev()
    {
        InitializeBigBoxPrev();

        float diffYVertic = UMath.ReturnDiffBetwMaxAndMin(_verticPathNew, H.Y);
        float diffYHoriz  = UMath.ReturnDiffBetwMaxAndMin(_horPathNew, H.Y);
        float biggestDiff = UMath.ReturnMax(diffYVertic, diffYHoriz);

        List <float> yS = UList.ReturnAxisList(_verticPathNew, H.Y);

        yS.AddRange(UList.ReturnAxisList(_horPathNew, H.Y));
        float maxY = UMath.ReturnMax(yS);

        if (_dominantSide == H.Vertic)
        {
            var locVertBound = MakeListYVal(BoundsVertic, maxY);
            verticBigBox.UpdatePos(locVertBound, biggestDiff + 0.5f);
            verticBigBox.CheckAndSwitchColor(_isWayOK);
        }
        else if (_dominantSide == H.Horiz)
        {
            var locHorBound = MakeListYVal(BoundsHoriz, maxY);
            horizBigBox.UpdatePos(locHorBound, biggestDiff + 0.5f);
            horizBigBox.CheckAndSwitchColor(_isWayOK);
        }
        //this is for all but bridges and DraggableSquare. Dominant Side here is None
        else if (_dominantSide == H.None && !HType.ToString().Contains("Bridge") && Category != Ca.DraggableSquare)
        {
            UpdateBigBoxesPrevForAllButBridges(maxY, biggestDiff);
        }

        TogglePrevBigBoxesVisible();
    }
Пример #4
0
    /// <summary>
    /// Shwo next stange of a building from stage1 to done
    /// </summary>
    public virtual void ShowNextStage()
    {
        //Debug.Log("ShowNext on StruPar");

        if (_currentStage < 4)
        {
            _currentStage++;
        }
        if (_currentStage == 1)
        {
            if (!HType.ToString().Contains("Unit") && !IsThisADoubleBoundedStructure())
            {
                CreateBasePlane();
            }
            HandleMeshChild(H.Stage1);
        }
        else if (_currentStage == 2)
        {
            //HandleMeshChild(H.Stage2);
        }
        else if (_currentStage == 3)
        {
            //HandleMeshChild(H.Stage3);
        }
        else if (_currentStage == 4)
        {
            HandleMeshChild(H.Done);
            HandleLastStage();
        }
    }
Пример #5
0
    /// <summary>
    /// Creates the air and ground parts and addToRegistro
    /// </summary>
    public void CreatePartsRoutine()
    {
        //creates parts above river
        PlanesOnAirPos = ReturnPlanesOnAirPosAndDefinePlanesOnSoil();
        PartsOnAir     = ClassifyABridgeByParts(ReturnPlanesOnAirPosAndDefinePlanesOnSoil().Count);

        createAirPartsNow = true;

        //creates parts on gorund
        //bz has duplicates// the big number is so close tiles dont have a part created
        //only needed if is a road
        if (HType.ToString().Contains("Road"))
        {
            PlanesOnSoil = EliminatesDuplicateDependingOnDominantSide(PlanesOnSoil);
        }
        //if is a trail...
        else if (HType.ToString().Contains("Trail"))
        {
            PlanesOnSoil = UList.EliminateDuplicatesByDist(PlanesOnSoil, 0.01f);
        }

        //bz is not ordered. They need to be ordered to be clasified
        PlanesOnSoil = OrderByXorZ(PlanesOnSoil);
        PartsOnSoil  = ClassifyShorePoints();

        //must be called here... So still we are using the CurrentSpawnBuild obj
        AddBridgeToRegistro();
    }
Пример #6
0
    // Use this for initialization
    protected void Start()
    {
        //just i know it works
        ToggleWheelRotate();

        //this is here bz gave me a null ref ex
        if (!HType.ToString().Contains(H.Bridge.ToString()))
        {
            Stage2.SetActive(false);
            Stage3.SetActive(false);
        }

        if (HType.ToString().Contains("Unit"))
        {
            PositionFixed = true;
            if (_startingStage == H.None)
            {
                _startingStage = H.Stage2;
            }
        }

        base.Start();

        //this is for BridgeUnits in here
        if (PositionFixed && _currentStage == 0)
        {
            if (_startingStage != H.None && _currentStage == 0)
            {
                RecreateStage();
            }
        }
    }
Пример #7
0
Файл: Way.cs Проект: Cdrix/SM
 /// <summary>
 /// Collide check routine and update the previews lists too
 /// </summary>
 void CollideCheckRoutineUpdatePrev(List <Vector3> _verticPathP, List <Vector3> _horPathP)
 {
     if (!HType.ToString().Contains("Bridge"))
     {
         CollideUpdatePrevForAllWays(_verticPathP, _horPathP);
     }
     else
     {
         CollideUpdatePrevForBridges(_verticPathP, _horPathP);
     }
 }
Пример #8
0
    private string ReturnBridgePartRoot(int which)
    {
        string base1 = "Prefab/Building/Infrastructure/";

        //for the stone brdige
        if ((HType.ToString().Contains("Road")))
        {
            base1 += "Stone/";
        }
        base1 += "Bridge_Trail_Piece_" + which;
        return(base1);
    }
Пример #9
0
Файл: Way.cs Проект: Cdrix/SM
 // Update is called once per frame
 protected void Update()
 {
     base.Update();
     //means the obj was called to be destroy in  base  class
     if (!PositionFixed)
     {
         if (HType.ToString().Contains(H.Bridge.ToString()))
         {
             DefineBridgeDominantSide();
         }
     }
 }
Пример #10
0
 //assign the material Stage to all Stage 2 or 3 passed but a few ex
 //this is here to address the exepctions
 void AssignMaterialToStage(GameObject passP)
 {
     if (!HType.ToString().Contains(H.Bridge.ToString()) && HType != H.Dock && HType != H.Shipyard &&
         HType != H.FishingHut   // && HType != H.FishRegular
         )
     {
         passP.GetComponent <Renderer>().sharedMaterial = Resources.Load(Root.RetMaterialRoot(H.Stages.ToString())) as Material;
     }
     if (Category == Ca.Shore)
     {
         passP.GetComponent <Renderer>().sharedMaterial = Resources.Load(Root.blue_Semi_T) as Material;
     }
 }
Пример #11
0
 private void AddBridgeToBuildControl()
 {
     if (PositionFixed && !createSoilPartsNow && !createAirPartsNow && Pieces.Count == PartsOnAir.Count + PartsOnSoil.Count &&
         !addedToBuildControl && Pieces.Count > 0)
     {
         //is being added here bz is needs to have all parts spawned to work
         if (HType.ToString().Contains(H.Bridge.ToString()))
         {
             SetBridgeAnchors();
             addedToBuildControl = true;
         }
     }
 }
Пример #12
0
    private void SetSpecWeight()
    {
        if (HType.ToString().Contains("Tree"))
        {
            _weight = Random.Range(600, 1000);
        }
        else//ore. stone
        {
            _weight = Random.Range(100, 100);
        }
#if UNITY_EDITOR
        //_weight = 10;
#endif
    }
Пример #13
0
    /// <summary>
    /// This will recreate the building satgae(1 only the base plane,2,3,4 for fully) builded .
    /// This on is used to Load the building
    /// </summary>
    protected void RecreateStage()
    {
        Geometry.gameObject.SetActive(false);
        UpdateBuild();

        //the bridges parts are called Units... u dont want planes on those...
        if (!HType.ToString().Contains("Unit") && Category != Ca.Shore && HType != H.MountainMine
            )
        {
            CreateBasePlane();
        }
        HandleMeshChild(_startingStage);

        FinishPlacingMode(H.Done);
        //so I defined the current stage so when we use the NextStage is ok
        _currentStage  = ReturnCurrentStageInt(_startingStage);
        _startingStage = H.None;//has to be set to none so in Update() now goes to ShowNextStage();
    }
Пример #14
0
Файл: Way.cs Проект: Cdrix/SM
    /// <summary>
    /// Returns planes dim from the Starting point of topleft
    /// </summary>
    protected List <Vector3> ReturnPlanesDim(Vector3 topLefts)
    {
        List <Vector3> res = new List <Vector3>();

        res = UPoly.RetSubMeshPoly(topLefts, Program.gameScene.controllerMain.MeshController.AllVertexs, WideSquare);

        //if is a bridge Y will be  _firstWayPoint.y + _secondWayPoint.y) / 2
        if (HType.ToString().Contains(H.Bridge.ToString()))
        {
            for (int i = 0; i < res.Count; i++)
            {
                Vector3 t = res[i];
                t.y    = (_firstWayPoint.y + _secondWayPoint.y) / 2;
                res[i] = t;
            }
        }
        return(res);
    }
Пример #15
0
Файл: Way.cs Проект: Cdrix/SM
    /// <summary>
    /// Find the closest submesh Vert to the list and returns them
    /// </summary>
    protected Vector3 FindSubMeshVert(Vector3 current)
    {
        Vector3 res = new Vector3();

        res = m.Vertex.FindClosestVertex(current, Program.gameScene.controllerMain.MeshController.AllVertexs.ToArray(), 0.0001f);
        //if is a bridge Y will be  _firstWayPoint.y + _secondWayPoint.y) / 2
        if (HType.ToString().Contains(H.Bridge.ToString()))
        {
            res.y = (_firstWayPoint.y + _secondWayPoint.y) / 2;
        }

        //bz if a road i wanna keep the Y value bz the one that overlap want to be different on Y
        if (HType == H.Road)
        {
            res.y = current.y;
        }
        ;

        return(res);
    }
Пример #16
0
 public new string ToString()
 {
     return(HType.ToString());
 }
Пример #17
0
    /// <summary>
    /// Handles the geomtry subobject of a structure will do the sequence of building from stage1 to done
    /// it hides and shows geomtries
    /// </summary>
    void HandleMeshChild(H name)
    {
        //if its not done pay fee for using next stage
        if (name != H.Done)
        {
            //no fees will be payed for now. Removed bz on Stage1 a fee is payed and throws Ledger off
            //this fees are intended as a pay now to get a building finish

            //NextStageFee();
        }



        _startingStage = name;
        Geometry.gameObject.SetActive(false);
        if (Stage2 != null)
        {
            Stage2.gameObject.SetActive(false);
        }
        if (Stage3 != null)
        {
            Stage3.gameObject.SetActive(false);
        }

        //so UnderTerra mines show something onces there are built
        if (name == H.Stage1 && IsThisADoubleBoundedStructure())
        {
            if (Stage2 != null)
            {
                Stage2.gameObject.SetActive(true);
                AssignMaterialToStage(Stage2);
            }
        }
        else if (name == H.Stage2)
        {
            //basePlane.Geometry.renderer.material =  (Material)Resources.Load(Root.matBuildingBase2) ;
            if (Stage2 != null)
            {
                Stage2.gameObject.SetActive(true);
                AssignMaterialToStage(Stage2);
            }
        }
        else if (name == H.Stage3)
        {
            if (Stage3 != null)
            {
                Stage3.gameObject.SetActive(true);
                AssignMaterialToStage(Stage3);
            }
        }
        else if (name == H.Done)
        {
            Geometry.gameObject.SetActive(true);
            ShowWheel(true);
        }

        //this is here bz units stuff must be saved with the bridge
        if (!HType.ToString().Contains("Unit"))
        {
            ResaveOnRegistro(name, MyId);
        }
    }