Пример #1
0
    public void CellStart(int cellID, CellSize size, OrganManager.OrganType.OrganInfo.cellsType.CellSizes.CellInfo info)
    {
        myInfo   = info;
        cellSize = size;
        ID       = cellID;

        Vector2 randomPosition = Vector2.zero;

        switch (CellType)
        {
        case 0:     // Red Cells
            randomPosition = new Vector2(Random.Range(0.2f, 0.8f), Random.Range(0.7f, 0.87f));
            break;

        case 1:
        case 2:
            randomPosition = new Vector2(Random.Range(0.2f, 0.8f), Random.Range(0.1f, 0.68f));
            break;

        default:
            randomPosition = Vector2.zero;
            break;
        }
        target = Camera.main.ViewportToWorldPoint(randomPosition);


        UpdateHealthCoroutine = StartCoroutine(UpdateHealth());
        randomTime            = Random.Range(0.4f, 1.5f);
    }
Пример #2
0
 public HumanParser(string code, CellSize cell, bool?Displayins, int ptrsize = 0, bool memoryview = false, bool checkOnlySyntax = false, string input = "") : base(code, ptrsize)
 {
     if (input != null)
     {
         inputList = input.ToCharArray();
     }
     this.ptrsize     = ptrsize;
     this.cell        = cell;
     this.DisplayIns  = Displayins;
     this.memoryView  = memoryview;
     this.syntaxCheck = checkOnlySyntax;
     if (this.ptrsize != 0)
     {
         if (this.cell == CellSize.bit8)
         {
             ptr = new byte[ptrsize];
             //         ptr = new List<byte>(ptrsize) ;
         }
         else if (this.cell == CellSize.bit16)
         {
             ptr16 = new ushort[ptrsize];
         }
         else if (this.cell == CellSize.bit32)
         {
             ptr32 = new uint[ptrsize];
         }
     }
 }
Пример #3
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Range != 0D)
            {
                hash ^= Range.GetHashCode();
            }
            if (CellSize != 0D)
            {
                hash ^= CellSize.GetHashCode();
            }
            if (ExtendDist != 0D)
            {
                hash ^= ExtendDist.GetHashCode();
            }
            if (NoEdgeTable != false)
            {
                hash ^= NoEdgeTable.GetHashCode();
            }
            if (SetRoiService != false)
            {
                hash ^= SetRoiService.GetHashCode();
            }
            return(hash);
        }
Пример #4
0
        public override int GetHashCode()
        {
            int hash = 17;

            hash = hash * 23 + Cells.GetHashCode();
            hash = hash * 23 + Size.GetHashCode();
            hash = hash * 23 + CellSize.GetHashCode();
            hash = hash * 23 + Position.GetHashCode();

            return(hash);
        }
Пример #5
0
        public void Get_CellSize_In_InValid_Tile_Level_Will_Throw_ArgumentException(int input)
        {
            //Arrange
            var _cellSize = new CellSize();

            //Act
            Action actual = () => _cellSize.GetCellSizeInDegree(input);

            //Assert
            Assert.Throws <ArgumentException>(actual);
        }
Пример #6
0
        public void Get_CellSize_In_Valid_Tile_Level(int input, double expected)
        {
            //Arrange
            var _cellSize = new CellSize();

            //Act
            var result = _cellSize.GetCellSizeInDegree(input);

            //Assert
            Assert.Equal(result, expected);
        }
Пример #7
0
        /// <summary>
        /// Resetoi halutun columin leveyden.
        /// </summary>
        /// <param name="column">Columi jonka leveys halutaan resetoida.</param>
        public void ResetColumnWidth(int column)
        {
            CellSize columnSize = GetColumnOverwrite(column);

            if (columnSize == null)
            {
                throw new InvalidGuiOperationException("Given column does not exist.");
            }

            columnSizeOverwrites.Remove(columnSize);

            UpdateLayout(GuiLayoutEventArgs.Empty);
        }
Пример #8
0
        /// <summary>
        /// Asettaa halutun columin koon
        /// </summary>
        /// <param name="column">Columi jonka koko halutaan muuttaa.</param>
        /// <param name="width">Prosentuaalinen leveys.</param>
        public void SetColumnWidth(int column, float width)
        {
            CellSize columnSize = GetColumnOverwrite(column);

            if (columnSize != null)
            {
                throw new InvalidGuiOperationException("Grid already overwrites given column. Call reset before overwriting column width.");
            }

            columnSizeOverwrites.Add(new CellSize(column, width));

            UpdateLayout(GuiLayoutEventArgs.Empty);
        }
