示例#1
0
    // TODO: Look into right mouse

    /*void OnMouseOver() {
     *  if (MapMenu.activeSelf) {
     *      //Debug.Log(Input.GetMouseButton(1) + ", " + Input.GetMouseButtonDown(1) + ", " + Input.GetMouseButtonUp(1));
     *  }
     * }*/

    public void OnMouseDown()
    {
        if (tiles == null)
        {
            tiles = World.Instance.Tiles;
        }

        if (UIMenuController.IsActiveMenu(uiMapEditor))
        {
            Debug("Left: " + Input.GetMouseButton(0) + "  Right: " + Input.GetMouseButton(1));
            Debug("Should be doing something.");
            operationManager.BeginDraw();
            var   gridPos = MouseToGridAPI.GetGridCoordinate(Input.mousePosition);
            Point point   = new Point((int)gridPos.x, (int)gridPos.y);
            switch (currentTool)
            {
            case ToolType.FILL:
                Fill(point, paintCurrent.ID, tiles[Convert.ToInt32(point.x), Convert.ToInt32(point.y)]);
                MapDisplayAPI.FinishOperation();
                break;

            case ToolType.LINE:
            case ToolType.SHAPE:
                startPoint = point;
                break;

            case ToolType.BRUSH:
                previous = point;
                break;

            default:
                break;
            }
        }
    }
示例#2
0
 void Start()
 {
     CardDeck         = new List <GameObject>();
     GameController   = GameObject.FindGameObjectWithTag("GameGO").GetComponent <GameController>();
     UIMenuController = GameObject.FindGameObjectWithTag("UIMenuGO").GetComponent <UIMenuController>();
     DontDestroyOnLoad(this);
 }
示例#3
0
    public void OnMouseUp()
    {
        if (UIMenuController.IsActiveMenu(uiMapEditor))
        {
            var   gridPos = MouseToGridAPI.GetGridCoordinate(Input.mousePosition);
            Point point   = new Point((int)gridPos.x, (int)gridPos.y);
            switch (currentTool)
            {
            case ToolType.LINE:
                DrawLine(startPoint, point, paintCurrent.ID);
                MapDisplayAPI.FinishOperation();
                break;

            case ToolType.SHAPE:
                int   distance = (int)(Math.Sqrt(Math.Pow(startPoint.x - point.x, 2) + Math.Pow(startPoint.y - point.y, 2)));
                int   deltaX   = Convert.ToInt32(startPoint.x) - Convert.ToInt32(point.x);
                int   deltaY   = Convert.ToInt32(startPoint.y) - Convert.ToInt32(point.y);
                Point center   = new Point(startPoint.x - (deltaX / 2), startPoint.y - (deltaY / 2));
                DrawWithBrush(center, distance / 2, paintCurrent.ID);
                MapDisplayAPI.FinishOperation();
                break;

            case ToolType.BRUSH:
                previous = null;
                break;

            default:
                break;
            }
            operationManager.EndDraw();
        }
    }
示例#4
0
    public void OnClick(int practice)
    {
        Practice PracticeEnum = (Practice)practice;

        GameStateManager.Instance.SelectPractice(PracticeEnum);
        UIMenuController.StaticLoadScene("RateScene");
    }
示例#5
0
    void OnMouseDrag()
    {
        if (UIMenuController.IsActiveMenu(UnitMenu))
        {
            var   gridPos = mapCamera.ScreenToWorldPoint(Input.mousePosition);
            Point point   = new Point((int)gridPos.x, (int)gridPos.y);
            switch (selectedTool)
            {
            case Tools.MOVE:
                if (selectedGO != null)
                {
                    if (NetworkManager.NetworkInstance.IsServer)
                    {
                        selectedGO.transform.localPosition = new Vector3(point.x, point.y, 0);
                    }
                    else
                    {
                        NetworkManager.NetworkInstance.MoveObject(selectedGO.name, point);
                    }
                }
                break;

            default:
                break;
            }
        }
    }
示例#6
0
    public void OpenFavoritePractice()
    {
        var practice = GameStateManager.Instance.GetFavoritePractice();

        GameStateManager.Instance.SelectPractice(practice);

        UIMenuController.StaticLoadScene("RateScene");
    }
