Inheritance: MonoBehaviour
Beispiel #1
0
 public override void Apply(Cell cell)
 {
     foreach (var item in _effects)
     {
         item.Apply(cell);
     }
 }
Beispiel #2
0
 public override void Apply(Cell cell)
 {
     if (!_isOn)
         cell.ActualCharacterIndex = CharacterIndex;
     else
         cell.ActualCharacterIndex = cell.CharacterIndex;
 }
Beispiel #3
0
 public override void Clear(Cell cell)
 {
     foreach (var item in _effects)
     {
         item.Clear(cell);
     }
 }
Beispiel #4
0
 public CellVM(int row, int col, Cell model)
 {
     Model = model;
     Row = row;
     Column = col;
     Content = model.Value.ToString();
 }
		void SetEndingCell(GridDungeonModel model, Cell cell) {
			var roomCenter = MathUtils.GridToWorld(model.Config.GridCellSize, cell.CenterF);

            // Destroy all old level goal objects
            var oldGoals = GameObject.FindObjectsOfType<DAShooter.LevelGoal>();
            foreach (var oldGoal in oldGoals)
            {
                var oldGoalObj = oldGoal.gameObject;
                if (oldGoalObj != null)
                {
                    if (Application.isPlaying)
                    {
                        Destroy(oldGoalObj);
                    }
                    else
                    {
                        DestroyImmediate(oldGoalObj);
                    }
                }
            }

			var goal = Instantiate(levelEndGoalTemplate) as GameObject;
            goal.transform.position = roomCenter;

            if (goal.GetComponent<DAShooter.LevelGoal>() == null)
            {
                Debug.LogWarning("No LevelGoal component attached to the Level goal prefab.  cleanup will not be proper");
            }
		}
Beispiel #6
0
			public Cell Clone()
			{
				Cell cell = new Cell(table);

				cell.text = this.text;
				cell.hyperLink = this.hyperLink;
				cell.textFormat = this.textFormat;
				cell.textColor = this.textColor;

				cell.toolTip = this.toolTip;
				cell.picture = this.picture;
				cell.picturePos = this.picturePos;

				cell.brush = this.brush;
				if (cell.brush != null)
					cell.brush.AddRef();

				cell.columnSpan = this.columnSpan;
				cell.rowSpan = this.rowSpan;
				cell.tag = this.tag;

				cell.txOptions = new Text.LayoutOptions();
				cell.txLayout = new Text.Layout();
				cell.updateText();

				return cell;
			}
		protected override AView GetCellCore(Cell item, AView convertView, ViewGroup parent, Context context)
		{
			Performance.Start();
			var cell = (ViewCell)item;

			var container = convertView as ViewCellContainer;
			if (container != null)
			{
				container.Update(cell);
				Performance.Stop();
				return container;
			}

			BindableProperty unevenRows = null, rowHeight = null;
			if (ParentView is TableView)
			{
				unevenRows = TableView.HasUnevenRowsProperty;
				rowHeight = TableView.RowHeightProperty;
			}
			else if (ParentView is ListView)
			{
				unevenRows = ListView.HasUnevenRowsProperty;
				rowHeight = ListView.RowHeightProperty;
			}

			IVisualElementRenderer view = Platform.CreateRenderer(cell.View);
			Platform.SetRenderer(cell.View, view);
			cell.View.IsPlatformEnabled = true;
			var c = new ViewCellContainer(context, view, cell, ParentView, unevenRows, rowHeight);

			Performance.Stop();

			return c;
		}
Beispiel #8
0
 public void ColorCell(Cell cell, bool isRight)
 {
     if (isRight)
         MarkRight(cell);
     else
         MarkWrong(cell);
 }
Beispiel #9
0
 public Cell[,] LoadLevel(int level_nr)
 {
     Cell[,] cell = null;
     string[] lines;
     try
     {
         lines = File.ReadAllLines(filename);
     }
     catch
     {
         return cell;
     }
     int curr = 0;
     int curr_level_nr = 0;
     int width;
     int height;
     while (curr < lines.Length)
     {
         ReadLevelHeader(lines[curr], out curr_level_nr, out width, out height);
         if (level_nr == curr_level_nr)
         {
             cell = new Cell[width, height];
             for (int y = 0; y < height; y++)
                 for (int x = 0; x < width; x++)
                     cell[x, y] = CharToCell(lines[curr + 1 + y][x]);
             break;
         }
         else
             curr = curr + 1 + height;
     }
     return cell;
 }
        public FileLogSettingsDlg( )
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent( );

            // initialize the grid
            ColumnHeader headerBehaviour = new ColumnHeader( false );
            FlatHeader headerVisual = new FlatHeader( true );
            EditorTextBoxButton textEditor = new EditorTextBoxButton( typeof ( String ) );
            EditorNumericUpDown numEditor = new EditorNumericUpDown( );

            grid.Redim( 3, 2 );

            grid[ 0, 0 ] = new SourceGrid2.Cells.Real.ColumnHeader( "Name", headerVisual, headerBehaviour );
            grid[ 0, 1 ] = new SourceGrid2.Cells.Real.ColumnHeader( "Value", headerVisual, headerBehaviour );

            grid[ 1, 0 ] = new Cell( "File", textEditor, headerVisual );
            grid[ 1, 0 ].ToolTipText = "The path and file name to log to";
            grid[ 1, 0 ].Invalidate( );
            // TODO: place the old file name here
            grid[ 1, 1 ] = new Link( @"c:\", new PositionEventHandler( this.OpenFile ) );

            grid[ 2, 0 ] = new Cell( "Size (Kb)", textEditor, headerVisual );
            grid[ 2, 0 ].ToolTipText = "The maximum size of the log file.";
            grid[ 2, 0 ].Invalidate( );

            grid[ 2, 1 ] = new Cell( 1024 * 100, numEditor );
            numEditor.Maximum = new decimal( 1024 * 1024 );
            numEditor.Minimum = new decimal( 0 );
            grid.AutoStretchColumnsToFitWidth = true;
            grid.StretchColumnsToFitWidth( );
        }
		public override UITableViewCell GetCell(Cell item, UITableViewCell reusableCell, UITableView tv)
		{
			var entryCell = (EntryCell)item;

			var tvc = reusableCell as EntryCellTableViewCell;
			if (tvc == null)
				tvc = new EntryCellTableViewCell(item.GetType().FullName);
			else
			{
				tvc.Cell.PropertyChanged -= OnCellPropertyChanged;
				tvc.TextFieldTextChanged -= OnTextFieldTextChanged;
				tvc.KeyboardDoneButtonPressed -= OnKeyBoardDoneButtonPressed;
			}

			SetRealCell(item, tvc);

			tvc.Cell = item;
			tvc.Cell.PropertyChanged += OnCellPropertyChanged;
			tvc.TextFieldTextChanged += OnTextFieldTextChanged;
			tvc.KeyboardDoneButtonPressed += OnKeyBoardDoneButtonPressed;

			WireUpForceUpdateSizeRequested(item, tvc, tv);

			UpdateBackground(tvc, entryCell);
			UpdateLabel(tvc, entryCell);
			UpdateText(tvc, entryCell);
			UpdateKeyboard(tvc, entryCell);
			UpdatePlaceholder(tvc, entryCell);
			UpdateLabelColor(tvc, entryCell);
			UpdateHorizontalTextAlignment(tvc, entryCell);
			UpdateIsEnabled(tvc, entryCell);

			return tvc;
		}
        private static void FillMatrix(int[,] matrix, Cell startupCell)
        {
            var currentCell = startupCell;
            var dirIndex = 0;

            while (IsCellPassable(matrix, currentCell))
            {
                matrix[currentCell.X, currentCell.Y] = currentCell.Value;

                while (!IsNextCellPassable(matrix, currentCell, dirIndex) &&
                       CanCellMoveSomewhere(matrix, currentCell, dirIndex))
                {
                    dirIndex = (dirIndex + 1) % DirectionsX.Length;
                }

                currentCell.X += DirectionsX[dirIndex];
                currentCell.Y += DirectionsY[dirIndex];
                currentCell.Value++;
            }

            var nextStartupCell = FindFirstEmptyCellIfExists(matrix);
            if (nextStartupCell != null)
            {
                nextStartupCell.Value = currentCell.Value;
                FillMatrix(matrix, nextStartupCell);
            }
        }
        private static void GetPath(char[,] matrix, Cell start, Cell end, ref bool foundExit)
        {
            if (foundExit)
            {
                return;                                     // already found the solution and other cases are not interesting
            }

            if (start.Row >= matrix.GetLength(0) || start.Row < 0 || start.Col >= matrix.GetLength(1) || start.Col < 0)
            {
                return;                                     // the cell is outside the matrix
            }

            if (matrix[start.Row, start.Col] == '*')
            {
                return;                                     // the cell is not passable
            }

            if (start.Equals(end))
            {
                foundExit = true;                           // found exit
                return;
            }

            matrix[start.Row, start.Col] = '*';
            GetPath(matrix, new Cell(start.Row + 1, start.Col), end, ref foundExit);
            GetPath(matrix, new Cell(start.Row, start.Col + 1), end, ref foundExit);
            GetPath(matrix, new Cell(start.Row - 1, start.Col), end, ref foundExit);
            GetPath(matrix, new Cell(start.Row, start.Col - 1), end, ref foundExit);
            matrix[start.Row, start.Col] = ' ';
        }
