Exemple #1
0
 /// <summary>
 /// Позволяет задать всю необходимую для начала битвы информацию
 /// </summary>
 /// <param name="cellBaseFightingFor"></param>
 /// <param name="firstFigure"></param>
 /// <param name="secondFigure"></param>
 public void SetAllInitialInfo(FigureData firstFigure, FigureData secondFigure, CellBase cellBaseFightingFor)
 {
     Clear();
     _firstFigure     = firstFigure;
     _secondFigure    = secondFigure;
     _cellFightingFor = cellBaseFightingFor;
 }
Exemple #2
0
    /// <summary>
    /// Делает то же, что и MoveToAnotherCell, но с анимацией
    /// </summary>
    /// <param name="cellBase"></param>
    /// <returns></returns>
    public virtual IEnumerator MoveToAnotherCellWithAnimation(CellBase cellBase)
    {
        while (_isMoving)
        {
            yield return(new WaitForSeconds(_moveTime));
        }

        _isMoving = true;
        MoveToAnotherCell(cellBase);
        var rectTransform  = GetComponent <RectTransform>();
        var startPosition  = rectTransform.localPosition;
        var targetPosition = new Vector2(cellBase.RectTransform.localPosition.x + cellBase.RectTransform.rect.width / 2,
                                         cellBase.RectTransform.localPosition.y + cellBase.RectTransform.rect.height / 2);

        float startTime = Time.realtimeSinceStartup;
        float fraction  = 0f;

        while (fraction < 1f)
        {
            fraction = Mathf.Clamp01((Time.realtimeSinceStartup - startTime) / _moveTime);
            rectTransform.localPosition = Vector2.Lerp(startPosition, targetPosition, fraction);
            yield return(null);
        }

        if (!_isFirstMovement)
        {
            _movementSound.Play();
        }
        _isFirstMovement = false;
        _isMoving        = false;
    }
Exemple #3
0
        void upriseTerrain(int size, ref int landBudget)
        {
            int        currentSize    = 0;
            List <int> alreadyVisited = new List <int>();
            int        cell           = getRandomCell();

            pendingToVisit.queue(cell, 1);

            while (pendingToVisit.Count > 0 && landBudget != 0 && currentSize < size)
            {
                int current = pendingToVisit.dequeue();
                alreadyVisited.Add(current);
                currentSize += 1;
                if ((int)cellTypes[current] < maxElevation)
                {
                    cellTypes[current]++;
                }

                for (HexDirection d = HexDirection.NE; d <= HexDirection.NW; d++)
                {
                    CellBase neighbor = grid.GetCellBase(current).getNeigbour(d);
                    if (neighbor != null && !pendingToVisit.contains(neighbor.Id) && !alreadyVisited.Contains(neighbor.Id))
                    {
                        pendingToVisit.queue(neighbor.Id, Random.Range(0, 100) < jitterInput.value ? 1 : 0);
                    }
                }

                if (cellTypes[current] == CellType.Grass)
                {
                    landBudget--;
                }
            }
            pendingToVisit.clear();
            alreadyVisited.Clear();
        }
        private void MarkCellAsSelected(CellBase cell)
        {
            if (cell == null)
            {
                return;
            }

            if (cell.Cell.GetIsGroupHeader <ItemsView <Cell>, Cell>())
            {
                return;
            }

            foreach (var childCell in _list.Children.OfType <CellBase>())
            {
                bool isTargetCell = cell == childCell;

                childCell.VisibleWindow = isTargetCell;

                if (isTargetCell)
                {
                    _selectedCell = childCell;
                    childCell.ModifyBg(StateType.Normal, _selectionColor);
                }
            }
        }
Exemple #5
0
        public void ReplaceCell(List <CellBase> cells, CellBase newCell)
        {
            var cellToDelete = cells.SingleOrDefault(currentCell => currentCell.X == newCell.X && currentCell.Y == newCell.Y);

            cells.Remove(cellToDelete);
            cells.Add(newCell);
        }
        private void UpdateItem(CellBase cell)
        {
            cell.ButtonPressEvent += (sender, args) =>
            {
                var gtkCell = sender as CellBase;

                if (gtkCell != null && gtkCell.Cell != null)
                {
                    SelectedItem = gtkCell.Item;

                    MarkCellAsSelected(gtkCell);

                    OnItemTapped?.Invoke(this, new ItemTappedEventArgs(SelectedItem));
                }
            };

            cell.VisibleWindow = false;

            _list.PackStart(cell, false, false, 0);
            cell.ShowAll();

            var separator = new ListViewSeparator();

            _separators.Add(separator);
            _list.PackStart(separator, false, false, 0);
            separator.ShowAll();
        }
