Example #1
0
        public async Task InitRecruitmentQueue(string userId)
        {
            _unitQueue = await _viewService.GetUnitQueueById(userId);

            _unitQueue.Queue.Sort((x, y) => DateTime.Compare(x.FinishTime, y.FinishTime));

            UnitQueueData previousItem = null;

            foreach (var item in _unitQueue.Queue)
            {
                TimeSpan tmp;

                if (previousItem != null)
                {
                    tmp = item.FinishTime - previousItem.FinishTime;
                }

                else
                {
                    tmp = item.FinishTime - DateTime.Now;
                }

                item.RecruitTime = new TimeSpan(tmp.Hours, tmp.Minutes, tmp.Seconds);
                previousItem     = item;
            }

            NotifyStateChanged();
        }
Example #2
0
 public override void Release()
 {
     base.Release();
     // Que整理
     {
         _unitQue.ListRelease();
         _unitQue = null;
     }
     // ViewPool整理
     {
         _unitViewPool = null;
     }
 }
    public void PathfinderColapso()
    {
        if (_targetPos == null || _unitiesToTest == null || _unitiesToTest.Count == 0)
        {
            Debug.LogError("Selecione um teste!");
            return;
        }

        List <ColapseNode> checkedList = new List <ColapseNode>();
        UnitQueue          unitQueue   = new UnitQueue(_unitiesToTest, _targetPos);
        ColapseNode        nodeAtual   = unitQueue.next();

        while (nodeAtual != null)
        {
            //foreach (var neighbour in neighbourAux) {
            //    Vector2Int posAux = nodeAtual.pos + neighbour;
            //    if (posAux == _targetPos) {
            //        print("Encontrado!");
            //        List<Vector2Int> caminhoFinal = new List<Vector2Int>();
            //        caminhoFinal.Add(posAux);
            //        caminhoFinal.Add(nodeAtual.pos);
            //        auxNode = nodeAtual.parent;
            //        while (auxNode != null) {
            //            caminhoFinal.Add(auxNode.pos);
            //            auxNode = auxNode.parent;
            //        }
            //        caminhoFinal.Reverse();
            //        foreach (var elem in caminhoFinal) {
            //            print(elem);
            //            //Instantiate(DebugPathMark, new Vector3(elem.x, elem.y, -2f), Quaternion.identity, transform);
            //        }

            //        for (int i = 1; i < caminhoFinal.Count; i++) {
            //            Debug.DrawLine(
            //                new Vector3(caminhoFinal[i - 1].x, caminhoFinal[i - 1].y, 0f),
            //                new Vector3(caminhoFinal[i].x, caminhoFinal[i].y, 0f),
            //                Color.blue,
            //                30);
            //        }
            //        return;
            //    }

            //    TileType tileType = TileMapController.Instance.ValidTile(posAux);
            //    if (tileType == TileType.Pathable) {
            //        auxNode = new AStarNode(posAux, nodeAtual, _targetPos);

            //        var auxAuxNode1 = toCheckList.Find(x => {
            //            if (x.pos == auxNode.pos) {
            //                return x.totalDistance < auxNode.totalDistance;
            //            }
            //            return false;
            //        });
            //        var auxAuxNode2 = checkedList.Find(x => {
            //            if (x.pos == auxNode.pos) {
            //                return x.totalDistance < auxNode.totalDistance;
            //            }
            //            return false;
            //        });
            //        if (auxAuxNode1 == null && auxAuxNode2 == null) {
            //            unitQueue.add(auxNode);
            //            Instantiate(DebugMark, new Vector3(auxNode.pos.x, auxNode.pos.y, -1f), Quaternion.identity, transform);
            //        }
            //    } else if (tileType == TileType.Blocked) {
            //        // tratamento da pedra
            //        /**
            //         * Expandir e encontrar todos os bloqueios adjecentes, salvar posicao, largura e altura da pedra
            //         */
            //        FindObstacleByTile(posAux);
            //    }
            //}

            //checkedList.Add(nodeAtual);
            nodeAtual = unitQueue.next();
        }

        // Botar uma lista pra cada unidade e só botar a melhor opcao de cada uma na fila pro proximo ciclo?
        // Isso + o colapso pode fazer bem menos choques de checks
    }
Example #4
0
 public SimpleLifeCycleLogic(IEntityFieldLogic_ForLifeCycle entityLogic, LifeCycleView lifeCycleView, ELifeCycleKind lifeCycleKind, int randomSeed, float leftWall, float topWall, float rightWall, float bottomWall)
     : base(entityLogic, lifeCycleView, lifeCycleKind, randomSeed, leftWall, topWall, rightWall, bottomWall)
 {
     _unitQue = new UnitQueue();
     _unitQue.ListInit();
 }