Exemplo n.º 1
0
        /// <summary>
        /// Calc the points for moving, ignore the level vector, only 2d
        /// </summary>
        /// <param name="player"></param>
        /// <param name="moveType"></param>
        /// <param name="start"></param>
        /// <param name="end"></param>
        /// <returns></returns>
        public int Cost(Player player, string moveType, NVector start, NVector end)
        {
            List <PPoint> points = Path(player, moveType, start, end);
            PGrid         grid   = Get(player, moveType);
            int           price  = 0;

            foreach (PPoint point in points)
            {
                price += (int)grid.nodes[point.x, point.y].price;
            }

            return(price);
        }
Exemplo n.º 2
0
        private void CalcGrid(Player player, string moveType)
        {
            GameMapData      gmap  = GameMgmt.Get().data.map;
            GameMapDataLevel level = GameMgmt.Get().newMap[_id].dataLevel;

            float[,] costMap = new float[gmap.width, gmap.height];

            for (int x = 0; x < gmap.width; x++)
            {
                for (int y = 0; y < gmap.height; y++)
                {
                    costMap[x, y] = L.b.modifiers[C.MoveCost].CalcModi(level.Terrain(x, y).MoveCost(moveType), player,
                                                                       new NVector(x, y, _id));// level.Terrain(x, y).MoveCost(moveType, nation);
                    //Debug.LogWarning($"Cost for {X},{Y} for {nation}-{moveType} is {costMap[x,y]}");
                }
            }

            _grids[Key(player, moveType)] = new PGrid(costMap);
        }