Exemple #7
0
        private void Subscriber_OnSubscriptionReply(Event eventObject, Session session)
        {
            Subscribe s = Subscribe.Create(eventObject);

            if (s != null)
            {
                foreach (var security in m_Securities)
                {
                    foreach (var field in m_Fields)
                    {
                        if (String.IsNullOrEmpty(security) || String.IsNullOrEmpty(field))
                        {
                            continue;
                        }
                        //Element element  = s[security, field];
                        //string v = element != null ? element.GetValue().ToString() : string.Empty;
                        object value = s[security, field];

                        //Utility.Log(this, "Update Value", field+ ":" +value);
                        string v = value != null?value.ToString() : string.Empty;

                        //Console.WriteLine("[" + security + "," + field + "] " + v);
                        if (!String.IsNullOrEmpty(v))
                        {
                            CellBase c = m_CellList.Values.FirstOrDefault(e => e.Name == security && e.Tag != null && e.Tag.ToString() == field);
                            if (c != null)
                            {
                                c.SetValue(v);
                            }
                        }
                    }
                }
            }
        }
    private ArrayList FindAllPossibleMove(CellBase cell)
    {
        if (cell.CurrentType != null)
        {
            switch ((int)cell.CurrentType.Type)
            {
            case 1:
                return(clsPawn.FindAllPossibleMove(_BoardState, new Vector2(cell.PosX + 1, cell.PosY + 1)));

            case 2:
                return(clsBishop.FindAllPossibleMove(_BoardState, new Vector2(cell.PosX + 1, cell.PosY + 1)));

            case 3:
                return(clsKnight.FindAllPossibleMove(_BoardState, new Vector2(cell.PosX + 1, cell.PosY + 1)));

            case 4:
                return(clsRook.FindAllPossibleMove(_BoardState, new Vector2(cell.PosX + 1, cell.PosY + 1)));

            case 5:
                return(clsQueen.FindAllPossibleMove(_BoardState, new Vector2(cell.PosX + 1, cell.PosY + 1)));

            case 6:
                return(clsKing.FindAllPossibleMove(_BoardState, new Vector2(cell.PosX + 1, cell.PosY + 1)));

            default: break;
            }
        }
        return(new ArrayList());
    }
    private void AiMove()
    {
        if (MyMove != null)
        {
            CellBase curCell = new CellBase(), newCell = new CellBase();
            foreach (var item in AllCell)
            {
                if (item.PosX == (int)MyMove.CurPos.x - 1 && item.PosY == 8 - (int)MyMove.CurPos.y)
                {
                    curCell = item;
                }

                if (item.PosX == (int)MyMove.NewPos.x - 1 && item.PosY == 8 - (int)MyMove.NewPos.y)
                {
                    newCell = item;
                }
            }

            if (curCell.CurrentType != null)
            {
                newCell.SetView(curCell.CurrentType);
                _BoardState [(int)curCell.CurrentType.Position.x + 1, (int)curCell.CurrentType.Position.y + 1] = 0;
                curCell.ClearView();
                _BoardState [(int)newCell.CurrentType.Position.x + 1, (int)newCell.CurrentType.Position.y + 1] = (int)newCell.CurrentType.Type * 10 + 1;
            }
        }
    }
Exemple #10
0
 private void ProcessTestDocument(string document, Action <string, TestCounts> writer)
 {
     try
     {
         Tree <Cell> result    = service.Compose(new StoryTestString(document));
         var         parse     = result != null ? (Parse)result.Value : null;
         var         storyTest = new StoryTest(parse, (tables, counts) => WriteResults(tables, counts, writer));
         reporter.WriteLine(parse.Leader);
         if (suiteSetupIdentifier.IsStartOf(parse.Leader) || IMaybeProcessingSuiteSetup)
         {
             storyTest.ExecuteOnConfiguration(service.Configuration);
         }
         else
         {
             storyTest.Execute(service.Configuration);
         }
     }
     catch (Exception e)
     {
         var testStatus = new TestStatus();
         var parse      = new CellBase(parseError, "div");
         parse.SetAttribute(CellAttribute.Body, parseError);
         testStatus.MarkException(parse, e);
         WriteResults(new CellTree().AddBranchValue(parse), testStatus.Counts, writer);
     }
 }