Пример #9
0
        /// <summary>
        /// Resetoi halutun rowin korkeuden.
        /// </summary>
        /// <param name="row">Rowi jonka korkeus halutaan resetoida.</param>
        public void ResetRowHeight(int row)
        {
            CellSize rowSize = GetRowOverwrite(row);

            if (rowSize == null)
            {
                throw new InvalidGuiOperationException("Given row does not exist.");
            }

            rowSizeOverwrites.Remove(rowSize);

            UpdateLayout(GuiLayoutEventArgs.Empty);
        }
Пример #10
0
        /// <summary>
        /// Asettaa halutun rowin koon.
        /// </summary>
        /// <param name="row">Rowi jonka koko halutaan muuttaa.</param>
        /// <param name="height">Prosentuaalinen korkeus.</param>
        public void SetRowHeight(int row, float height)
        {
            CellSize rowSize = GetRowOverwrite(row);

            if (rowSize != null)
            {
                throw new InvalidGuiOperationException("Grid already overwrites given row. Call reset before overwiriting row height.");
            }

            rowSizeOverwrites.Add(new CellSize(row, height));

            UpdateLayout(GuiLayoutEventArgs.Empty);
        }
Пример #11
0
        public ProgramState(CellSize cellSize)
        {
            _cellValues = new Dictionary <int, uint> {
                { 0, 0 }
            };
            _loopStack          = new Stack <int>();
            CurrentCodePosition = 0;
            CurrentCell         = 0;

            switch (cellSize)
            {
            case CellSize.OneByte:
                _maxValue = byte.MaxValue;
                break;

            case CellSize.TwoBytes:
                _maxValue = ushort.MaxValue;
                break;

            case CellSize.FourBytes:
                _maxValue = uint.MaxValue;
                break;
            }
        }
Пример #12
0
        private void UpdateCellSizes()
        {
            float width = 0.0f, height = 0.0f;
            float widthPercents  = (100.0f - GetTotalColumnOverwritePercent()) / (currentColumns - columnSizeOverwrites.Count);
            float heightPercents = (100.0f - GetTotalRowOverwritePercent()) / (currentRows - rowSizeOverwrites.Count);

            for (int i = 0; i < cells.Length; i++)
            {
                CellSize rowOverwrite = GetRowOverwrite(i);

                for (int j = 0; j < cells[i].Length; j++)
                {
                    CellSize columnOverwrite = GetColumnOverwrite(j);

                    if (rowOverwrite != null)
                    {
                        height = rowOverwrite.Percents;
                    }
                    else
                    {
                        height = heightPercents;
                    }

                    if (columnOverwrite != null)
                    {
                        width = columnOverwrite.Percents;
                    }
                    else
                    {
                        width = widthPercents;
                    }

                    cells[i][j].Size = new Vector2(width, height);
                }
            }
        }
Пример #13
0
    private static void OnTopTool(MapEditor wind)
    {
        Init(wind);
        ToolMapArray config = wind.Level_Data.Tools;

        GUILayout.BeginHorizontal();
        if (isEdit)
        {
            isEdit = !GUILayout.Button("确认", GUILayout.Width(50));
            GenGrid(config);
        }
        else
        {
            isEdit = GUILayout.Button("编辑", GUILayout.Width(50));
        }
        if (isEdit)
        {
            int owidth  = config.WidthMap[m_StrSelect];
            int oheight = config.FillTypeMap[m_StrSelect].Length / owidth;

            GUILayout.Label("宽度:", GUILayout.Width(50));
            string tempx  = GUILayout.TextField(owidth.ToString(), GUILayout.Width(50));
            int    fwidth = int.Parse(tempx);
            config.WidthMap[m_StrSelect] = fwidth;
            GUILayout.Space(10f);

            GUILayout.Label("高度:", GUILayout.Width(50));
            tempx = GUILayout.TextField(oheight.ToString(), GUILayout.Width(50));
            int fheight = int.Parse(tempx);
            GUILayout.Space(10f);

            config.FitArray(owidth, oheight, fwidth, fheight, m_StrSelect);

            GUILayout.Label("格子大小:", GUILayout.Width(50));
            tempx    = GUILayout.TextField(CellSize.ToString(), GUILayout.Width(50));
            CellSize = int.Parse(tempx);
            GUILayout.Label("间距:", GUILayout.Width(50));
            tempx      = GUILayout.TextField(CellOffset.ToString(), GUILayout.Width(50));
            CellOffset = int.Parse(tempx);
        }
        else
        {
            int width  = config.WidthMap[m_StrSelect];
            int height = config.FillTypeMap[m_StrSelect].Length / width;
            GUILayout.Label("宽度:", GUILayout.Width(50));
            GUILayout.Label("" + width, GUILayout.Width(50));
            GUILayout.Space(10f);
            GUILayout.Label("高度:", GUILayout.Width(50));
            GUILayout.Label("" + height, GUILayout.Width(50));
        }



        GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("生成"))
        {
            GenGrid(config);
        }
        if (GUILayout.Button("读取底图"))
        {
            MapEditor.BgTexture = EditorTool.LoadTexture();
        }
        if (GUILayout.Button("保存"))
        {
            wind.SaveEdit();
        }
        if (GUILayout.Button("返回总览"))
        {
            IsInit        = false;
            wind.Pagetype = MapEditor.PageType.Total;
            return;
        }
        if (!isShowbg && GUILayout.Button("显示底图"))
        {
            isShowbg = true;
        }
        if (isShowbg && GUILayout.Button("显示网格"))
        {
            isShowbg = false;
        }
        GUILayout.EndHorizontal();
    }
