Пример #1
0
    /// <summary>
    /// Will select clicked building and ret true if one was seelected
    /// </summary>
    /// <returns></returns>
    bool SelectClickedBuild()
    {
        if (!Input.GetMouseButtonUp(0))
        {
            return(false);
        }

        List <string> names   = new List <string>();
        var           clicked = ReturnBuildinHit();

        //unselect if was click outise
        if (clicked != null)
        {
            names = UString.ExtractNamesUntilGranpa(clicked);
            Program.InputMain.InputMouse.UnSelectRoutine(names, clicked);
        }
        //select new Build
        if (names.Count > 0)
        {
            for (int i = 0; i < names.Count; i++)
            {
                H  typeL = Program.InputMain.InputMouse.FindType(names[i]);
                Ca cat   = DefineCategory(typeL);
                Program.InputMain.InputMouse.Select(cat, names[i]);
                ManagerReport.AddInput("Selected building: " + names[i]);

                if (BuildingPot.Control.Registro.SelectBuilding != null)
                {
                    return(true);
                }
            }
        }
        return(false);
    }
Пример #2
0
    private void CheckIfKeyWasPressed()
    {
        //didnt load so one need to be redone
        if (Program.IsInputLocked || list == null)
        {
            return;
        }

        foreach (var item in list)
        {
            if (Input.GetKeyUp(item.saveKeyC))
            {
                ManagerReport.AddInput("SaveCamPos:" + item.saveKeyC);
                SaveCamPos(item.saveKeyC, TransformCam.position, TransformCam.rotation);
            }
        }
        foreach (var item in list)
        {
            if (Input.GetKeyUp(item.loadKeyC))
            {
                ManagerReport.AddInput("LoadCamPos:" + item.saveKeyC);

                LoadCamPos(item.loadKeyC);
            }
        }
    }
Пример #3
0
    private void GeneralSwitch()
    {
        var ctrlS = Input.GetKeyUp(KeyCode.F) && (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl));

        if (Input.GetKeyUp(KeyCode.Escape))
        {
            ManagerReport.AddInput(KeyCode.Escape + "");
            EscapeKey();
        }
        else if (Input.GetMouseButtonUp(1))
        {
            RightClickRoutine();
        }
        else if (!Dialog.IsActive() && Developer.IsDev && Input.GetKeyUp(KeyCode.F11))
        {
            Program.gameScene.controllerMain.MeshController.ForcedTerraScanning();
        }
        else if (!Dialog.IsActive() &&
                 (Input.GetKeyUp(KeyCode.F) || ctrlS) &&
                 !Program.IsInputLocked)
        {
            ManagerReport.AddInput("QuickSaveNow()");
            QuickSaveNow();
        }
    }
Пример #4
0
    public void ChangeGameSpeedBy(int val)
    {
        if (Program.gameScene.GameController1.IsGameOver)
        {
            return;
        }

        val = DefineChangedVal(val);
        Program.gameScene.GameSpeed = val;

        if (Program.gameScene.GameSpeed < 0)
        {
            Program.gameScene.GameSpeed = 0;
        }
        else if (Program.gameScene.GameSpeed > 10)
        {
            Program.gameScene.GameSpeed = 10;
        }

        if (Program.gameScene.GameSpeed == 2)
        {
            Program.gameScene.TutoStepCompleted("2XSpeed.Tuto");
        }

        //needs to be call for Body.cs
        OnChangeSpeed(EventArgs.Empty);
        ManagerReport.AddInput("Speed changed by:" + val + ". CurrSpeed: " + Program.gameScene.GameSpeed);
        ManagerReport.AddNewSpeed(Program.gameScene.GameSpeed);
    }
Пример #5
0
    // Update is called once per frame
    private void Update()
    {
        //if (_showAInventory != null)
        //{
        //    _showAInventory.Update();
        //}
        if (_showPathToSea != null)
        {
            _showPathToSea.Update();
        }

        if (_miniHelper != null && Input.GetKeyUp(KeyCode.F1))
        {
            ManagerReport.AddInput("KeyCode.F1");
            Program.MouseListener.HelpWindow.Show("");
        }

        if (Input.GetKeyUp(KeyCode.F9))
        {
            if (isShownNow)
            {
                HideCanvas();
            }
            else
            {
                ShowCanvas();
            }

            isShownNow = !isShownNow;
        }
    }