Beispiel #14
0
        //
        // test 2:
        // test sensors
        static void test2()
        {
            MindClock clk = new MindClock();
            SensorScan ss = new SensorScan(clk);
            SensorCompare sc = new SensorCompare(clk);
            Cell a = new Cell(clk);
            Cell b = new Cell(clk);
            Cell[] outs = new Cell[5]{
                new Cell(clk),
                new Cell(clk),
                new Cell(clk),
                new Cell(clk),
                new Cell(clk)
            };

            ss.m_needle = 0xa;
            byte[] data = {0xa,0xa,0xa,0xa,0xa};
            ss.add_cell(a);
            ss.add_cell(b);
            ss.scan_input(data);

            System.Console.WriteLine("a -> " + a + " (?5)");
            System.Console.WriteLine("b -> " + b + " (?5)");

            sc.set_mask(data, outs);
            byte[] cmpdata = {0xa,0xb,0xa,0xa,0xa};
            int[] res = {1, 0, 1, 1, 1};
            sc.compare_input(cmpdata);
            for(int i = 0; i < outs.Length; i++) {
                Cell o = outs[i];
                System.Console.WriteLine("o -> " + o + " (?" + res[i] + ")");
            }
        }
Beispiel #15
0
        public Edge(int x, int y, Directions direction, int depth)
        {
            origin = new Cell {direction = direction, x = x, y = y, depth = depth};
            exit = new Cell {x = x, y = y, depth = depth + 1};

            switch (origin.direction)
            {
                case Directions.Left:
                    exit.direction = Directions.Right;
                    exit.x -= 1;
                    break;
                case Directions.Right:
                    exit.direction = Directions.Left;
                    exit.x += 1;
                    break;
                case Directions.Down:
                    exit.direction = Directions.Up;
                    exit.y -= 1;
                    break;
                case Directions.Up:
                    exit.direction = Directions.Down;
                    exit.y += 1;
                    break;
            }
        }
        public Cell CompileCell(CellHandling cellHandling, Fixture fixture)
        {
            _cell = Cell.For(cellHandling, _property, fixture);
            _cell.output = true;

            return _cell;
        }
Beispiel #17
0
        // test 1:
        // Create two notes, load them, then decay them.
        static void test1()
        {
            MindClock clk = new MindClock();
            Cell a = new Cell(clk);
            Cell b = new Cell(clk);

            System.Console.WriteLine("Starting test...");

            a.connect_output(b);

            // load
            for(int i=0; i<99; i++) {
                a.upcharge();
            }
            System.Console.WriteLine("a -> " + a + " (?9)");
            System.Console.WriteLine("b -> " + b + " (?9)");

            // decay (there could be a thread somewhere
            // running this loop with a delay)
            for(int i=0; i<5; i++) {
                clk.cycle();
            }
            System.Console.WriteLine("a -> " + a + " (?4)");
            System.Console.WriteLine("b -> " + b + " (?4)");

            for(int i=0; i<99; i++) {
                clk.cycle();
            }
            System.Console.WriteLine("a -> " + a + " (?0)");
            System.Console.WriteLine("b -> " + b + " (?0)");
        }
        object SerializeCell(IDesignerSerializationManager manager, CodeExpression target, Cell cell)
        {
            object codeObject = null;
            ExpressionContext context = null;
            ExpressionContext context2 = manager.Context[typeof(ExpressionContext)] as ExpressionContext;
            if (context2 != null)
            {
                CodeMethodInvokeExpression codeIndexer = new CodeMethodInvokeExpression(target, "GetAt", new CodePrimitiveExpression(cell.Column.Index));
                context = new ExpressionContext(codeIndexer, typeof(RowCollection), context2.PresetValue, cell);
                manager.Context.Push(context);
            }
            try
            {
                CodeDomSerializer rowSerialzier = (CodeDomSerializer)manager.GetSerializer(cell.GetType(), typeof(CodeDomSerializer));

                //codeObject = rowSerialzier.Serialize(manager, row);
                codeObject = rowSerialzier.SerializeAbsolute(manager, cell);
            }
            finally
            {
                if (context != null)
                {
                    manager.Context.Pop();
                }
            }

            return codeObject;
        }
Beispiel #19
0
    private static void FindAllPaths(string[,] lab, Cell currentCell, Cell wantedCell, string path)
    {
        int currentRow = currentCell.Row;
        int currentCol = currentCell.Col;

        if (CheckIfInsideLab(lab, currentRow, currentCol))
        {
            if (currentRow == wantedCell.Row && currentCol == wantedCell.Col)
            {
                path += string.Format(" -> ({0},{1})", currentRow, currentCol);
                Console.WriteLine(path.Substring(4));
                Console.WriteLine();
            }
            else
            {
                if (lab[currentRow, currentCol] == " ")
                {
                    lab[currentRow, currentCol] = "visited";
                    path += string.Format(" -> ({0},{1})", currentRow, currentCol);

                    FindAllPaths(lab, new Cell(currentRow - 1, currentCol), wantedCell, path); // UP
                    FindAllPaths(lab, new Cell(currentRow, currentCol + 1), wantedCell, path); // Right
                    FindAllPaths(lab, new Cell(currentRow + 1, currentCol), wantedCell, path); // Down
                    FindAllPaths(lab, new Cell(currentRow, currentCol - 1), wantedCell, path); // Left

                    lab[currentRow, currentCol] = " ";
                }
            }
        }
    }
        private void afterMatching()
        {
            var comparer = new UnorderedSetMatcher();
            var cells = new Cell[] {Cell.For<int>("x"), Cell.For<int>("y")};

            theResult = comparer.Match(cells, _expected, _actual);
        }
 public override UITableViewCell GetCell (Cell item, UITableView tv)
 {
     var cellView = base.GetCell (item, tv);
     var index = ((List<OptionItem>)((ListView)item.Parent).ItemSource).IndexOf((OptionItem)item.BindingContext);
     cellView.BackgroundColor = index % 2 == 0 ? cellView.BackgroundColor : UIColor.FromRGB(255,255,240);
     return cellView;
 }
		protected override global::Android.Views.View GetCellCore(Cell item, global::Android.Views.View convertView, ViewGroup parent, Context context)
		{
			if ((_view = convertView as EntryCellView) == null)
				_view = new EntryCellView(context, item);
			else
			{
				_view.TextChanged = null;
				_view.FocusChanged = null;
				_view.EditingCompleted = null;
			}

			UpdateLabel();
			UpdateLabelColor();
			UpdatePlaceholder();
			UpdateKeyboard();
			UpdateHorizontalTextAlignment();
			UpdateText();
			UpdateIsEnabled();
			UpdateHeight();

			_view.TextChanged = OnTextChanged;
			_view.EditingCompleted = OnEditingCompleted;

			return _view;
		}
        byte WAIT_TICKS = 30; // How many ticks to wait for another unit to move.

        #endregion Fields

        #region Constructors

        /// <summary>
        /// This constructor will create a MoveAction to the given targetX, and targetY.
        /// </summary>
        /// <param name="targetX">X coordinate destination of the move action in game space.</param>
        /// <param name="targetY">Y coordinate destination of the move action in game space.</param>
        /// <param name="gw">The GameWorld that the move action is occurring in.</param>
        /// <param name="entity">The Entity being given the MoveAction. (Should only be given to Units)</param>
        public MoveAction(float targetX, float targetY, GameWorld gw, Entity entity)
        {
            this.actionType = ActionType.Move;
            this.targetY = targetY;
            this.targetX = targetX;
            this.entity = entity;
            this.gw = gw;
            unit = (Unit)entity;
            float startX = unit.x;
            float startY = unit.y;

            if ((int)targetX >= gw.map.width || (int)targetX < 0 || (int)targetY >= gw.map.height || (int)targetY < 0)
            {
                // Invalid target position.
                path = new List<Cell>();
            }
            else
            {
                path = findPath.between(gw.map, gw.map.getCell((int)startX, (int)startY), gw.map.getCell((int)targetX, (int)targetY));

                // Don't bother with path if it is just to same cell.
                if (path.Count > 1)
                {
                    targetCell = path[1];
                    cellIndex = 1;
                }
                else
                {
                    path = new List<Cell>();
                }
            }
        }
Beispiel #24
0
        public bool Load(Stream gnd)
        {
            BinaryReader br = new BinaryReader(gnd);
            string header = ((char)br.ReadByte()).ToString() + ((char)br.ReadByte()) + ((char)br.ReadByte()) + ((char)br.ReadByte());

            if (header != "GRAT")
                return false;

            majorVersion = br.ReadByte();
            minorVersion = br.ReadByte();

            if (majorVersion != 1 || minorVersion != 2)
                return false;

            _width = br.ReadInt32();
            _height = br.ReadInt32();

            _cells = new Cell[_width * _height];
            for (int i = 0; i < _cells.Length; i++)
            {
                Cell c = new Cell();

                c.Load(br);

                _cells[i] = c;
            }

            Logger.WriteLine("Altitude v{0}.{1} status: {2}x{3} - {4} cells", majorVersion, minorVersion, _width, _height, _cells.Length);

            return true;
        }
Beispiel #25
0
 public CellTag(Cell cell, string tag)
     : base(tag)
 {
     AddClass(GrammarConstants.CELL);
     this.AddSafeClassName(cell.Key);
     MetaData(GrammarConstants.KEY, cell.Key);
 }
        public void GridCellInstantiationTest()
        {
            Grid grid;

            // Assert each cell in grid is instantiated and initialized with expected default chemical concentrations
            grid = new Grid(4);
            for (int column = 0; column < grid.Size; column++)
            {
                for (int row = 0; row < grid.Size; row++)
                {
                    Assert.AreEqual(grid[column, row]["A"], 0);
                    Assert.AreEqual(grid[column, row]["B"], 0);
                }
            }

            // Assert each cell in grid is instantiated and initialized with given chemical concentrations
            Cell cell = new Cell
            {
                { "A", 0.25 },
                { "B", 0.75 }
            };
            grid = new Grid(4, cell);
            for (int column = 0; column < grid.Size; column++)
            {
                for (int row = 0; row < grid.Size; row++)
                {
                    Assert.AreEqual(grid[column, row]["A"], 0.25);
                    Assert.AreEqual(grid[column, row]["B"], 0.75);
                }
            }
        }