Пример #14
0
    public static void OnGui(MapEditor wind)
    {
        Init(wind);
        isDo = false;
        LevelMapArray config = wind.Level_Config;

        GUILayout.BeginHorizontal();
        if (isEdit)
        {
            isEdit = !GUILayout.Button("确认", GUILayout.Width(50));
        }
        else
        {
            isEdit = GUILayout.Button("编辑", GUILayout.Width(50));
        }
        if (isEdit)
        {
            int owidth  = config.MapWidth;
            int oheight = config.MapHeight;
            GUILayout.Label("宽度:", GUILayout.Width(50));
            string tempx = GUILayout.TextField(config.MapWidth.ToString(), GUILayout.Width(50));
            config.MapWidth = int.Parse(tempx);
            GUILayout.Space(10f);
            GUILayout.Label("高度:", GUILayout.Width(50));
            tempx            = GUILayout.TextField(config.MapHeight.ToString(), GUILayout.Width(50));
            config.MapHeight = int.Parse(tempx);
            config.FitArray(owidth, oheight);

            //string tempxx = config.ConfigID.ToString();
            GUILayout.Label("地图ID:", GUILayout.Width(100));
            tempx = GUILayout.TextField(config.Id.ToString(), GUILayout.Width(50));
            //if (GUILayout.Button("确认", GUILayout.Width(50)))
            uint temp = uint.Parse(tempx);
            wind.curLevelId = temp;
            config.Id       = temp;

            tempx = config.ConfigID.ToString();
            GUILayout.Label("对应配置表ID:", GUILayout.Width(100));
            tempx           = GUILayout.TextField(tempx, GUILayout.Width(50));
            config.ConfigID = uint.Parse(tempx);

            config.FitArray(owidth, oheight);
            GUILayout.Label("格子大小:", GUILayout.Width(50));
            tempx    = GUILayout.TextField(CellSize.ToString(), GUILayout.Width(50));
            CellSize = int.Parse(tempx);
            config.FitArray(owidth, oheight);
            GUILayout.Label("间距:", GUILayout.Width(50));
            tempx      = GUILayout.TextField(CellOffset.ToString(), GUILayout.Width(50));
            CellOffset = int.Parse(tempx);
        }
        else
        {
            GUILayout.Label("宽度:", GUILayout.Width(50));
            GUILayout.Label("" + config.MapWidth, GUILayout.Width(50));
            GUILayout.Space(10f);
            GUILayout.Label("高度:", GUILayout.Width(50));
            GUILayout.Label("" + config.MapHeight, GUILayout.Width(50));
        }



        GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("生成"))
        {
            GenGrid(config);
        }
        if (GUILayout.Button("读取底图"))
        {
            MapEditor.BgTexture = EditorTool.LoadTexture();
        }
        if (GUILayout.Button("保存"))
        {
            wind.SaveEdit();
        }
        if (GUILayout.Button("返回总览"))
        {
            IsInit        = false;
            wind.Pagetype = MapEditor.PageType.Total;
            return;
        }
        if (!isShowbg && GUILayout.Button("显示底图"))
        {
            isShowbg = true;
        }
        if (isShowbg && GUILayout.Button("显示网格"))
        {
            isShowbg = false;
        }
        GUILayout.EndHorizontal();
        ShowBg(wind);
        if (!isEdit && !isShowbg)
        {
            ShowGrid(wind);
        }
        if (isDo)
        {
            //wind.SaveEdit();
        }
    }