Example #1
0
        /// <summary>
        /// Calculates the movement cost
        /// </summary>
        /// <param name="gs"></param>
        /// <param name="locationID"></param>
        /// <returns></returns>
        public double CalculateMoveCost(GameState gs, int locationID)
        {
            LocationModel lm          = gs.GetLM();
            int           current     = lm.GetCurentLocation().GetLocationID();
            var           buttonAreas = lm.GetButtonAreas();

            System.Windows.Point source;
            System.Windows.Point target;
            if (buttonAreas.TryGetValue(current, out source) && buttonAreas.TryGetValue(locationID, out target))
            {
                double xDistance = source.X - target.X;
                double yDistance = source.Y - target.Y;
                double distance  = Math.Sqrt(xDistance * xDistance + yDistance * yDistance);

                return(distance / 5);
            }

            return(0);
        }