Beispiel #27
0
 public Output Reify(
     Cell<IMaybe<Size>> size,
     Stream<MouseEvent> sMouse, Stream<KeyEvent> sKey,
     Cell<long> focus, Supply idSupply)
 {
     return this.reify(size, sMouse, sKey, focus, idSupply);
 }
    private static Cell FindFirstExit(Cell startingPoint)
    {
        var path = new Queue<Cell>();
        if (startingPoint != null)
        {
            path.Enqueue(startingPoint);
        }

        while (path.Count > 0)
        {
            var curretnCell = path.Dequeue();

            if (IsExit(curretnCell))
            {
                return curretnCell;
            }

            TryDirection(path, curretnCell, "U", 0, -1);
            TryDirection(path, curretnCell, "R", 1, 0);
            TryDirection(path, curretnCell, "D", 0, 1);
            TryDirection(path, curretnCell, "L", -1, 0);
        }

        return null;
    }
Beispiel #29
0
        public CellTag AddCell(Cell cell, string tagName)
        {
            var child = new CellTag(cell, tagName);
            Append(child);

            return child;
        }
 public void CellReproducesWith3Neighbors()
 {
     var c = new Cell(1, 2);
     c.IsAlive = false;
     c.Neighbors = 3;
     Assert.AreEqual(true, c.IsAlive);
 }
Beispiel #31
0
 public void ClearCell(Cell cell)
 {
     buildingsRefs.SetCellValue(cell, null);
 }
Beispiel #32
0
 public Erosion(EffectDice effect, FightActor caster, SpellCastHandler castHandler, Cell targetedCell, bool critical) : base(effect, caster, castHandler, targetedCell, critical)
 {
 }
Beispiel #33
0
        protected void ExcelOut(List <UserInfo> userList)
        {
            //生成Excel开始
            string FilePath = "~/xml/Demo.xls";

            XlsDocument xls = new XlsDocument();                        //创建空xls文档

            xls.FileName = Server.MapPath(FilePath);                    //保存路径,如果直接发送到客户端的话只需要名称 生成名称

            Worksheet sheet = xls.Workbook.Worksheets.AddNamed("会员列表"); //创建一个工作页为Dome

            //设置指定工作页跨行跨列
            MergeArea ma = new MergeArea(1, 1, 1, 6);//合并单元格 行与列

            sheet.AddMergeArea(ma);

            //设置指定工作页跨行跨列结束

            //创建列样式创建列时引用
            XF cellXF = xls.NewXF();

            cellXF.VerticalAlignment   = VerticalAlignments.Centered;
            cellXF.HorizontalAlignment = HorizontalAlignments.Centered;
            cellXF.Font.Height         = 24 * 12;
            cellXF.Font.Bold           = true;
            //cellXF.Pattern = 1;//设定单元格填充风格。如果设定为0,则是纯色填充
            //cellXF.PatternBackgroundColor = Colors.Red;//填充的背景底色
            //cellXF.PatternColor = Colors.Red;//设定填充线条的颜色
            //创建列样式结束

            //创建列
            Cells cells = sheet.Cells; //获得指定工作页列集合
            //列操作基本
            Cell cell = cells.Add(1, 1, "会员列表", cellXF);

            //设置XY居中
            cell.HorizontalAlignment = HorizontalAlignments.Centered;
            cell.VerticalAlignment   = VerticalAlignments.Centered;
            //设置字体
            cell.Font.Bold       = true;               //设置粗体
            cell.Font.ColorIndex = 0;                  //设置颜色码
            cell.Font.FontFamily = FontFamilies.Roman; //设置字体 默认为宋体
            //创建列结束


            //创建数据
            int LineNum = 3;

            if (userList.Count > 0)
            {
                cells.Add(2, 1, "序号");
                cells.Add(2, 2, "姓名");
                cells.Add(2, 3, "公司简称");
                cells.Add(2, 4, "品牌");
                cells.Add(2, 5, "手机");
                cells.Add(2, 6, "Email");
                //cells.Add(2, 7, "原始岗位");
                //cells.Add(2, 5, "性别");
                //cells.Add(2, 8, "用户ID");
                //cells.Add(2, 9, "工作岗位");
                //cells.Add(2, 9, "学习岗位");
                //cells.Add(2, 10, "帐户类型");
                foreach (UserInfo Info in userList)
                {
                    cells.Add(LineNum, 1, LineNum - 2);
                    cells.Add(LineNum, 2, Info.RealName);
                    cells.Add(LineNum, 3, ReadCompany(Info.CompanyID).CompanySimpleName);
                    cells.Add(LineNum, 4, ReadBrandName(ProductBrandBLL.ReadProductBrandCacheList(StringHelper.SubString(ReadCompany(Info.CompanyID).BrandId, "17"))));
                    cells.Add(LineNum, 5, Info.Mobile);
                    cells.Add(LineNum, 6, Info.Email);
                    //cells.Add(LineNum, 7, Info.PostName);
                    //cells.Add(LineNum, 5, EnumHelper.ReadEnumChineseName<SexType>(Info.Sex));
                    //cells.Add(LineNum, 2, PostBLL.ReadPost(Info.Department).PostName);
                    //cells.Add(LineNum, 8, Info.UserName);
                    //cells.Add(LineNum, 9, BLLPost.ReadPost(Info.PostId).PostName);
                    //cells.Add(LineNum, 9, PostBLL.ReadPost(Info.StudyPostID).PostName);
                    //cells.Add(LineNum, 10, AdminGroupBLL.ReadAdminGroupCache(Info.GroupID).Name);

                    LineNum = LineNum + 1;
                }
            }
            //
            //生成保存到服务器如果存在不会覆盖并且报异常所以先删除在保存新的
            //ScriptHelper.Alert(Server.MapPath("~/Demo.xls"));
            if (File.Exists(Server.MapPath(FilePath)))
            {
                File.Delete(Server.MapPath(FilePath));//删除
            }
            //保存文档
            xls.Save(Server.MapPath(FilePath)); //保存到服务器
            xls.Send();                         //发送到客户端
        }