Пример #6
0
 public void SelectPerson(Person pers)
 {
     ManagerReport.AddInput("Selected person: " + pers.name);
     PersonSelect = pers;
     _personWindow.Show(PersonSelect);
     UnselectingBuild();
     _buildingWindow.Hide();
 }
Пример #7
0
 /// <summary>
 /// Switch between modes
 /// </summary>
 private void ModeSwitcher()
 {
     if (Input.GetKeyUp(KeyCode.B))
     {
         ManagerReport.AddInput("Mode.Building");
         BuildingPot.InputMode = Mode.Building;
         //_audioPlayer.PlaySoundOneTime(RootSound.hoverMenuSound);
         DestroyCurrentSpawnBuild();
     }
     else if (Input.GetKeyUp(KeyCode.C))
     {
         //BuildingPot.InputMode = Mode.Cutting;
         //_audioPlayer.PlaySoundOneTime(RootSound.hoverMenuSound);
     }
     //if (BuilderPot.InputMode != Mode.Placing) { Cursor.visible = true; }
 }
Пример #8
0
    /// <summary>
    /// This is where the selection of a new building to be built happen
    /// </summary>
    void BuildingMode()
    {
        foreach (var item in _fInputKeys)
        {
            if (Input.GetKeyUp(item.Key))
            {
                ManagerReport.AddInput("SelecNewBuild: " + item.Key);

                //selection of the type of Building is goonna be build
                selection = item.Value;
                //print(selection + ".");
            }
        }

        //if something was selected
        if (selection != H.None)
        {
            //will find what numbers is that selection in Book.MenuGroupsList
            int indexSelection = -1;
            if (indexSelection == -1)
            {
                for (int i = 0; i < Program.gameScene.Book.MenuGroupsList.Count; i++)
                {
                    if (selection == Program.gameScene.Book.MenuGroupsList[i])
                    {
                        indexSelection = i;
                    }
                }
            }

            if (indexSelection != -1)
            {
                //then in that list whaterever key is pressed will be pass for buildNow()
                foreach (var item in _inputListDict[indexSelection])
                {
                    if (Input.GetKeyUp(item.Key))
                    {
                        //print(indexSelection + ".indexSelection");
                        BuildNowNew(item.Value);
                        //print(selection + "."+item.Value );
                        ManagerReport.AddInput("BuildNowNew: " + item.Value);
                    }
                }
            }
        }
    }
Пример #9
0
    // Update is called once per frame
    void Update()
    {
        //if (_showAInventory != null)
        //{
        //    _showAInventory.Update();
        //}
        if (_showPathToSea != null)
        {
            _showPathToSea.Update();
        }

        if (_miniHelper != null && Input.GetKeyUp(KeyCode.F1))
        {
            ManagerReport.AddInput("KeyCode.F1");
            Program.MouseListener.HelpWindow.Show("");
        }
    }
Пример #10
0
    public void Next(string step)
    {
        if (_showAgainTuto == null)
        {
            return;
        }

        if (_currentIndex == -1 || step != _steps[_currentIndex] || _showAgainTuto.activeSelf)
        {
            return;
        }

        HideAllHelpers();
        HideArrow();
        ManagerReport.AddInput("Tuto.Step.Achieved:" + _steps[_currentIndex]);
        _currentIndex++;

        if (_currentIndex >= _steps.Count)
        {
            _currentIndex = -1;
            Hide();

            //temporal
            Dialog.OKDialog(H.TutoOver);

            if (!Program.WasTutoPassed)
            {
                Program.gameScene.GameController1.Dollars += 10000;
                AudioCollector.PlayOneShot("BoughtLand", 0);
                BulletinWindow.SubBulletinFinance1.FinanceLogger.AddToAcct("Quests Completion", 10000);
            }

            ManagerReport.AddInput("Tutorial.Done:");
            Program.gameScene.QuestManager.QuestFinished("Tutorial");

            Program.WasTutoPassed = true;
            PlayerPrefs.SetString("Tuto", "Done");


            return;
        }
        //QuestManager.QuestFinished("Tutorial");
        Show();
    }
