コード例 #1
0
    // Update is called once per frame
    void Update()
    {
        float scroll = Input.GetAxis("Mouse ScrollWheel");

        if (scroll != 0)
        {
            if (scroll > 0)
            {
                if (TestMain.GetCamera().orthographicSize > 25)
                {
                    TestMain.GetCamera().orthographicSize -= 5;
                }
            }
            else
            {
                if (TestMain.GetCamera().orthographicSize < 200)
                {
                    TestMain.GetCamera().orthographicSize += 5;
                }
            }
        }
        bool[] currMouseDown = new bool[] { Input.GetMouseButtonDown(0), Input.GetMouseButtonDown(1) };
        if (currMouseDown[0] || currMouseDown[1])
        {
            m_mode[(int)currMode].OnClick(currMouseDown);
        }
        else
        {
            m_mode[(int)currMode].OnHover();
        }
        if (!mapLoaded)
        {
            mapLoaded = TestMain.GetMap().ExtendBound(ref bottomLeft, ref topRight);
        }
    }
コード例 #2
0
 public void Initialise(Character givenCharacter)
 {
     m_character = givenCharacter;
     m_mode      = GameMode.CreateModes(this);
     m_menu      = new MenuController();
     currMode    = 0;
     bottomLeft  = new Position((int)transform.position.x - 1, (int)transform.position.y - 1);
     topRight    = new Position((int)transform.position.x, (int)transform.position.y);
     TestMain.GetMap().CreateMapView(ref bottomLeft, ref topRight);
     mapLoaded = false;
 }
コード例 #3
0
ファイル: Dictionary.cs プロジェクト: ZXYmania/Chevauchee
 public Tile GetTile(Position givenPosition)
 {
     if (TestMain.GetMap().GetTile(givenPosition) != null)
     {
         for (int i = 0; i < m_array.Length; i++)
         {
             if (m_array[i][0].GetX() == givenPosition.x)
             {
                 for (int j = 0; j < m_array[i].Length; j++)
                 {
                     if (m_array[i][j].GetPosition().Equals(givenPosition))
                     {
                         return(m_array[i][j]);
                     }
                 }
             }
         }
         return(null);
     }
     else
     {
         return(null);
     }
 }
コード例 #4
0
ファイル: GameMode.cs プロジェクト: ZXYmania/Chevauchee
    public override void OnHover()
    {
        GameObject cursorObj = FindObjectUnder();

        if (cursorObj != null)
        {
            ClickAble cursorItem = cursorObj.GetComponent <ClickAble>();
            if (cursorItem != null)
            {
                if (cursorObj.layer == LayerMask.NameToLayer("Tile"))
                {
                    if (Building.CanBuildOnTile((Tile)cursorItem, currbuilding, m_player))
                    {
                        if (currbuilding != "Road")
                        {
                            if (hover != null)
                            {
                                hover.Hover(false, m_player);
                            }
                            hover = cursorItem;
                            cursorItem.Hover(true, m_player);
                        }
                        else
                        {
                            if (selected.Length > 0)
                            {
                                try
                                {
                                    Tile[] tempPath = TestMain.GetMap().GetBestPath((Tile)selected[selected.Length - 1], (Tile)cursorItem, PathType.CompareTerrain);
                                    if (currPath != null)
                                    {
                                        for (int i = 0; i < currPath.Length; i++)
                                        {
                                            currPath[i].Selected(false, m_player);
                                        }
                                    }
                                    currPath = tempPath;
                                    for (int i = 0; i < currPath.Length; i++)
                                    {
                                        currPath[i].Hover(true, m_player);
                                    }
                                    for (int i = 0; i < selected.Length; i++)
                                    {
                                        selected[i].Selected(true, m_player);
                                    }
                                }
                                catch (NoPathException e)
                                {
                                    //hit ocean or imppassible
                                }
                            }
                            else
                            {
                                if (hover != null)
                                {
                                    hover.Selected(false, m_player);
                                }
                                if (Building.CanBuildOnTile((Tile)cursorItem, currbuilding, m_player))
                                {
                                    hover = cursorItem;
                                    hover.Selected(true, m_player);
                                }
                            }
                        }
                    }
                }
            }
            clickLength++;
        }
    }