Beispiel #34
0
    public string PlayfairCipher(string keyWord, string plainText)
    {
        //Debug.LogFormat("[Playfair #{2}] PlayfairCipher started – Encrypting text {1} with key {0}", keyWord, plainText, _moduleId);
        //Define alphabet
        //There is no J in the alphabet, I is used instead!
        char[] alphabet = "ABCDEFGHIKLMNOPQRSTUVWXYZ".ToCharArray();

        //region Adjust Key
        keyWord = keyWord.Trim();
        keyWord = keyWord.Replace(" ", "");
        keyWord = keyWord.Replace("J", "I");
        keyWord = keyWord.ToUpper();

        StringBuilder keyString = new StringBuilder();

        foreach (char c in keyWord)
        {
            if (!keyString.ToString().Contains(c))
            {
                keyString.Append(c);
                alphabet = alphabet.Where(val => val != c).ToArray();
            }
        }
        //endregion

        adjustText(plainText);

        //If the Length of the plain text is odd add X
        if ((plainText.Length % 2 > 0))
        {
            plainText += "X";
        }

        List <string> plainTextEdited = new List <string>();

        //Split plain text into pairs
        for (int i = 0; i < plainText.Length; i += 2)
        {
            //If a pair of chars contains the same letters replace one of them with X
            if (plainText[i].ToString() == plainText[i + 1].ToString())
            {
                plainTextEdited.Add(plainText[i].ToString() + 'X');
            }
            else
            {
                plainTextEdited.Add(plainText[i].ToString() + plainText[i + 1].ToString());
            }
        }
        //endregion



        //region Create 5 x 5 matrix
        List <Cell> matrix = new List <Cell>();

        int keyIDCounter      = 0;
        int alphabetIDCounter = 0;

        //Fill the matrix. First with the key characters then with the alphabet
        for (int x = 0; x < 5; x++)
        {
            for (int y = 0; y < 5; y++)
            {
                if (keyIDCounter < keyString.Length)
                {
                    Cell cell = new Cell(keyString[keyIDCounter], x, y);
                    matrix.Add(cell);
                    keyIDCounter++;
                }
                else
                {
                    Cell cell = new Cell(alphabet[alphabetIDCounter], x, y);
                    matrix.Add(cell);
                    alphabetIDCounter++;
                }
            }
        }
        //endregion



        //region Write cipher

        StringBuilder cipher = new StringBuilder();

        foreach (string pair in plainTextEdited)
        {
            int  indexA = matrix.FindIndex(c => c.character == pair[0]);
            Cell a      = matrix[indexA];

            int  indexB = matrix.FindIndex(c => c.character == pair[1]);
            Cell b      = matrix[indexB];

            //Write cipher
            if (a.X == b.X)
            {
                cipher.Append(matrix[matrix.FindIndex(c => c.Y == (a.Y + 1) % 5 && c.X == a.X)].character);
                cipher.Append(matrix[matrix.FindIndex(c => c.Y == (b.Y + 1) % 5 && c.X == b.X)].character);
            }
            else if (a.Y == b.Y)
            {
                cipher.Append(matrix[matrix.FindIndex(c => c.Y == a.Y && c.X == (a.X + 1) % 5)].character);
                cipher.Append(matrix[matrix.FindIndex(c => c.Y == b.Y % 5 && c.X == (b.X + 1) % 5)].character);
            }
            else
            {
                cipher.Append(matrix[matrix.FindIndex(c => c.X == a.X && c.Y == b.Y)].character);
                cipher.Append(matrix[matrix.FindIndex(c => c.X == b.X % 5 && c.Y == a.Y)].character);
            }
        }
        //endregion
        //Debug.LogFormat ("[Playfair #{1}] – {0}", cipher.ToString(), _moduleId);
        return(cipher.ToString());
    }
    void Update()
    {
        Vector3 localPoint;
        RaycastHit hit;
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        if (Input.GetKeyUp(KeyCode.Mouse0))
        {
            selected.GetComponent<PictureCell>().cell.pos = new Vector2(selected.localPosition.x, selected.localPosition.y);
            selected = null;
            alreadyPainted = new List<Transform>();
        }
        if (selected != null)
        {          
            if(Physics.Raycast(ray, out hit, 1000f, bgMask))
            {
                localPoint = map.transform.worldToLocalMatrix * new Vector3(hit.point.x, hit.point.y, 0);
                selected.localPosition = localPoint;
            }
        }
        else if (Input.GetKeyDown(KeyCode.Mouse0) && _editMode != EditMode.OFF)
        {
            if (Physics.Raycast(ray, out hit))
            {
                if (hit.collider.CompareTag("Background"))
                {
                    if (_editMode == EditMode.ADD)
                    {
                        localPoint = map.transform.worldToLocalMatrix * new Vector3(hit.point.x, hit.point.y, 0);
                        Transform newCell = Instantiate(cellPrefab, map.cellsContainer).transform;
                        newCell.localPosition = localPoint;
                        Cell site = new Cell { pos = new Vector2(localPoint.x, localPoint.y) };
                        newCell.GetComponent<PictureCell>().cell = site;
                        map.GetDiagram().cells.Add(site);
                    }
                }
                else if (hit.collider.CompareTag("Site"))
                {
                    if (_editMode == EditMode.DELETE)
                    {
                        map.GetDiagram().cells.Remove(hit.collider.gameObject.GetComponent<PictureCell>().cell);
                        Destroy(hit.collider.gameObject);
                    }
                    else if (_editMode == EditMode.MOVE)
                    {
                        selected = hit.collider.transform;
                    }
                }
            }

        }
        else if (Input.GetKey(KeyCode.Mouse0) && (edgePaint != EdgePaint.OFF || cellPaint != CellPaint.OFF))
        {
            if(Physics.Raycast(ray, out hit))
            {
                if (hit.collider.CompareTag("Site"))
                {
                    if(cellPaint == CellPaint.ERASER)
                    {
                        hit.collider.GetComponent<MeshRenderer>().enabled = false;
                    }
                    else if(cellPaint != CellPaint.OFF)
                    {
                        MeshRenderer rend = hit.collider.GetComponent<MeshRenderer>();
                        switch (cellPaint)
                        {
                            case CellPaint.FOREST:
                                rend.material = forestMat;
                                break;
                            case CellPaint.FARM:
                                rend.material = farmMat;
                                break;
                            case CellPaint.RURAL:
                                rend.material = ruralMat;
                                break;
                            case CellPaint.URBAN:
                                rend.material = urbanMat;
                                break;
                            case CellPaint.WATER:
                                rend.material = waterMat;
                                break;
                        }
                        rend.enabled = true;
                        if (!alreadyPainted.Contains(rend.transform))
                        {
                            alreadyPainted.Add(rend.transform);
                            if (cellPaint == CellPaint.FARM || cellPaint == CellPaint.URBAN)
                                rend.gameObject.GetComponent<PictureCell>().Rotate(Random.Range(0, 360));
                            else
                                rend.gameObject.GetComponent<PictureCell>().Rotate(0);
                        }
                    }
                }
                else if (hit.collider.CompareTag("Edge"))
                {
                    if(edgePaint != EdgePaint.OFF)
                    {
                        Transform parent = hit.collider.transform.parent;
                        LineRenderer rend = parent.GetComponent<LineRenderer>();
                        PictureEdge edge = parent.GetComponent<PictureEdge>();

                        switch (edgePaint)
                        {
                            case EdgePaint.RIVER:
                                rend.startColor = riverColor;
                                rend.endColor = riverColor;
                                edge.painted = true;
                                break;
                            case EdgePaint.ROAD:
                                rend.startColor = roadColor;
                                rend.endColor = roadColor;
                                edge.painted = true;
                                break;
                            case EdgePaint.WALL:
                                rend.startColor = wallColor;
                                rend.endColor = wallColor;
                                edge.painted = true;
                                break;
                            case EdgePaint.ERASER:
                                rend.startColor = StyleManager.Instance.GetForeground();
                                rend.endColor = StyleManager.Instance.GetForeground();
                                edge.painted = false;
                                break;
                        }
                    }
                    
                }
                
            }
        }
        
    }
 /// <summary>
 /// the basic function; requires only the map and the start and end Cells (advanced features are turned on)
 /// </summary>
 /// <param name="map">The Map</param>
 /// <param name="start">The starting Cell</param>
 /// <param name="end">The ending Cell</param>
 /// <returns>The path as a list of waypoints</returns>
 public static List <Cell> between(Map map, Cell start, Cell end)
 {
     return(between(map, start, end, true));
 }