Пример #11
0
    /// <summary>
    /// Will try to select a person. Person selection has more importantce than
    /// building selection and priority
    /// </summary>
    /// <returns>Will retrun true if a person was selected</returns>
    private bool SelectPerson()
    {
        Transform clicked = UPoly.RayCastLayer(Input.mousePosition, 11).transform;

        if (clicked != null)
        {
            ManagerReport.AddInput("Selected person: " + clicked.name);

            PersonSelect = clicked.GetComponent <Person>();
            _personWindow.Show(PersonSelect);

            UnselectingBuild();

            _buildingWindow.Hide();
            return(true);
        }
        _personWindow.Hide();
        return(false);
    }
Пример #12
0
    //Center cam command
    public void CenterCam(bool fakedPressKeyP = false)
    {
        if (Dialog.IsActive() || Program.IsInputLocked)
        {
            return;
        }

        var yes = Input.GetKeyUp(KeyCode.P) || fakedPressKeyP;

        if (yes && !_isFollowingPersonNow)
        {
            ManagerReport.AddInput("CenterCam to 1st Building");

            LoadFirstCamPos();
            Program.gameScene.TutoStepCompleted("BackToTown.Tuto");

            if (TownLoader.IsTemplate)
            {
                return;
            }

            CenterCamTo(BuildingPot.Control.Registro.AllBuilding.ElementAt(0).Value.transform);
        }
    }
Пример #13
0
 public static void MouseClickListenerSt(string type)
 {
     _mouseListener.DetectMouseClick(type);
     ManagerReport.AddInput(type);
 }
Пример #14
0
    /// <summary>
    /// Depending on the current InputMode will direct the code to  BuildingMode(); or
    /// Structure.Place, DrawWay(), DragFarm(
    /// </summary>
    public void BuildingSwitch(H val = H.None)
    {
        //Building mode
        if (InputMode == Mode.Building)
        {
            //with keyboard
            if (val == H.None)
            {
                BuildingMode();
            }
            //with GUI buttons
            else
            {
                BuildNowNew(val);
            }
        }
        //Placing mode
        else if (InputMode == Mode.Placing)
        {
            //Vector3 iniPos = m.HitMouseOnTerrain.point;
            //var onMap = CamControl.CAMRTS.MiniMapRts.IsOnMapConstraints(iniPos);

            //if (!onMap)
            //{
            //    return;
            //}


            //Screen.showCursor = false;
            //Structures
            if (Control.CurrentSpawnBuild.Category == Ca.Structure || Control.CurrentSpawnBuild.Category == Ca.Shore)
            {
                Structure str = Control.CurrentSpawnBuild as Structure;

                //for bulldozer
                if (str != null)
                {
                    str.UpdateClosestVertexAndOld();
                }
            }

            //Ways and Farm
            if (Control.CurrentSpawnBuild.Category == Ca.Way || Control.CurrentSpawnBuild.Category == Ca.DraggableSquare)
            {
                UpdateWayFarmCursor();
                if (Control.CurrentSpawnBuild.Category == Ca.Way)
                {
                    DrawWay();
                }
                else if (DefineCategory(DoingNow) == Ca.DraggableSquare)
                {
                    DragFarm();
                }
            }

            //Structures
            if (Input.GetKeyUp(KeyCode.R) && (DefineCategory(DoingNow) == Ca.Structure || (DefineCategory(DoingNow) == Ca.Shore)))
            {
                ManagerReport.AddInput("RotateBuilding");
                Control.CurrentSpawnBuild.RotationAction();
                AudioCollector.PlayOneShot("ClickMetal1", 0);
            }
            else if (Input.GetMouseButtonUp(0) && !_isDraggingWay && (DefineCategory(DoingNow) == Ca.Structure || (DefineCategory(DoingNow) == Ca.Shore)))
            {
                MouseUp();
            }
        }
    }