Exemple #11
0
        private void OnClick(CellBase cell, EventArgs e)
        {
            MouseEventArgs me    = (MouseEventArgs)e;
            double         price = Convert.ToDouble(((TextCell)m_Price).Value);

            int  colIndex = cell.Cell.Column.Index;
            char bs       = char.MinValue;

            if (colIndex == (int)ColGenre.Buy)
            {
                bs = 'B';
            }
            else if (colIndex == (int)ColGenre.Sell)
            {
                bs = 'S';
            }
            if (bs == char.MinValue)
            {
                return;
            }

            switch (me.Button)
            {
            case MouseButtons.Left:
                Center.Instance.Post(Observer.Log, $"Left {price} {bs}");
                break;

            case MouseButtons.Right:
                Center.Instance.Post(Observer.Log, $"Right {price} {bs}");
                break;
            }
        }
        protected override bool SaveWhenENodebNotExisted()
        {
            CellBase cellBase = _baseRepository.QueryCell(_cellInfo.ENodebId, _cellInfo.SectorId);

            if (cellBase == null)
            {
                Cell cell = new Cell();
                cell.Import(_cellInfo);
                _repository.Insert(cell);
                return(true);
            }
            if (_updateExisted)
            {
                Cell cell = _repository.GetAll().FirstOrDefault(x =>
                                                                x.ENodebId == _cellInfo.ENodebId && x.SectorId == _cellInfo.SectorId);
                if (cell == null)
                {
                    return(false);
                }
                cell.Import(_cellInfo);
                _repository.Update(cell);
                return(true);
            }
            return(false);
        }
Exemple #13
0
    private void GenerateHexagonGrid()
    {
        float offsetX = 0.38f;
        float offsetZ = 0.32f;

        for (int x = 0; x < width; x++)
        {
            for (int y = 0; y < height; y++)
            {
                float posX = x * offsetX;

                if (y % 2 == 1)
                {
                    posX += offsetX / 2;
                }

                GameObject _newCell = Instantiate(PrefabCell, new Vector3(posX, 0, y * offsetZ), Quaternion.identity);

                CellBase _cell = _newCell.GetComponent <CellBase>();
                CellNode _node = new CellNode();
                _node.GridX = x;
                _node.GridY = y;
                _cell.SetNode(_node);

                _newCell.transform.parent = ParentForCells;
            }
        }
    }
Exemple #14
0
        void createForest()
        {
            foreach (var id in getGrassCellByPercentage((int)forestPercentageInput.value))
            {
                List <int> pending = new List <int>();
                pending.Add(id);

                int current = 0;
                int total   = Random.Range(3, 8);
                while (current < total && pending.Count > 0)
                {
                    int randomIndex = Random.Range(0, pending.Count);
                    int currentCell = pending[randomIndex];
                    pending.RemoveAt(randomIndex);

                    cellTypes[currentCell] = CellType.Forest;

                    for (HexDirection d = HexDirection.NE; d <= HexDirection.NW; d++)
                    {
                        CellBase neighbor = grid.GetCellBase(currentCell).getNeigbour(d);
                        if (neighbor != null && !pending.Contains(neighbor.Id) && cellTypes[neighbor.Id] == CellType.Grass)
                        {
                            pending.Add(neighbor.Id);
                        }
                    }
                    current++;
                }
                pendingToVisit.clear();
            }
        }
Exemple #15
0
        public object this[RowGenre row, ColGenre col, int index = -1]
        {
            get
            {
                CellBase cell = null;
                switch (row)
                {
                case RowGenre.Functional:
                case RowGenre.Statistics:
                case RowGenre.MP:
                    cell = CellList[row].First()[col];
                    return(cell is TextCell ? ((TextCell)cell).Value : 0);

                case RowGenre.BP:
                case RowGenre.AP:
                    if (index == -1)
                    {
                        return(null);
                    }
                    cell = CellList[row][index][col];
                    return(cell is TextCell ? ((TextCell)cell).Value : 0);

                default:
                case RowGenre.Header:
                    return(0);
                }
            }
            set
            {
                switch (row)
                {
                case RowGenre.Header:
                case RowGenre.Functional:
                case RowGenre.Statistics:
                case RowGenre.MP:
                default:
                    CellList[row].First().SetValue(col, value);
                    break;

                case RowGenre.BP:
                case RowGenre.AP:
                    if (index == -1)
                    {
                        return;
                    }
                    else if (index == 999)
                    {
                        for (int i = 0; i < TickNumber; i++)
                        {
                            CellList[row][i].SetValue(col, value);
                        }
                    }
                    else
                    {
                        CellList[row][index].SetValue(col, value);
                    }
                    break;
                }
            }
        }