Beispiel #37
0
 private iTextSharp.text.Table GenerateMainTable(DataSet dsMainTable)
 {
     // 生成表格
     BaseFont bfChinese = BaseFont.CreateFont("C:\\WINDOWS\\Fonts\\simsun.ttc,1", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
     Font font22B = new Font(bfChinese, 22, iTextSharp.text.Font.BOLD);
     Font font22 = new Font(bfChinese, 22);
     Font font20B = new Font(bfChinese, 20, iTextSharp.text.Font.BOLD);
     Font font20 = new Font(bfChinese, 20);
     Font font19B = new Font(bfChinese, 19, iTextSharp.text.Font.BOLD);
     Font font19 = new Font(bfChinese, 19);
     Font font14B = new Font(bfChinese, 14, iTextSharp.text.Font.BOLD);
     Font font14 = new Font(bfChinese, 14);
     Font font13B = new Font(bfChinese, 13, iTextSharp.text.Font.BOLD);
     Font font13 = new Font(bfChinese, 13);
     Font font12B = new Font(bfChinese, 12, iTextSharp.text.Font.BOLD);
     Font font12 = new Font(bfChinese, 12);
     Font font11B = new Font(bfChinese, 11, iTextSharp.text.Font.BOLD);
     Font font11 = new Font(bfChinese, 11);
     Font font10B = new Font(bfChinese, 10, iTextSharp.text.Font.BOLD);
     Font font10 = new Font(bfChinese, 10);
     Font font9B = new Font(bfChinese, 9, iTextSharp.text.Font.BOLD);
     Font font9 = new Font(bfChinese, 9);
     Font font8B = new Font(bfChinese, 8, iTextSharp.text.Font.BOLD);
     Font font8 = new Font(bfChinese, 8);
     int intColumn = 0;
     
     intColumn += 4 + 20;
     iTextSharp.text.Table itbOutput = new iTextSharp.text.Table(intColumn);
     itbOutput.BorderWidth = 0;
     itbOutput.Cellpadding = 2;
     itbOutput.Cellspacing = 0;
     itbOutput.Width = 100;
     
     // 加入表头信息
     Cell cellTitle = new Cell(new Paragraph("消息", font19B));
     cellTitle.BorderWidth = 0;
     cellTitle.HorizontalAlignment = 1;
     cellTitle.VerticalAlignment = 1;
     cellTitle.Colspan = intColumn;
     itbOutput.AddCell(cellTitle);
       
     Cell cellTitleSpace = new Cell(new Paragraph(" ", font20B));
     cellTitleSpace.BorderWidth = 0;
     cellTitleSpace.HorizontalAlignment = 1;
     cellTitleSpace.VerticalAlignment = 1;
     cellTitleSpace.Colspan = intColumn;
     itbOutput.AddCell(cellTitleSpace);
     itbOutput.AddCell(cellTitleSpace);
     // 定义分割线
     Cell cellBorder = new Cell(new Paragraph("", font10B));
     cellBorder.BorderWidth = 0;
     cellBorder.BorderWidthBottom = 1;
     cellBorder.HorizontalAlignment = 1;
     cellBorder.VerticalAlignment = 1;
     cellBorder.Colspan = intColumn;
     if (dsMainTable.Tables.Count > 0)
     {
         foreach (DataRow drTemp in dsMainTable.Tables[0].Rows)
         {
             // 生成主表表格
         
             // 生成一对一相关表表格
         
             itbOutput.AddCell(cellTitleSpace);
             itbOutput.AddCell(cellTitleSpace);
         
         }
     }
     return itbOutput;
 }    
        private void RenderShading(Cell cell, Rectangle innerRect)
        {
            ShadingRenderer shadeRenderer = new ShadingRenderer(_gfx, cell.Shading);

            shadeRenderer.Render(innerRect.X, innerRect.Y, innerRect.Width, innerRect.Height, cell.RoundedCorner);
        }
Beispiel #39
0
 public void SetCellValue(Cell cell, T value)
 {
     SetCellValue(cell.cellID[0], cell.cellID[1], value);
 }
Beispiel #40
0
    /// <summary>
    /// Sets the target for the current action.
    /// </summary>
    public bool SetTarget(Vector2Int coordinate)
    {
        Cell cell = SelectedActor.Grid.GetCell(coordinate);

        return(SetTarget(cell));
    }
Beispiel #41
0
 public T GetCellValue(Cell cell) //Returns default value of assigned type if index outside array range
 {
     return(GetCellValue(cell.cellID[0], cell.cellID[1]));
 }
Beispiel #42
0
    // public void SetCellOccupiedState (Cell cell, bool isOccupied)
    // {
    //     SetCellOccupiedState(cell.cellID[0], cell.cellID[1], isOccupied? 1 : 0);
    // }

    // public void SetCellOccupiedState (uint cellID_x, uint cellID_y, bool isOccupied)
    // {
    //     SetCellOccupiedState(cellID_x, cellID_y, isOccupied? 1 : 0);
    // }

    // void SetCellOccupiedState(uint cellID_x, uint cellID_y, int state)
    // {
    //     cellOccupationStatus.SetCellValue(cellID_x, cellID_y, state);
    // }

    public void SetNewBuilding(Cell cell, Building newBuilding)
    {
        buildingsRefs.SetCellValue(cell, newBuilding);
        //SetCellOccupiedState(cell, true);
    }
Beispiel #43
0
 public CellTest()
 {
     Cell.RootPath = @"C:\";
     cell          = new Cell("1140209287");
 }
Beispiel #44
0
 public ref T GetCellRef(Cell cell)
 {
     return(ref GetCellRef(cell.cellID[0], cell.cellID[1]));
 }
Beispiel #45
0
        /// <summary>
        ///
        /// </summary>
        /// <remarks></remarks>
        /// <seealso cref=""/>
        /// <param name="variables"></param>
        /// <param name="path"></param>
        /// <param name="filename"></param>
        /// <returns></returns>
        public SpreadsheetDocument CreateTemplate(List <Variable> variables, string path, string filename)
        {
            if (!Directory.Exists(Path.Combine(AppConfiguration.DataPath, path)))
            {
                Directory.CreateDirectory(Path.Combine(AppConfiguration.DataPath, path));
            }

            SpreadsheetDocument template          = SpreadsheetDocument.Open(Path.Combine(AppConfiguration.GetModuleWorkspacePath("RPM"), "Template", _fileName), true);
            SpreadsheetDocument dataStructureFile = SpreadsheetDocument.Create(Path.Combine(AppConfiguration.DataPath, path, filename), template.DocumentType);

            //dataStructureFile = SpreadsheetDocument.Open(Path.Combine(AppConfiguration.GetModuleWorkspacePath("RPM"), "Template", filename), true);


            foreach (OpenXmlPart part in template.GetPartsOfType <OpenXmlPart>())
            {
                OpenXmlPart newPart = dataStructureFile.AddPart <OpenXmlPart>(part);
            }

            template.Close();

            // get worksheet
            List <StyleIndexStruct> styleIndex  = new List <StyleIndexStruct>();
            CellFormats             cellFormats = dataStructureFile.WorkbookPart.WorkbookStylesPart.Stylesheet.Elements <CellFormats>().First();
            //number 0,00
            CellFormat cellFormat = new CellFormat()
            {
                NumberFormatId = (UInt32Value)2U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)1U, ApplyNumberFormat = true
            };

            cellFormat.Protection        = new Protection();
            cellFormat.Protection.Locked = false;
            cellFormats.Append(cellFormat);
            styleIndex.Add(new StyleIndexStruct()
            {
                Name = "Decimal", Index = (uint)cellFormats.Count++, DisplayPattern = null
            });
            //number 0
            cellFormat = new CellFormat()
            {
                NumberFormatId = (UInt32Value)1U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)1U, ApplyNumberFormat = true
            };
            cellFormat.Protection        = new Protection();
            cellFormat.Protection.Locked = false;
            cellFormats.Append(cellFormat);
            styleIndex.Add(new StyleIndexStruct()
            {
                Name = "Number", Index = (uint)cellFormats.Count++, DisplayPattern = null
            });
            //text
            cellFormat = new CellFormat()
            {
                NumberFormatId = (UInt32Value)49U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)1U, ApplyNumberFormat = true
            };
            cellFormat.Protection        = new Protection();
            cellFormat.Protection.Locked = false;
            cellFormats.Append(cellFormat);
            styleIndex.Add(new StyleIndexStruct()
            {
                Name = "Text", Index = (uint)cellFormats.Count++, DisplayPattern = null
            });
            //DateTime
            cellFormat = new CellFormat()
            {
                NumberFormatId = (UInt32Value)22U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)1U, ApplyNumberFormat = true
            };
            cellFormat.Protection        = new Protection();
            cellFormat.Protection.Locked = false;
            cellFormats.Append(cellFormat);
            styleIndex.Add(new StyleIndexStruct()
            {
                Name = "DateTime", Index = (uint)cellFormats.Count++, DisplayPattern = DataTypeDisplayPattern.Pattern.Where(p => p.Systemtype.Equals(DataTypeCode.DateTime) && p.Name.Equals("DateTime")).FirstOrDefault()
            });
            //Date
            cellFormat = new CellFormat()
            {
                NumberFormatId = (UInt32Value)14U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)1U, ApplyNumberFormat = true
            };
            cellFormat.Protection        = new Protection();
            cellFormat.Protection.Locked = false;
            cellFormats.Append(cellFormat);
            styleIndex.Add(new StyleIndexStruct()
            {
                Name = "Date", Index = (uint)cellFormats.Count++, DisplayPattern = DataTypeDisplayPattern.Pattern.Where(p => p.Systemtype.Equals(DataTypeCode.DateTime) && p.Name.Equals("Date")).FirstOrDefault()
            });
            //Time
            cellFormat = new CellFormat()
            {
                NumberFormatId = (UInt32Value)21U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)1U, ApplyNumberFormat = true
            };
            cellFormat.Protection        = new Protection();
            cellFormat.Protection.Locked = false;
            cellFormats.Append(cellFormat);
            styleIndex.Add(new StyleIndexStruct()
            {
                Name = "Time", Index = (uint)cellFormats.Count++, DisplayPattern = DataTypeDisplayPattern.Pattern.Where(p => p.Systemtype.Equals(DataTypeCode.DateTime) && p.Name.Equals("Time")).FirstOrDefault()
            });

            Worksheet worksheet = dataStructureFile.WorkbookPart.WorksheetParts.First().Worksheet;



            List <Row> rows = GetRows(worksheet, 1, 11);

            foreach (Variable var in variables)
            {
                DataContainerManager CM            = new DataContainerManager();
                DataAttribute        dataAttribute = CM.DataAttributeRepo.Get(var.DataAttribute.Id);

                int    indexVar    = variables.ToList().IndexOf(var) + 1;
                string columnIndex = GetClomunIndex(indexVar);

                string cellRef = columnIndex + 1;
                Cell   cell    = new Cell()
                {
                    CellReference = cellRef,
                    StyleIndex    = (UInt32Value)4U,
                    DataType      = CellValues.String,
                    CellValue     = new CellValue(var.Label)
                };
                rows.ElementAt(0).AppendChild(cell);

                cellRef = columnIndex + 2;
                cell    = new Cell()
                {
                    CellReference = cellRef,
                    DataType      = CellValues.String,
                    StyleIndex    = getExcelStyleIndex(dataAttribute.DataType, styleIndex),
                    CellValue     = new CellValue("")
                };
                rows.ElementAt(1).AppendChild(cell);

                cellRef = columnIndex + 3;
                cell    = new Cell()
                {
                    CellReference = cellRef,
                    StyleIndex    = (UInt32Value)4U,
                    DataType      = CellValues.String,
                    CellValue     = new CellValue(var.Id.ToString())
                };
                rows.ElementAt(2).AppendChild(cell);



                cellRef = columnIndex + 4;
                cell    = new Cell()
                {
                    CellReference = cellRef,
                    StyleIndex    = (UInt32Value)4U,
                    DataType      = CellValues.String,
                    CellValue     = new CellValue(dataAttribute.ShortName)
                };
                rows.ElementAt(3).AppendChild(cell);

                // description from variable
                // if not then from attribute
                string description = "";
                description = String.IsNullOrEmpty(var.Description) ? dataAttribute.Description : var.Description;

                cellRef = columnIndex + 5;
                cell    = new Cell()
                {
                    CellReference = cellRef,
                    StyleIndex    = (UInt32Value)4U,
                    DataType      = CellValues.String,
                    CellValue     = new CellValue(description)
                };
                rows.ElementAt(4).AppendChild(cell);

                string classification = "";

                if (dataAttribute.Classification != null)
                {
                    classification = dataAttribute.Classification.Name;
                }

                cellRef = columnIndex + 6;
                cell    = new Cell()
                {
                    CellReference = cellRef,
                    StyleIndex    = (UInt32Value)4U,
                    DataType      = CellValues.String,
                    CellValue     = new CellValue(classification)
                };
                rows.ElementAt(5).AppendChild(cell);

                string unit = "";

                if (var.Unit != null)
                {
                    unit = var.Unit.Name;
                }

                cellRef = columnIndex + 7;
                cell    = new Cell()
                {
                    CellReference = cellRef,
                    StyleIndex    = (UInt32Value)4U,
                    DataType      = CellValues.String,
                    CellValue     = new CellValue(unit)
                };
                rows.ElementAt(6).AppendChild(cell);

                string dataType = "";

                if (dataAttribute.DataType != null)
                {
                    dataType = dataAttribute.DataType.Name;
                }

                cellRef = columnIndex + 8;
                cell    = new Cell()
                {
                    CellReference = cellRef,
                    StyleIndex    = (UInt32Value)4U,
                    DataType      = CellValues.String,
                    CellValue     = new CellValue(dataType)
                };
                rows.ElementAt(7).AppendChild(cell);

                cellRef = columnIndex + 9;
                cell    = new Cell()
                {
                    CellReference = cellRef,
                    StyleIndex    = (UInt32Value)4U,
                    DataType      = CellValues.String,
                    CellValue     = new CellValue(var.IsValueOptional.ToString())
                };
                rows.ElementAt(8).AppendChild(cell);

                cellRef = columnIndex + 10;
                cell    = new Cell()
                {
                    CellReference = cellRef,
                    StyleIndex    = (UInt32Value)4U,
                    DataType      = CellValues.String,
                    CellValue     = new CellValue(dataAttribute.IsMultiValue.ToString())
                };
                rows.ElementAt(9).AppendChild(cell);
            }

            foreach (DefinedName name in dataStructureFile.WorkbookPart.Workbook.GetFirstChild <DefinedNames>())
            {
                if (name.Name == "Data" || name.Name == "VariableIdentifiers")
                {
                    string[] tempArr = name.InnerText.Split('$');
                    string   temp    = "";
                    tempArr[tempArr.Count() - 2] = GetClomunIndex(variables.Count());
                    foreach (string t in tempArr)
                    {
                        if (t == tempArr.First())
                        {
                            temp = temp + t;
                        }
                        else
                        {
                            temp = temp + "$" + t;
                        }
                    }
                    name.Text = temp;
                }
            }

            //WorkbookPart workbookPart = spreadsheetDocument.WorkbookPart;
            //WorksheetPart worksheetPart = workbookPart.WorksheetParts.First();

            dataStructureFile.WorkbookPart.Workbook.Save();

            dataStructureFile.Close();

            return(dataStructureFile);
        }