示例#7
0
    private void Intialise()
    {
        MenuScreen     = GameObjectUtilities.GetChildComponent <UIMenuController> (this.transform);
        GameScreen     = GameObjectUtilities.GetChildComponent <UIGameController> (this.transform);
        PauseScreen    = GameObjectUtilities.GetChildComponent <UIPauseController> (this.transform);
        GameOverScreen = GameObjectUtilities.GetChildComponent <UIGameOverController> (this.transform);

        EventManager.OnStateChanged += OnStateSwitched;
    }
示例#8
0
    void OnMouseUp()
    {
        var gridPos = mapCamera.ScreenToWorldPoint(Input.mousePosition);

        // Record the grid position of where the mouse was released
        //Debug.Log("OnMouseUp at: [" + gridPos.x + "," + gridPos.y + "]");

        if (UIMenuController.IsActiveMenu(UnitMenu))
        {
            Point point = new Point((int)gridPos.x, (int)gridPos.y);
            switch (selectedTool)
            {
            case Tools.MOVE:
                if (selectedGO != null)
                {
                    selectedGO.transform.localPosition = new Vector3(point.x, point.y, 0);
                    if (checkForCarrier(selectedGO))
                    {
                        return;
                    }
                    switch (selectedGO.tag)
                    {
                    case "Surface":
                    case "Subsurface":
                        if (!IsValid(point.x, point.y) || IsLand(point.x, point.y))
                        {
                            selectedGO.transform.localPosition = origionalPosition;
                        }
                        break;

                    case "Marine":
                        if (!IsValid(point.x, point.y) || !IsLand(point.x, point.y))
                        {
                            selectedGO.transform.localPosition = origionalPosition;
                        }
                        break;

                    case "Air":
                        if (!IsValid(point.x, point.y))
                        {
                            selectedGO.transform.localPosition = origionalPosition;
                        }
                        break;

                    default:
                        break;
                    }
                }
                break;

            default:
                break;
            }
            selectedGO = null;
        }
    }
        void ResetImage(UIMenuController controller)
        {
            var mid = new CGPoint((imageForReset.Bounds.Left + imageForReset.Bounds.Right) / 2, (imageForReset.Bounds.Top + imageForReset.Bounds.Bottom) / 2);
            var locationInSuperview = imageForReset.ConvertPointToView(mid, imageForReset.Superview);

            imageForReset.Layer.AnchorPoint = new CGPoint(0.5f, 0.5f);
            imageForReset.Center            = locationInSuperview;

            UIView.BeginAnimations(null, IntPtr.Zero);
            imageForReset.Transform = CoreGraphics.CGAffineTransform.MakeIdentity();
            UIView.CommitAnimations();
        }
示例#10
0
 void Awake()
 {
     // Singleton Initialization
     if (_instance != null && _instance != this)
     {
         Destroy(gameObject);
     }
     else
     {
         _instance = this;
     }
 }
示例#11
0
        void tap(UITapGestureRecognizer gr)
        {
            CGPoint point = gr.LocationInView(this);

            this.selectedLine = lineAtPoint(point);

            // If we just tapped, remove all lines in process
            // so that a tap does not result in a new line
            linesInProcess.Clear();

            if (selectedLine != null)
            {
                this.BecomeFirstResponder();

                // Grab the menu controller
                UIMenuController menu = UIMenuController.SharedMenuController;

                // Create a new "Delete" UIMenuItem
                UIMenuItem deleteItem = new UIMenuItem("Delete", new Selector("deleteLine:"));
                menu.MenuItems = new UIMenuItem[] { deleteItem };

                // Tell the menu item where it should come from and show it
                menu.SetTargetRect(new CGRect(point.X, point.Y, 2, 2), this);
                menu.SetMenuVisible(true, true);

                UIGestureRecognizer[] grs = this.GestureRecognizers;
                foreach (UIGestureRecognizer gestRec in grs)
                {
                    if (gestRec.GetType() != new UITapGestureRecognizer().GetType())
                    {
                        gestRec.Enabled = false;
                    }
                }
            }
            else
            {
                // Hide the menu if no line is selected
                UIMenuController menu = UIMenuController.SharedMenuController;
                menu.SetMenuVisible(false, true);

                UIGestureRecognizer[] grs = this.GestureRecognizers;
                foreach (UIGestureRecognizer gestRec in grs)
                {
                    if (gestRec.GetType() != new UITapGestureRecognizer().GetType())
                    {
                        gestRec.Enabled = true;
                    }
                }
            }
            this.SetNeedsDisplay();
        }