Exemple #16
0
    /// <summary>
    /// no doubt this is not a best approach
    /// </summary>
    private void RegisterNeighboring()
    {
        for (int i = 0; i < 6; i++)
        {
            Collider[] collResults = new Collider[7];
            if (Physics.OverlapSphereNonAlloc((transform.position - transform.up * 0.2f), 0.25f, collResults) > 0)
            {
                List <CellBase> objFound = new List <CellBase>();
                foreach (var item in collResults)
                {
                    if (item != null && item != ObjectCollider && item.transform.parent != null)
                    {
                        CellBase _cellBase = item.transform.parent.GetComponent <CellBase>();
                        if (_cellBase != null)
                        {
                            objFound.Add(_cellBase);
                        }
                    }
                }

                NearestCells = new CellBase[objFound.Count];
                objFound.CopyTo(NearestCells);
            }
        }
    }
 private void ProcessTestDocument(string document, StoryTestWriter writer)
 {
     try {
         var storyTest = new StoryTest(service, writer)
                         .WithInput(document)
                         .OnAbandonSuite(() => { suiteIsAbandoned = true; });
         reporter.WriteLine(storyTest.Leader);
         if (suiteSetupIdentifier.IsStartOf(storyTest.Leader) || IMaybeProcessingSuiteSetup)
         {
             storyTest.Execute();
         }
         else
         {
             storyTest.Execute(new Service.Service(service));
         }
     }
     catch (Exception e) {
         var testStatus = new TestStatus();
         var parse      = new CellBase(parseError, "div");
         parse.SetAttribute(CellAttribute.Body, parseError);
         testStatus.MarkException(parse, e);
         writer.WriteTable(new CellTree(parse));
         writer.WriteTest(new CellTree().AddBranchValue(parse), testStatus.Counts);
     }
 }
Exemple #18
0
        public void TestCellBaseRepository_QueryCell()
        {
            CellBase cell = baseRepository.QueryCell(1, 0);

            Assert.IsNotNull(cell);
            Assert.AreEqual(cell.SectorId, 0);
        }
Exemple #19
0
        [Test] public void FoldedWithExtraTextIsFormatted()
        {
            var cell = new CellBase(string.Empty);

            cell.SetAttribute(CellAttribute.Body, string.Empty);
            cell.SetAttribute(CellAttribute.Folded, "more");
            Assert.AreEqual(FormatFolded("more"), TreeCellWriter.Body(cell));
        }
 public void SetStartPoint(CellBase point)
 {
     if (StartPoint != null && CellBase.CompareStates(StartPoint.GetState(), CellBase.State.StartPoint))
     {
         StartPoint.SetFree();
     }
     StartPoint = point;
 }
Exemple #21
0
 public virtual bool CanAdd(CellBase cell)
 {
     if (selected.Contains(cell))
     {
         return(false);
     }
     return(true);
 }
Exemple #22
0
        [Test] public void FoldedWithoutExtraTextFormatsBody()
        {
            var cell = new CellBase(string.Empty);

            cell.SetAttribute(CellAttribute.Body, "stuff");
            cell.SetAttribute(CellAttribute.Folded, string.Empty);
            Assert.AreEqual(FormatFolded("stuff"), TreeCellWriter.Body(cell));
        }
Exemple #23
0
 public override void MoveToAnotherCell(CellBase cellBase)
 {
     base.MoveToAnotherCell(cellBase);
     if (IsFirstTurn)
     {
         IsFirstTurn = false;
     }
 }
 public void SetDestinationPoint(CellBase point)
 {
     if (DestinationPoint != null && CellBase.CompareStates(DestinationPoint.GetState(), CellBase.State.DestinationPoint))
     {
         DestinationPoint.SetFree();
     }
     DestinationPoint = point;
 }
Exemple #25
0
 /// <summary>
 /// Очищает всю старую информацию
 /// </summary>
 private void Clear()
 {
     _firstFigure     = null;
     _secondFigure    = null;
     _cellFightingFor = null;
     _winner          = null;
     Loser            = null;
 }
Exemple #26
0
        void UpdateCellVisible(Section section, CellBase cell)
        {
            var secIndex = Element.Model.GetSectionIndex(section);
            var rowIndex = section.IndexOf(cell);

            Control.BeginUpdates();
            Control.ReloadRows(GetPaths(secIndex, rowIndex, 1), UITableViewRowAnimation.Automatic);
            Control.EndUpdates();
        }
Exemple #27
0
        static void AddBranch(TreeList <CellBase> source, string body)
        {
            var branchNode = new CellBase("text");

            branchNode.SetAttribute(CellAttribute.Body, body);
            branchNode.SetAttribute(CellAttribute.EndTag, "</leaftag>");
            branchNode.SetAttribute(CellAttribute.StartTag, "<leaftag>");
            source.AddBranchValue(branchNode);
        }
