コード例 #1
0
    /// <summary>
    /// This gets call when user is dreaggin a Farm object.
    /// </summary>
    void DragFarm()
    {
        DragSquare farm = Control.CurrentSpawnBuild as DragSquare;


        if (Control.CurrentSpawnBuild != null && Input.GetMouseButtonUp(0) && !_isDraggingWay)
        {
            _isDraggingWay = true;
        }

        if (_isDraggingWay)
        {
            farm.Drag();
        }

        if (_isDraggingWay && Input.GetMouseButtonUp(0) && farm.IsBuildOk && farm.IsFarmOk)
        {
            //print("DragFarm() MouseUp() farm");
            IsDraggingWay = false;
            MouseUp();
        }
        //else if (!farm.IsFarmOk && _isDraggingWay && Input.GetMouseButtonUp(0))
        else if (!farm.IsFarmOk)
        {
            print("cant place farm here ");
        }
    }
コード例 #2
0
ファイル: BuildingSaveLoad.cs プロジェクト: Cdrix/SM
    /// <summary>
    /// Will create a draggable category building (Farm, StockPile, Farm)
    /// </summary>
    void CreateDraggableSquare(RegFile regFile)
    {
        Control.CurrentSpawnBuild = Way.CreateWayObj(Root.farm, regFile.IniPos,
                                                     previewObjRoot: Root.previewTrail, hType: regFile.HType, isLoadingFromFile: true
                                                     , container: Program.BuildsContainer.transform);

        Control.CurrentSpawnBuild.MyId           = regFile.MyId;
        Control.CurrentSpawnBuild.transform.name = regFile.MyId;

        DragSquare f = (DragSquare)Control.CurrentSpawnBuild;

        f.PlanesSoil = CreatePlanes(regFile.PlaneOnAirPos, f.transform, regFile.TileScale, regFile.MaterialKey, Control.CurrentSpawnBuild);



        f.AddBoxCollider(regFile);
        f.PositionFixed = true;
        f.PeopleDict    = regFile.PeopleDict;

        f.transform.position = regFile.IniPos;


        Program.gameScene.BatchAdd(f);

        Control.Registro.DragSquares.Add(regFile.MyId, Control.CurrentSpawnBuild as DragSquare);
        Control.Registro.AllBuilding.Add(regFile.MyId, Control.CurrentSpawnBuild);
    }
コード例 #3
0
 void ShowHelp()
 {
     count = 0;
     _orgStructuresFromMouseHitPoint = DragSquare.ReturnClosestBuildings(m.HitMouseOnTerrain.point,
                                                                         Control.Registro.Structures.Count, H.Road);
     showHelp = true;
     helpLoop = true;
 }
コード例 #4
0
    /// <summary>
    /// Is being called from this class on  public void MouseUp() and from the Farm instance
    /// bz we need to prevent from building a new one before the old obj was added to registro.
    /// So the 1st call is expected to do the first if... the second call is expected to comply with the 2nd if
    /// </summary>
    public void DoneFarmRoutine()
    {
        DragSquare f = Control.CurrentSpawnBuild as DragSquare;

        //if the farm is ok and farm is not being added to refistro
        if (f.IsFarmOk && !Control.Registro.DragSquares.ContainsKey(Control.CurrentSpawnBuild.MyId))
        {
            f.FinishPlacingFarm();
        }
        //is here so we prevent from building a new one before the old obj was added to registro
        else if (f.IsFarmOk && Control.Registro.DragSquares.ContainsKey(Control.CurrentSpawnBuild.MyId))
        {
            BuildNowNew(DoingNow);
        }
    }
コード例 #5
0
    private void DemolishAction()
    {
        //print("Selected name:" + b.name);
        if (BuildingPot.Control.Registro.SelectBuilding.Category == Ca.Way)
        {
            Trail b = BuildingPot.Control.Registro.SelectBuilding as Trail;
            b.Demolish();
        }
        else if (BuildingPot.Control.Registro.SelectBuilding.Category == Ca.Structure ||
                 BuildingPot.Control.Registro.SelectBuilding.Category == Ca.Shore)
        {
            Structure b = BuildingPot.Control.Registro.SelectBuilding as Structure;

            if (BuildingPot.Control.IsThisTheLastFoodSrc(b))
            {
                Program.gameScene.GameController1.NotificationsManager1.MainNotify("LastFood");
                return;
            }
            if (BuildingPot.Control.IsThisTheLastOfThisType(H.Masonry, b))
            {
                Program.gameScene.GameController1.NotificationsManager1.MainNotify("LastMasonry");
                return;
            }
            if (BuildingPot.Control.Registro.AreUDemolishingOneAlready())
            {
                Program.gameScene.GameController1.NotificationsManager1.MainNotify("OnlyOneDemolish");
                return;
            }

            var wasDemolished = b.Demolish();
            if (wasDemolished)
            {
                OnDemolish(EventArgs.Empty);
            }
        }
        else if (BuildingPot.Control.Registro.SelectBuilding.Category == Ca.DraggableSquare)
        {
            DragSquare b = BuildingPot.Control.Registro.SelectBuilding as DragSquare;
            b.Demolish();
        }

        //Program.InputMain.InputMouse.UnSelectCurrent();
        //DestroyForm();
    }
コード例 #6
0
ファイル: Registro.cs プロジェクト: Cdrix/SM
 //will add an new building to it list dependeing on catefory
 void AddSpecToList(Ca cat)
 {
     if (cat == Ca.Way)
     {
         Way f = BuildingPot.Control.CurrentSpawnBuild as Way;
         f = (Way)CheckIfOnDict(_ways, f);
         Ways.Add(f.MyId, f);
     }
     else if (cat == Ca.Structure || cat == Ca.Shore)
     {
         Structure f = BuildingPot.Control.CurrentSpawnBuild as Structure;
         f = (Structure)CheckIfOnDict(Structures, f);
         Structures.Add(f.MyId, f);
     }
     else if (cat == Ca.DraggableSquare)
     {
         DragSquare f = BuildingPot.Control.CurrentSpawnBuild as DragSquare;
         f = (DragSquare)CheckIfOnDict(DragSquares, f);
         DragSquares.Add(f.MyId, f);
     }
 }
コード例 #7
0
ファイル: InputMain.cs プロジェクト: naaturaz/SM
    /// <summary>
    /// This is for the roads farm when they are canceled neeed to to all this
    /// </summary>
    private void HandleWayDestroy()
    {
        //in case is a dragable square
        BuildingPot.InputU.KillCursor();
        BuildingPot.InputU.IsDraggingWay = false;

        DragSquare farm = BuildingPot.Control.CurrentSpawnBuild as DragSquare;

        if (farm != null)
        {
            farm.DestroyPreviews();
            return;
        }

        Way fWay = BuildingPot.Control.CurrentSpawnBuild as Way;

        if (fWay != null)
        {
            fWay.DestroyWayFromUserRightClick();
        }
    }