Beispiel #46
0
        private void createNewAppointment()
        {
            goToCalendarModule();
            calendarRepo.MainForm.newEventBtn.Click();

            try {
                calendarRepo.EventDetailForm.SelfInfo.WaitForExists(customWaitTime);
            } catch (Exception) {
                calendarRepo.MainForm.newEventBtn.Click();
            }

            calendarRepo.EventDetailForm.titleTextInfo.WaitForAttributeEqual(customWaitTime, "Visible", true);
            calendarRepo.EventDetailForm.titleText.PressKeys("Ranorex sanity " + appoinmentStartTime.ToString("hh:mm tt"));
            calendarRepo.EventDetailForm.startTimeText.PressKeys(appoinmentStartTime.AddMinutes(30).ToString("hh:mm tt"));
            calendarRepo.EventDetailForm.locationText.Click();
            calendarRepo.EventDetailForm.locationText.PressKeys("Meeting Room");
            calendarRepo.EventDetailForm.okBtn.Click();

            try {
                calendarRepo.EventDetailForm.SelfInfo.WaitForNotExists(customWaitTime);
            } catch (Exception) {
                if (calendarRepo.AppointmentOverlapDialog.SelfInfo.Exists())
                {
                    calendarRepo.AppointmentOverlapDialog.itsOkRadioBtn.Click();
                    calendarRepo.AppointmentOverlapDialog.okBtn.Click();

                    try {
                        calendarRepo.AppointmentOverlapDialog.SelfInfo.WaitForNotExists(customWaitTime);
                    } catch (Exception) {
                        Report.Log(ReportLevel.Failure, "Failed to dismiss the appointment overlap dialog");
                    }
                }

                if (calendarRepo.EventDetailForm.okBtnInfo.Exists())
                {
                    calendarRepo.EventDetailForm.okBtn.Click();
                }
            }

            try {
                calendarRepo.EventDetailForm.SelfInfo.WaitForNotExists(customWaitTime);
            } catch (Exception) {
                Report.Log(ReportLevel.Failure, "Failed to create new appointment");
            }

            calendarRepo.MainForm.CalendarIndexFormBottomPanel.Today.Click();
            calendarRepo.MainForm.DayView.leftPanelInfo.WaitForExists(customWaitTime);
            calendarRepo.MainForm.DayView.rightListInfo.WaitForExists(customWaitTime);
            calendarRepo.MainForm.DayView.ToDos.Click();
            calendarRepo.AmicusAttorneyXWin.appointmentMenuItem.Select();

            try {
                appointment = String.Format("?/?/form[@controlname='CalendarIndexForm']/container[@controlname='pnlBase']//table[@accessiblename='Band 0']/row/cell[@text='Ranorex sanity {0}']", appoinmentStartTime.ToString("hh:mm tt"));
                apptName    = String.Format("Ranorex sanity {0}", appoinmentStartTime.ToString("hh:mm tt"));
                Report.Info("New Ranorex automation appointment created: " + appointment.Text);
            } catch (Exception) {
                Report.Log(ReportLevel.Info, "Ranorex automation appointment visible? " + appointment.Element.Visible.ToString());
            }

//          try {
//              IList<Cell>events = calendarRepo.MainForm.DayView.eventTable.FindDescendants<Cell>();
//              Report.Info("Table: " + calendarRepo.MainForm.DayView.eventTable.ToString());
//              foreach (Cell cell in events) {
//                  Report.Info("Cell: " + cell.Text);
//              }
//          } catch (Exception) {
//
//              throw;
//          }
        }
Beispiel #47
0
 protected override void ConstructOutermostCellContents(Cell cell)
 {
 }
Beispiel #48
0
        private void FillData()
        {
            _builder.MoveToMergeField("缺曠獎懲");

            Cell cell = _builder.CurrentParagraph.ParentNode as Cell;
            //cell.CellFormat.Borders.Top.LineStyle = LineStyle.Double;

            double width         = cell.CellFormat.Width;
            int    columnCount   = _manager.DisciplineCount + _manager.AttendacneCount;
            double miniUnitWitdh = width / (double)columnCount;

            Table table = _builder.StartTable();

            _builder.RowFormat.HeightRule = HeightRule.Exactly;
            _builder.RowFormat.Height     = 18.0;

            _builder.InsertCell().CellFormat.Width = miniUnitWitdh * _manager.DisciplineCount;
            _builder.Write("獎懲情形");
            if (_manager.AttendacneCount > 0)
            {
                _builder.InsertCell().CellFormat.Width = miniUnitWitdh * _manager.AttendacneCount;
                _builder.Write("缺曠情形(單位節數)");
            }
            _builder.EndRow();

            foreach (var key in _manager.Discipline.Keys)
            {
                _builder.InsertCell().CellFormat.Width = miniUnitWitdh * _manager.Discipline[key].Count;
                _builder.Write(key);
            }
            foreach (var key in _manager.Attendance.Keys)
            {
                _builder.InsertCell().CellFormat.Width = miniUnitWitdh * _manager.Attendance[key].Count;
                _builder.Write(key);
            }
            _builder.EndRow();

            List <int> valueList = new List <int>();

            foreach (var key in _manager.Discipline.Keys)
            {
                foreach (var instance in _manager.Discipline[key].Keys)
                {
                    _builder.InsertCell().CellFormat.Width = miniUnitWitdh;
                    _builder.Write(instance);
                    valueList.Add(_manager.Discipline[key][instance]);
                }
            }
            foreach (var key in _manager.Attendance.Keys)
            {
                foreach (var instance in _manager.Attendance[key].Keys)
                {
                    _builder.InsertCell().CellFormat.Width = miniUnitWitdh;
                    _builder.Write(instance);
                    valueList.Add(_manager.Attendance[key][instance]);
                }
            }
            _builder.EndRow();

            foreach (int times in valueList)
            {
                _builder.InsertCell().CellFormat.Width = miniUnitWitdh;
                //string v = string.Empty;
                //if (times > 0) v = "" + times;
                _builder.Write("" + times);
            }
            _builder.EndRow();
            _builder.EndTable();

            //去除表格四邊的線
            foreach (Cell c in table.FirstRow.Cells)
            {
                c.CellFormat.Borders.Top.LineStyle = LineStyle.None;
            }

            foreach (Cell c in table.LastRow.Cells)
            {
                c.CellFormat.Borders.Bottom.LineStyle = LineStyle.None;
            }

            foreach (Row r in table.Rows)
            {
                r.FirstCell.CellFormat.Borders.Left.LineStyle = LineStyle.None;
                r.LastCell.CellFormat.Borders.Right.LineStyle = LineStyle.None;
            }

            //補上去一條線…
            (table.ParentNode as Cell).CellFormat.Borders.Top.LineStyle = LineStyle.Double;
        }
Beispiel #49
0
        private List <Object> ToGeometry(Topology topology, double tolerance)
        {
            if (topology == null)
            {
                return(null);
            }

            List <Object> geometries = new List <Object>();
            Vertex        vertex     = topology as Vertex;

            if (vertex != null)
            {
                geometries.Add(ToPoint(vertex));
                return(geometries);
            }

            Edge edge = topology as Edge;

            if (edge != null)
            {
                geometries.Add(ToCurve(edge));
                return(geometries);
            }

            Wire wire = topology as Wire;

            if (wire != null)
            {
                return(ToCurves(wire));
            }

            Face face = topology as Face;

            if (face != null)
            {
                geometries.Add(ToSurface(face, tolerance));
                return(geometries);
            }

            Shell shell = topology as Shell;

            if (shell != null)
            {
                return(ToBrep(shell, tolerance));
            }

            Cell cell = topology as Cell;

            if (cell != null)
            {
                return(ToBrep(cell, tolerance));
            }

            CellComplex cellComplex = topology as CellComplex;

            if (cellComplex != null)
            {
                return(ToBreps(cellComplex, tolerance));
            }

            Cluster cluster = topology as Cluster;

            if (cluster != null)
            {
                return(ToGeometries(cluster, tolerance));
            }

            Aperture aperture = topology as Aperture;

            if (aperture != null)
            {
                return(ToGeometry(aperture.Topology, tolerance));
            }

            throw new Exception("The type of the input topology is not recognized.");
        }