Exemple #28
0
        private void _InitSL()
        {
            m_SL = null;
            View v = null;

            switch (Genre)
            {
            case RowGenre.Functional:
            case RowGenre.Statistics:
            case RowGenre.BP:
                m_SL = new TextCell()
                {
                    HasBorder = false, Border = Border
                };
                v = EmptyView;
                break;

            case RowGenre.Header:
                m_SL = new CHeaderCell()
                {
                    Caption = "賣量"
                };
                v = HeaderView;
                break;

            case RowGenre.MP:
                m_SL = new TextCell()
                {
                    HasBorder = true, Border = Border
                };
                v = MPView;
                break;

            case RowGenre.AP:
                m_SL = new TextCell()
                {
                    HasBorder = true, Border = Border
                };
                v = APView;
                break;
            }

            m_SL.SetBackColor(v.SL_BackColor);
            m_SL.SetFontColor(v.SL_ForeColor);
            if (m_SL is TextCell)
            {
                var cell = (TextCell)m_SL;
                cell.CellType = TextCell.TextType.Int;
                cell.Format   = VolumeFormat;
                cell.FontName = CellBase.FontName.Verdana;
            }
            if (Genre == RowGenre.AP || Genre == RowGenre.BP || Genre == RowGenre.MP)
            {
                m_SL.OnMouseEnter += OnMouseEnter;
            }
        }
Exemple #29
0
        static TreeList <CellBase> MakeRootNode()
        {
            var sourceNode = new CellBase("text");

            sourceNode.SetAttribute(CellAttribute.EndTag, "</tag>");
            sourceNode.SetAttribute(CellAttribute.Leader, "leader");
            sourceNode.SetAttribute(CellAttribute.StartTag, "<tag stuff>");
            sourceNode.SetAttribute(CellAttribute.Trailer, "trailer");
            return(new TreeList <CellBase>(sourceNode));
        }
Exemple #30
0
 private void CacheCells()
 {
     foreach (Transform cellChild in _cellsContainer)
     {
         CellBase cell = cellChild.gameObject.GetComponent <CellBase>();
         cell.Coordinate = Utils.Utils.GetCoordinate(cellChild.position);
         _cellsController.AddCell(cell);
         cell.LevelHandler = this;
     }
 }
Exemple #31
0
        public void AddNewItemsCommandTests()
        {
            // arrange
            var vm = new CellBase(null, null);

            var view = new SpreadsheetView();
            Mock.Arrange(() => view.KeyNavigationByDemand(Key.Insert, true)).MustBeCalled();
            Mock.Arrange(() => vm.Owner).Returns(view);

            // act
            vm.AddNewItemsCommand.Execute(null);

            // assert
            Mock.Assert(view);
        }
Exemple #32
0
        public void EditRecordCommandTests()
        {
            // arrange
            var vm = new CellBase(null, null);

            var view = new SpreadsheetView();
            Mock.Arrange(() => view.KeyNavigationByDemand(Key.Enter, false)).MustBeCalled();
            Mock.Arrange(() => vm.Owner).Returns(view);

            // act
            vm.EditRecordCommand.Execute(null);

            // assert
            Mock.Assert(view);
        }
Exemple #33
0
        public void RemoveSelectedItemsCommandAllowedTests()
        {
            // arrange
            var vm = new CellBase(null, null);

            var view = new SpreadsheetView();
            Mock.Arrange(() => view.KeyNavigationByDemand(Key.Delete, false)).MustBeCalled();
            Mock.Arrange(() => vm.ContainedValue).Returns("abc");
            Mock.Arrange(() => vm.Owner).Returns(view);

            // act
            vm.RemoveSelectedItemsCommand.Execute(null);

            // assert
            Mock.Assert(view);
        }
Exemple #34
0
        public void SelectParentCellDisallowedTests()
        {
            // arrange
            var vm = new CellBase(null, null);

            var view = new SpreadsheetView();
            Mock.Arrange(() => view.KeyNavigationByDemand(Key.P, false)).OccursNever();
            Mock.Arrange(() => vm.Owner).Returns(view);

            // act
            vm.SelectParentCell.Execute(null);

            // assert
            Mock.Assert(view);
        }
Exemple #35
0
        public void SelectParentCellAllowedTests()
        {
            // arrange
            var vm = new CellBase(null, null);

            var view = Mock.Create<SpreadsheetView>(Constructor.Mocked);
            Mock.Arrange(() => view.KeyNavigationByDemand(Key.P, false)).MustBeCalled();
            Mock.Arrange(() => vm.Owner).Returns(view);

            // act
            vm.SelectParentCell.Execute(null);

            // assert
            Mock.Assert(view);
        }