示例#12
0
 void Update()
 {
     if (UIMenuController.IsActiveMenu(uiMapEditor))
     {
         if (KeyUndo.Released)
         {
             Undo();
         }
         else if (KeyRedo.Released)
         {
             Redo();
         }
         else
         {
             if (KeyDefaultTerrain.Pressed)
             {
                 Pick(DEFAULT_CLEAR_TERRAIN);
                 Pick(DEFAULT_PAINT_TERRAIN);
             }
             else if (KeySwapTerrain.Pressed)
             {
                 SwapPick();
             }
             else if (KeyPickWater.Pressed)
             {
                 Pick("WATER");
             }
             else if (KeyPickLand.Pressed)
             {
                 Pick("LAND");
             }
             else if (KeyPickUndefined.Pressed)
             {
                 Pick("UNDEFINED");
             }
             else if (KeyPickMountain.Pressed)
             {
                 Pick("MOUNTAIN");
             }
             else if (KeyPickWooded.Pressed)
             {
                 Pick("WOODED");
             }
             else if (KeyPickHeavyBrush.Pressed)
             {
                 Pick("HEAVY_BRUSH");
             }
         }
     }
 }
    public void OnPlay()
    {
        var answers = new Dictionary <QuestionnaireQuestion, bool>();

        foreach (var question in GetComponentsInChildren <QuestionController>())
        {
            var toggle = question.GetComponent <Toggle>();
            answers.Add(question.question, toggle.isOn);
        }

        var practice = GameStateManager.Instance.GetQuestionnairePractice(answers);

        GameStateManager.Instance.SelectPractice(practice);
        UIMenuController.StaticLoadScene("RateScene");
    }
    public void OnClick()
    {
        var rate  = GameObject.FindGameObjectWithTag("Rate");
        int value = int.Parse(rate.GetComponent <Text>().text);

        if (GameStateManager.Instance.IsGameStarted)
        {
            GameStateManager.Instance.SaveGame(value);
            UIMenuController.StaticLoadScene("IntroScene");
        }
        else
        {
            GameStateManager.Instance.RateBeforeGame(value);
            UIMenuController.StaticLoadScene("TimerScene");
        }
    }
        partial void menuAction(NSObject sender)
        {
            this.View.BecomeFirstResponder();
            var menuController = UIMenuController.SharedMenuController;

            var red   = new UIMenuItem("Red", new Selector("redAction"));
            var blue  = new UIMenuItem("Blue", new Selector("blueAction"));
            var green = new UIMenuItem("Green", new Selector("greenAction"));

            UIMenuController menu = UIMenuController.SharedMenuController;
            var bounds            = new RectangleF(this.menuButton.Frame.X, this.menuButton.Frame.Y, 320, 110);

            menu.SetTargetRect(bounds, this.View);
            menu.MenuItems = new [] { red, blue, green };

            menu.MenuVisible = true;
        }
示例#16
0
 private void Awake()
 {
     #region Enforces Singleton Pattern.
     //Check if instance already exists
     if (instance == null)
     {
         //if not, set instance to this
         instance = this;
     }
     //If instance already exists and it's not this:
     else if (instance != this)
     {
         //Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a MyNetworkManager.
         Destroy(gameObject);
     }
     #endregion
 }
示例#17
0
        void swipe(UISwipeGestureRecognizer gr)
        {
            linesInProcess.Clear();
            this.BecomeFirstResponder();
            // Grab the menu controller
            UIMenuController menu = UIMenuController.SharedMenuController;

            // Create buttons
            UIMenuItem red   = new UIMenuItem("Red", new Selector("red:"));
            UIMenuItem green = new UIMenuItem("Green", new Selector("green:"));
            UIMenuItem blue  = new UIMenuItem("Blue", new Selector("blue:"));

            menu.MenuItems = new UIMenuItem[] { red, green, blue };

            // Tell the menu where it should come from and show it
            menu.SetTargetRect(new CGRect(0, 0, UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height), this);
            menu.SetMenuVisible(true, true);
        }
