Ejemplo n.º 1
0
        public static float GetTerritoryCellPercentAmount(Fraction owner, JEventBus eventBus = null)
        {
            int   territories = GetTerritoryCellsAmount(owner, eventBus);
            int   grounds     = TerrainApi.GetTerrainAmountsByType(1);
            float result      = (territories / (float)grounds) * 100f;

            return(result);
        }
Ejemplo n.º 2
0
        public void FindPathListener(FindPathEvent findPathEvent)
        {
            byte costOfMove = _pathFinder.GetCostOfMove(findPathEvent.End.X, findPathEvent.End.Y);

            bool entranceMode = TerrainApi.IsGround(findPathEvent.End) && StructureApi.IsEntrance(findPathEvent.End);

            if (entranceMode)
            {
                _pathFinder.ChangeCostOfMove(findPathEvent.End.X, findPathEvent.End.Y, 1);
            }

            var result = _pathFinder.FindPath(findPathEvent.Start, findPathEvent.End);

            if (result != null)
            {
                findPathEvent.CalculatedPath = result.Select(step => new Point(step.X, step.Y)).ToList();
                findPathEvent.CalculatedPath.Reverse();
            }

            if (entranceMode)
            {
                _pathFinder.ChangeCostOfMove(findPathEvent.End.X, findPathEvent.End.Y, costOfMove);
            }
        }