Beispiel #50
0
        public void BDAttack()
        {
            ActionTime = Envir.Time + 300;
            AttackTime = Envir.Time + AttackSpeed;
            #region Slash Attack
            if (InSlashRange && Envir.Time > SlashAttackTime && Envir.Random.Next(5) == 0)
            {
                bool attacked = false;
                if (Target != null)
                {
                    MapObject _origTarget = Target;
                    //  Attempt to find a weaker target
                    Target = FindWeakTarget(CurrentLocation, 3);
                    if (Target == null)
                    {
                        Target = _origTarget;
                    }
                    Direction = Functions.DirectionFromPoint(CurrentLocation, Target.CurrentLocation);
                    if (Target.Attacked(this, GetAttackPower(MinSC, MaxSC), DefenceType.None) > 0)
                    {
                        attacked = true;
                        if (Envir.Random.Next(5) == 0)
                        {
                            Target.ApplyPoison(new Poison {
                                PType = PoisonType.Bleeding, Duration = Envir.Random.Next(3, 8), Owner = this, TickSpeed = 1000, Value = Envir.Random.Next(25, 50)
                            });
                        }
                    }
                }
                if (attacked)
                {
                    SlashAttackTime = Envir.Time + 2500;
                    Broadcast(new S.ObjectAttack {
                        Type = 0, Direction = Direction, Location = CurrentLocation, ObjectID = ObjectID
                    });
                    //Broadcast(new S.Chat { Message = string.Format("Slash"), Type = ChatType.System });
                    return;
                }
            }
            #endregion
            #region Cone Attack
            else if (InConeRange && Envir.Time > ConeAttackTime)
            {
                List <Point> conePoints = GetConePoints();
                bool         attacked   = false;
                for (int i = 0; i < conePoints.Count; i++)
                {
                    if (!CurrentMap.ValidPoint(conePoints[i]))
                    {
                        continue;
                    }
                    Cell cell = CurrentMap.GetCell(conePoints[i]);
                    if (cell == null || cell.Objects == null || cell.Objects.Count <= 0)
                    {
                        continue;
                    }
                    for (int x = 0; x < cell.Objects.Count; x++)
                    {
                        MapObject ob = cell.Objects[x];
                        switch (ob.Race)
                        {
                        case ObjectType.Player:
                        case ObjectType.Monster:
                        {
                            if (ob.IsAttackTarget(this))
                            {
                                if (ob.Attacked(this, GetAttackPower(MinMC, MaxMC), DefenceType.Agility) > 0)
                                {
                                    attacked = true;
                                    if (Envir.Random.Next(5) == 0)
                                    {
                                        Target.ApplyPoison(new Poison {
                                                PType = PoisonType.Slow, Duration = Envir.Random.Next(3, 8), Owner = this, TickSpeed = 1000, Value = GetAttackPower(MinMC, MaxMC)
                                            });
                                    }
                                    else if (Envir.Random.Next(10) == 0)
                                    {
                                        Target.ApplyPoison(new Poison {
                                                PType = PoisonType.Frozen, Duration = Envir.Random.Next(3, 8), Owner = this, TickSpeed = 1000, Value = GetAttackPower(MinMC, MaxMC)
                                            });
                                    }
                                }
                            }
                        }
                        break;
                        }
                    }
                }
                if (attacked)
                {
                    //  Only set the cone attack time if it succesfully hit a target
                    ConeAttackTime = Envir.Time + 5000;
                    Broadcast(new S.ObjectAttack {
                        Type = 1, Direction = Direction, Location = CurrentLocation, ObjectID = ObjectID, Spell = Spell.None
                    });
                    //Broadcast(new S.Chat { Message = string.Format("Cone"), Type = ChatType.System });
                    return;
                }
            }
            #endregion
            else if (Stage == 1 || Stage == 3)
            {
                if (Envir.Random.Next(5) == 0)
                {
                    if (!SpawnSlaves())
                    {
                        Attack();
                    }
                }
                else
                {
                    Attack();
                }

                return;
            }
            else
            {
                Attack();
            }
            return;
        }
Beispiel #51
0
 public override bool IsRightCellNotFliped(Cell cell)
 {
     return(IsRightCell(cell) && cell.State != Cell.CellState.Opened);
 }
Beispiel #52
0
        public override AView GetView(int position, AView convertView, ViewGroup parent)
        {
            Cell cell = null;

            Performance.Start();

            ListViewCachingStrategy cachingStrategy = Controller.CachingStrategy;
            var nextCellIsHeader = false;

            if (cachingStrategy == ListViewCachingStrategy.RetainElement || convertView == null)
            {
                if (_listView.IsGroupingEnabled)
                {
                    List <Cell> cells = GetCellsFromPosition(position, 2);
                    if (cells.Count > 0)
                    {
                        cell = cells[0];
                    }

                    if (cells.Count == 2)
                    {
                        nextCellIsHeader = cells[1].GetIsGroupHeader <ItemsView <Cell>, Cell>();
                    }
                }

                if (cell == null)
                {
                    cell = GetCellForPosition(position);
                    if (cell == null)
                    {
                        return(new AView(_context));
                    }
                }
            }

            var cellIsBeingReused = false;
            var layout            = convertView as ConditionalFocusLayout;

            if (layout != null)
            {
                cellIsBeingReused = true;
                convertView       = layout.GetChildAt(0);
            }
            else
            {
                layout = new ConditionalFocusLayout(_context)
                {
                    Orientation = Orientation.Vertical
                }
            };

            if (cachingStrategy == ListViewCachingStrategy.RecycleElement && convertView != null)
            {
                var boxedCell = convertView as INativeElementView;
                if (boxedCell == null)
                {
                    throw new InvalidOperationException($"View for cell must implement {nameof(INativeElementView)} to enable recycling.");
                }
                cell = (Cell)boxedCell.Element;

                // We are going to re-set the Platform here because in some cases (headers mostly) its possible this is unset and
                // when the binding context gets updated the measure passes will all fail. By applying this here the Update call
                // further down will result in correct layouts.
                cell.Platform = _listView.Platform;

                ICellController cellController = cell;
                cellController.SendDisappearing();

                int row            = position;
                var group          = 0;
                var templatedItems = TemplatedItemsView.TemplatedItems;
                if (_listView.IsGroupingEnabled)
                {
                    group = templatedItems.GetGroupIndexFromGlobal(position, out row);
                }

                var templatedList = templatedItems.GetGroup(group);

                if (_listView.IsGroupingEnabled)
                {
                    if (row == 0)
                    {
                        templatedList.UpdateHeader(cell, group);
                    }
                    else
                    {
                        templatedList.UpdateContent(cell, row - 1);
                    }
                }
                else
                {
                    templatedList.UpdateContent(cell, row);
                }

                cellController.SendAppearing();

                if (cell.BindingContext == ActionModeObject)
                {
                    ActionModeContext = cell;
                    ContextView       = layout;
                }

                if (ReferenceEquals(_listView.SelectedItem, cell.BindingContext))
                {
                    Select(_listView.IsGroupingEnabled ? row - 1 : row, layout);
                }
                else if (cell.BindingContext == ActionModeObject)
                {
                    SetSelectedBackground(layout, true);
                }
                else
                {
                    UnsetSelectedBackground(layout);
                }

                Performance.Stop();
                return(layout);
            }

            AView view = CellFactory.GetCell(cell, convertView, parent, _context, _listView);

            Performance.Start("AddView");

            if (cellIsBeingReused)
            {
                if (convertView != view)
                {
                    layout.RemoveViewAt(0);
                    layout.AddView(view, 0);
                }
            }
            else
            {
                layout.AddView(view, 0);
            }

            Performance.Stop("AddView");

            bool isHeader = cell.GetIsGroupHeader <ItemsView <Cell>, Cell>();

            AView bline;

            UpdateSeparatorVisibility(cell, cellIsBeingReused, isHeader, nextCellIsHeader, layout, out bline);

            UpdateSeparatorColor(isHeader, bline);

            if ((bool)cell.GetValue(IsSelectedProperty))
            {
                Select(position, layout);
            }
            else
            {
                UnsetSelectedBackground(layout);
            }

            layout.ApplyTouchListenersToSpecialCells(cell);

            Performance.Stop();

            return(layout);
        }
Beispiel #53
0
 public void MovePiece(Cell cell)
 {
     pieceToMove.Move(cell);
 }
Beispiel #54
0
 internal void Eat(Cell cell)
 {
     snakeList.AddFirst(new BodyCell(cell.Pos));
 }
Beispiel #55
0
        static int[][] FindCoarseningClusters(BitArray Ok2Coarsen, GridData CurrentGrid)
        {
            int JE = CurrentGrid.Cells.NoOfCells;
            int J  = CurrentGrid.Cells.NoOfLocalUpdatedCells;

            if (Ok2Coarsen.Length != JE)
            {
                throw new ArgumentException();
            }

            int[][] CellNeighbours = CurrentGrid.Cells.CellNeighbours;

            List <Cell> temp   = new List <Cell>();
            List <int>  tempCC = new List <int>();

            int RecursionDepht = -1;

            if (CurrentGrid.SpatialDimension == 1)
            {
                RecursionDepht = 1;
            }
            else if (CurrentGrid.SpatialDimension == 2)
            {
                RecursionDepht = 2;
            }
            else if (CurrentGrid.SpatialDimension == 3)
            {
                RecursionDepht = 4;
            }
            else
            {
                throw new NotSupportedException();
            }

            int[][] CoarseningCluster = new int[JE][];


            BitArray marker = new BitArray(JE);

            for (int j = 0; j < J; j++)
            {
                if (marker[j])
                {
                    continue;
                }
                if (!Ok2Coarsen[j])
                {
                    continue;
                }

                Cell Cell_j = CurrentGrid.Cells.GetCell(j);
                int  Level  = Cell_j.RefinementLevel;

                if (Level == 0)
                {
                    marker[j] = true;
                    continue;
                }

                temp.Clear();
                temp.Add(Cell_j);

                tempCC.Clear();
                tempCC.Add(j);

                //SearchGids = new long[Cell_j.CoarseningPeers.Length + 1];
                //Array.Copy(Cell_j.CoarseningPeers, SearchGids, SearchGids.Length - 1);
                //SearchGids[SearchGids.Length - 1] = Cell_j.GlobalID;
                int SearchID    = Cell_j.CoarseningClusterID;
                int ClusterSize = Cell_j.CoarseningClusterSize;
                Debug.Assert(SearchID > 0);


                bool complete = false;
                FindCoarseiningClusterRecursive(j, RecursionDepht, CellNeighbours, marker, CurrentGrid.Cells.GetCell, Level, SearchID, ClusterSize, tempCC, ref complete);
                foreach (int jC in tempCC)
                {
                    marker[jC] = true;
                }

                if (complete)
                {
                    if (!tempCC.Any(jC => Ok2Coarsen[jC] == false))
                    {
                        int[] CC = tempCC.ToArray();
                        foreach (int jC in CC)
                        {
                            Debug.Assert(CoarseningCluster[jC] == null);
                            CoarseningCluster[jC] = CC;
                        }
                    }
                    else
                    {
                        //Console.WriteLine("Not ok to coarsen.");
                    }
                }
            }


            return(CoarseningCluster);
        }
Beispiel #56
0
 public override bool IsRightCell(Cell cell)
 {
     return(cell.Type == Cell.CellType.Block && rightColors.Contains(cell.CurrentColor));
 }