示例#18
0
    public void OnClick()
    {
        var selectedPractice = GameStateManager.Instance.GetPractice();

        switch (selectedPractice)
        {
        case Practice.Breathing:
            UIMenuController.StaticLoadScene("BreathingScene");
            break;

        case Practice.Collecting:
            UIMenuController.StaticLoadScene("RabbitJump");
            break;

        case Practice.Counting:
            UIMenuController.StaticLoadScene("CountSheeps");
            break;
        }
    }
示例#19
0
    public void OnMouseDrag()
    {
        if (UIMenuController.IsActiveMenu(uiMapEditor))
        {
            var   gridPos = MouseToGridAPI.GetGridCoordinate(Input.mousePosition);
            Point point   = new Point((int)gridPos.x, (int)gridPos.y);
            switch (currentTool)
            {
            case ToolType.BRUSH:
                DrawLine(previous, point, paintCurrent.ID);
                previous = point;
                MapDisplayAPI.FinishOperation();
                break;

            default:
                break;
            }
        }
    }
示例#20
0
 private void Awake()
 {
     _manager = FindObjectOfType <GameManager>();
     Instance = this;
 }
		void ResetImage (UIMenuController controller)
		{
			var mid = new PointF ((imageForReset.Bounds.Left + imageForReset.Bounds.Right) / 2, (imageForReset.Bounds.Top + imageForReset.Bounds.Bottom) / 2);
			var locationInSuperview = imageForReset.ConvertPointToView (mid, imageForReset.Superview);
			imageForReset.Layer.AnchorPoint = new PointF (0.5f, 0.5f);
			imageForReset.Center =locationInSuperview;
			
			UIView.BeginAnimations (null, IntPtr.Zero);
			imageForReset.Transform = MonoTouch.CoreGraphics.CGAffineTransform.MakeIdentity ();
			UIView.CommitAnimations ();
		}
示例#22
0
    void OnMouseDown()
    {
        var gridPos = mapCamera.ScreenToWorldPoint(Input.mousePosition);

        timeSinceClick = 0;
        // Record the grid position of where the mouse was released
        ////Debug.Log ("OnMouseDown at: [" + gridPos.x + "," + gridPos.y + "]");
        Point point = new Point((int)(gridPos.x + 0.5), (int)(gridPos.y + 0.5));

        ////Debug.Log ("Point at : [" + point.x + "," + point.y + "]");

        if (UIMenuController.IsActiveMenu(UnitMenu))
        {
            GameObject gameObjectToAdd = null;
            switch (selectedTool)
            {
            case Tools.PLACE:
                try
                {
                    selectedUnit = unitmanager.GetSelectedUnit();
                }
                catch (Exception)
                {
                    //Debug.Log ("Selected Unit not found from combobox!");
                    selectedUnit = "";
                }

                if (!selectedUnit.Equals(""))
                {
                    switch (selectedUnitType)
                    {
                    case UnitType.AIR:
                        if (IsValid(Convert.ToInt32(point.x), Convert.ToInt32(point.y)))
                        {
                            point.z = -0.0004f;
                            if (NetworkManager.NetworkInstance.IsServer)
                            {
                                gameObjectToAdd = unitFactory.LoadAir(selectedUnit);
                                AddObject(gameObjectToAdd, point);

                                string[] teams   = { Team.Teams[TeamComboBox.SelectedIndex].GetTeamName() };
                                string   message = "Admin has spawned an Air unit on team " + teams[0] + " at latitude: " + point.x + " longitude: " + point.y;

                                EventLog.LogManual(EventLog.FormatEventString(teams, Time.time, message));
                            }
                            else
                            {
                                int teamIndex = TeamComboBox.SelectedIndex;
                                NetworkManager.NetworkInstance.StartObject(selectedUnit, point, Convert.ToString(teamIndex), "0");
                            }
                        }
                        break;

                    case UnitType.MARINE:
                        if (IsValid(point.x, point.y) && IsLand(point.x, point.y))
                        {
                            if (NetworkManager.NetworkInstance.IsServer)
                            {
                                gameObjectToAdd = unitFactory.LoadMarine(selectedUnit);
                                AddObject(gameObjectToAdd, point);

                                string[] teams   = { Team.Teams[TeamComboBox.SelectedIndex].GetTeamName() };
                                string   message = "Admin has spawned a Marine unit on team " + teams[0] + " at latitude: " + point.x + " longitude: " + point.y;

                                EventLog.LogManual(EventLog.FormatEventString(teams, Time.time, message));
                            }
                            else
                            {
                                int teamIndex = TeamComboBox.SelectedIndex;
                                NetworkManager.NetworkInstance.StartObject(selectedUnit, point, Convert.ToString(teamIndex), "1");
                            }
                        }
                        break;

                    case UnitType.SUBSURFACE:
                        if (IsValid(point.x, point.y) && !IsLand(point.x, point.y))
                        {
                            if (NetworkManager.NetworkInstance.IsServer)
                            {
                                gameObjectToAdd = unitFactory.LoadSubSurface(selectedUnit);
                                gameObjectToAdd.transform.localPosition = new Vector3(point.x, point.y, point.z);
                                AddObject(gameObjectToAdd, point);

                                string[] teams   = { Team.Teams[TeamComboBox.SelectedIndex].GetTeamName() };
                                string   message = "Admin has spawned a Subsurface unit on team " + teams[0] + " at latitude: " + point.x + " longitude: " + point.y;

                                EventLog.LogManual(EventLog.FormatEventString(teams, Time.time, message));
                            }
                            else
                            {
                                int teamIndex = TeamComboBox.SelectedIndex;
                                NetworkManager.NetworkInstance.StartObject(selectedUnit, point, Convert.ToString(teamIndex), "2");
                            }
                        }
                        break;

                    case UnitType.SURFACE:
                        if (IsValid(point.x, point.y) && !IsLand(point.x, point.y))
                        {
                            point.z = -.0002f;
                            if (NetworkManager.NetworkInstance.IsServer)
                            {
                                gameObjectToAdd = unitFactory.LoadSurface(selectedUnit);
                                AddObject(gameObjectToAdd, point);

                                string[] teams   = { Team.Teams[TeamComboBox.SelectedIndex].GetTeamName() };
                                string   message = "Admin has spawned an Surface unit on team " + teams[0] + " at latitude: " + point.x + " longitude: " + point.y;

                                EventLog.LogManual(EventLog.FormatEventString(teams, Time.time, message));
                            }
                            else
                            {
                                int teamIndex = TeamComboBox.SelectedIndex;
                                NetworkManager.NetworkInstance.StartObject(selectedUnit, point, Convert.ToString(teamIndex), "3");
                            }
                        }
                        break;

                    default:
                        break;
                    }
                }
                break;

            case Tools.MOVE:
                selectedGO = RaycastForObject();
                if (selectedGO != null)
                {
                    if (NetworkManager.NetworkInstance.IsServer)
                    {
                        origionalPosition = selectedGO.transform.localPosition;
                    }
                    else
                    {
                        NetworkManager.NetworkInstance.setObject(selectedGO.GetComponent <IdentityController>().GetGuid());
                    }
                }
                break;

            case Tools.DELETE:
                GameObject toDelete = RaycastForObject();
                if (toDelete != null)
                {
                    NetworkManager.NetworkInstance.DestroyUnitOnNetwork(toDelete);  //
                }
                break;

            case Tools.EDIT:
                GameObject toEdit = RaycastForObject();
                if (toEdit != null)
                {
                    if (NetworkManager.NetworkInstance.IsServer)
                    {
                        // Send to editor.
                        unitmanager.SetCurrentObject(toEdit);
                        unitmanager.realObjectSelected = true;
                        unitmanager.RefreshUI();
                    }
                    else
                    {
                        NetworkManager.NetworkInstance.setObject(selectedGO.GetComponent <IdentityController>().GetGuid());
                        unitmanager.SetCurrentObject(toEdit);
                        unitmanager.realObjectSelected = true;
                        unitmanager.RefreshUI();
                    }
                }
                break;

            default:
                break;
            }
        }
    }
示例#23
0
 private void Start() => _menuController = GetComponent <UIMenuController>();
示例#24
0
 public void SelectPractice()
 {
     UIMenuController.StaticLoadScene("SelectPracticeScene");
 }
示例#25
0
 public void OpenQuestionnaire()
 {
     UIMenuController.StaticLoadScene("Questionnaire");
 }
示例#26
0
 void Awake()
 {
     Instance = this;
 }
示例#27
0
 void GameOver()
 {
     UIMenuController.StaticLoadScene("RateScene");
 }
示例#28
0
    public void SetActivePanel(bool a)
    {
        UIMenuController uIMenu = FindObjectOfType <UIMenuController>();

        uIMenu.SetPanel(panel, a);
    }