Beispiel #57
0
    private void FindAvalableCell(Cell cell)
    {
        Cell avalableCell;

        #region Haut-Droite
        if (cell.Position[0] == 0 && cell.Position[6] == 0)
        {
            avalableCell = cell.Pair ? matrix[cell.Id - 14] : matrix[cell.Id - 13];
            if (avalableCell.End)
            {
                avalableCell.Parent = cell;
                find = true;
                return;
            }

            if (avalableCell.Walkable)
            {
                if (!avalableCell.InOpenList && !avalableCell.InClosedList)
                {
                    avalableCell.Parent     = cell;
                    avalableCell.InOpenList = true;
                    openList.Add(avalableCell);
                    FixeCell(avalableCell, cell);
                }
            }
        }
        #endregion

        #region Bas-Droite
        if (cell.Position[2] == 0 && cell.Position[6] == 0)
        {
            avalableCell = cell.Pair ? matrix[cell.Id + 14] : matrix[cell.Id + 15];
            if (avalableCell.End)
            {
                avalableCell.Parent = cell;
                find = true;
                return;
            }

            if (avalableCell.Walkable)
            {
                if (!avalableCell.InOpenList && !avalableCell.InClosedList)
                {
                    avalableCell.Parent     = cell;
                    avalableCell.InOpenList = true;
                    openList.Add(avalableCell);
                    FixeCell(avalableCell, cell);
                }
            }
        }
        #endregion

        #region Haut-Gauche
        if (cell.Position[0] == 0 && cell.Position[4] == 0)
        {
            avalableCell = cell.Pair ? matrix[cell.Id - 15] : matrix[cell.Id - 14];
            if (avalableCell.End)
            {
                avalableCell.Parent = cell;
                find = true;
                return;
            }

            if (avalableCell.Walkable)
            {
                if (!avalableCell.InOpenList && !avalableCell.InClosedList)
                {
                    avalableCell.Parent     = cell;
                    avalableCell.InOpenList = true;
                    openList.Add(avalableCell);
                    FixeCell(avalableCell, cell);
                }
            }
        }
        #endregion

        #region Bas-Gauche
        if (cell.Position[2] == 0 && cell.Position[4] == 0)
        {
            avalableCell = cell.Pair ? matrix[cell.Id + 13] : matrix[cell.Id + 14];
            if (avalableCell.End)
            {
                avalableCell.Parent = cell;
                find = true;
                return;
            }

            if (avalableCell.Walkable)
            {
                if (!avalableCell.InOpenList && !avalableCell.InClosedList)
                {
                    avalableCell.Parent     = cell;
                    avalableCell.InOpenList = true;
                    openList.Add(avalableCell);
                    FixeCell(avalableCell, cell);
                }
            }
        }
        #endregion

        #region Droite
        if (cell.Position[6] == 0 && cell.Position[7] == 0 && useDiagonals)
        {
            avalableCell = matrix[cell.Id + 1];
            if (avalableCell.End)
            {
                avalableCell.Parent = cell;
                find = true;
                return;
            }

            if (avalableCell.Walkable)
            {
                if (!avalableCell.InOpenList && !avalableCell.InClosedList)
                {
                    avalableCell.Parent     = cell;
                    avalableCell.InOpenList = true;
                    openList.Add(avalableCell);
                    FixeCell(avalableCell, cell);
                }
            }
        }
        #endregion

        #region Gauche
        if (cell.Position[4] == 0 && cell.Position[5] == 0 && useDiagonals)
        {
            avalableCell = matrix[cell.Id - 1];
            if (avalableCell.End)
            {
                avalableCell.Parent = cell;
                find = true;
                return;
            }

            if (avalableCell.Walkable)
            {
                if (!avalableCell.InOpenList && !avalableCell.InClosedList)
                {
                    avalableCell.Parent     = cell;
                    avalableCell.InOpenList = true;
                    openList.Add(avalableCell);
                    FixeCell(avalableCell, cell);
                }
            }
        }
        #endregion

        #region Haut
        if (cell.Position[0] == 0 && cell.Position[1] == 0 && useDiagonals)
        {
            avalableCell = matrix[cell.Id - 28];
            if (avalableCell.End)
            {
                avalableCell.Parent = cell;
                find = true;
                return;
            }

            if (avalableCell.Walkable)
            {
                if (!avalableCell.InOpenList && !avalableCell.InClosedList)
                {
                    avalableCell.Parent     = cell;
                    avalableCell.InOpenList = true;
                    openList.Add(avalableCell);
                    FixeCell(avalableCell, cell);
                }
            }
        }
        #endregion

        #region Bas
        if (cell.Position[2] == 0 && cell.Position[3] == 0 && useDiagonals)
        {
            avalableCell = matrix[cell.Id + 28];
            if (avalableCell.End)
            {
                avalableCell.Parent = cell;
                find = true;
                return;
            }

            if (avalableCell.Walkable)
            {
                if (!avalableCell.InOpenList && !avalableCell.InClosedList)
                {
                    avalableCell.Parent     = cell;
                    avalableCell.InOpenList = true;
                    openList.Add(avalableCell);
                    FixeCell(avalableCell, cell);
                }
            }
        }
        #endregion

        SortOpenList();
    }
Beispiel #58
0
        static void FindCoarseiningClusterRecursive(int j, int MaxRecursionDeph,
                                                    int[][] CellNeighbours, BitArray marker, Func <int, Cell> GetCell, int Level, int SearchID, int ClusterSize,
                                                    List <int> CoarseiningCluster, ref bool complete)
        {
            Debug.Assert(CoarseiningCluster.Contains(j) == true);

            int[] Neighs = CellNeighbours[j];
            foreach (var jNeigh in Neighs)
            {
                if (marker[jNeigh] == true)
                {
                    continue;
                }
                if (CoarseiningCluster.Contains(jNeigh))
                {
                    continue;
                }

                Cell Cell_neigh = GetCell(jNeigh);
                if (Cell_neigh.RefinementLevel != Level)
                {
                    continue;
                }

                if (Cell_neigh.CoarseningClusterID != SearchID)
                {
                    continue;
                }

                CoarseiningCluster.Add(jNeigh);

                if (CoarseiningCluster.Count == ClusterSize)
                {
                    complete = true;
#if DEBUG
                    foreach (int j1 in CoarseiningCluster)
                    {
                        Cell Cell_j1 = GetCell(j1);
                        Debug.Assert(Cell_j1.RefinementLevel > 0);
                        //Debug.Assert(Cell_j1.CoarseningPeers != null);
                        //Debug.Assert(Cell_j1.CoarseningPeers.Length == CoarseiningCluster.Count - 1);
                        Debug.Assert(Cell_j1.RefinementLevel == Level);
                        Debug.Assert(Cell_j1.CoarseningClusterID == SearchID);
                        Debug.Assert(Cell_j1.CoarseningClusterSize == ClusterSize);
                        //Debug.Assert(Array.IndexOf(SearchGids, Cell_j1.GlobalID) >= 0);
                        //foreach(long gid_cp in Cell_j1.CoarseningPeers) {
                        //    Debug.Assert(Array.IndexOf(SearchGids, gid_cp) >= 0);
                        //}
                    }
#endif
                    return;
                }

                if (MaxRecursionDeph > 0)
                {
                    FindCoarseiningClusterRecursive(jNeigh, MaxRecursionDeph - 1,
                                                    CellNeighbours, marker, GetCell, Level, SearchID, ClusterSize, CoarseiningCluster, ref complete);
                }

                if (complete)
                {
                    return;
                }
            }
        }
Beispiel #59
0
    private double GetFixedMouvementCost(Cell cellInspected, Cell currentCell)
    {
        double poid = PointWeight(cellInspected.Location);

        return(cellInspected.G + (cellInspected.Location.Y == currentCell.Location.Y || cellInspected.Location.X == currentCell.Location.X ? 10 : 15) * poid);
    }
Beispiel #60
0
    public void ExtractCellClicked(Cell cellClicked)
    {
        int targetX = cellClicked.gridPosition.x;
        int targetY = cellClicked.gridPosition.y;

        if (cellClicked.cellState != CellState.Discovered)
        {
            Debug.Log("Not discovered!");
            return;
        }

        switch (cellClicked.cellWorth)
        {
        case CellWorth.Max:
            Manager.instance.AddGold(100);
            break;

        case CellWorth.Half:
            Manager.instance.AddGold(50);
            break;

        case CellWorth.Quarter:
            Manager.instance.AddGold(25);
            break;

        case CellWorth.Nothing:
            Manager.instance.AddGold(10);
            break;
        }

        for (int i = -2; i < 3; i++)
        {
            if (i + targetX < 0 || i + targetX >= cellSizeX)
            {
                continue;
            }

            for (int j = -2; j < 3; j++)
            {
                if (j + targetY < 0 || j + targetY >= cellSizeY)
                {
                    continue;
                }

                if (allCells[i + targetX, j + targetY].cellState == CellState.Used)
                {
                    continue;
                }

                switch (allCells[i + targetX, j + targetY].cellWorth)
                {
                case CellWorth.Max:
                    allCells[i + targetX, j + targetY].cellWorth = CellWorth.Half;
                    allCells[i + targetX, j + targetY].GetComponent <Image>().color = Color.blue;
                    break;

                case CellWorth.Half:
                    allCells[i + targetX, j + targetY].cellWorth = CellWorth.Quarter;
                    allCells[i + targetX, j + targetY].GetComponent <Image>().color = Color.green;
                    break;

                case CellWorth.Quarter:
                    allCells[i + targetX, j + targetY].cellWorth = CellWorth.Nothing;
                    allCells[i + targetX, j + targetY].GetComponent <Image>().color = Color.red;
                    break;

                case CellWorth.Nothing:
                    allCells[i + targetX, j + targetY].cellWorth = CellWorth.Nothing;
                    allCells[i + targetX, j + targetY].GetComponent <Image>().color = Color.red;
                    break;
                }
            }
        }

        Image image2 = cellClicked.GetComponent <Image>();

        image2.color          = Color.black;
        cellClicked.cellState = CellState.Used;
    }