Example #1
0
        public static Color GetColorOfMapElement(MapElement element)
        {
            Color colorResult = Color.White;

            if (element.ElementState == MapElementState.Free)
            {
                float levelColor = (1f - (float)(element.Level-1)/10f);

                colorResult = Color.White;
                Color colorWithLight = new Color((levelColor*AmbientLight * element.Light * colorResult.ToVector3()));
                colorWithLight = new Color(colorWithLight.R, colorWithLight.G, colorWithLight.B, colorResult.A);
                colorResult = colorWithLight;
            }
            else if (element.ElementState == MapElementState.MiningScheduled)
                colorResult = Color.Orange;
            else if (element.ElementState == MapElementState.ChobbingScheduled)
                colorResult = Color.Orange;
            else if (element.ElementState == MapElementState.WheatFieldScheduled)
                colorResult = Color.White;
            else if (element.ElementState == MapElementState.CannabisFieldScheduled)
                colorResult = Color.Green;

            //if (element.Level == 2)
            //    colorResult = Color.Yellow;

            if (element.Unconstructed == true)
            {
                colorResult = new Color(colorResult.R, colorResult.G, colorResult.B, 0.5f);
            }

            return colorResult;
        }
Example #2
0
        public static double GetProcessingTimeForMapElement(MapElement element)
        {
            if (element.ElementType == MapElementType.Grass)
                return 0.1;
            else if (element.ElementType == MapElementType.Rock)
                return 0.1;

            throw new Exception("Crap");
        }
Example #3
0
        public override void PlaceOnMap()
        {
            base.PlaceOnMap();

            _mapElement = new StoneWallQube(Position);
            _mapElement.ElementEffect = MapElementEffect.Nonmoveable;
            _mapElement.Unconstructed = true;

            WorldMap.Instance.AddMapElement(_mapElement);
        }
Example #4
0
        public static double DamageMapElement(MapElement element, Dwarf d, double dtd)
        {
            if (element.ElementType == MapElementType.Grass)
                return 0.02 * d.Stats.GetMining() * DwarfRules.GetToolModifier(d) * dtd;
            else if (element.ElementType == MapElementType.Rock)
                return 0.02 * d.Stats.GetMining() * DwarfRules.GetToolModifier(d) * dtd;
            else if (element.ElementType == MapElementType.IronOreCube)
                return 0.02 * d.Stats.GetMining() * DwarfRules.GetToolModifier(d) * dtd;

            throw new Exception("Crap");
        }
Example #5
0
        //public static bool IsCursorOpperationValidOnCube(CursorMode mode, Cube cube)
        //{
        //    if (cube == null)
        //        return false;
        //    if (mode == CursorMode.None)
        //        return true;
        //    if (mode == CursorMode.Mine &&
        //        (cube.ElementType == MapElementType.Rock)
        //        )
        //    {
        //        return true;
        //    }
        //    return false;
        //}
        public static bool IsCursorOpperationValidOnMapElement(CursorMode mode, MapElement element)
        {
            if (element == null)
                return false;

            if (mode == CursorMode.Mine &&
                (
                element.ElementType == MapElementType.Rock ||
                element.ElementType == MapElementType.IronOreCube
                ) &&
                element.Position.Z == WorldMap.Instance.GetSurfacePoint()
                )
                return true;

            else if ((mode == CursorMode.CropArea || mode == CursorMode.Pasture || mode == CursorMode.IndoorCropArea || mode == CursorMode.Wall) &&
                element.Position.Z == WorldMap.Instance.GetSurfacePoint() + 1 &&
                element.ElementState == MapElementState.Free)
            {
                bool valid = true;

                // Check if there is a rock in the way
                if (WorldMap.Instance.GetMapElement(element.Position.X, element.Position.Y, element.Position.Z - 1) != null)
                    valid = false;

                // Check if outside
                if (mode == CursorMode.IndoorCropArea)
                {
                    if (WorldMap.Instance.IsOutside(element.Position.X, element.Position.Y) == true)
                        valid = false;
                }
                if (mode == CursorMode.CropArea)
                {
                    if (WorldMap.Instance.IsOutside(element.Position.X, element.Position.Y) == false)
                        valid = false;
                }

                return valid;
            }

            else if (mode == CursorMode.PlacingBuilding && element.ElementEffect == MapElementEffect.Moveable)
                return true;

            else if (mode == CursorMode.PlacingWorldObject && element.ElementEffect == MapElementEffect.Moveable)
            {
                return true;
            }
            //if (mode == CursorMode.Chopping && element.ElementType == MapElementType.Tree)
            //{
            //    return true;
            //}
            return false;
        }
Example #6
0
        private void RequestPathfinding(MapElement element, Dwarf dwarf)
        {
            if (WorldMap.Instance.GetMapElement(element.Position.X + 1, element.Position.Y, element.Position.Z) == null ||
                WorldMap.Instance.GetMapElement(element.Position.X + 1, element.Position.Y, element.Position.Z).ElementEffect != MapElementEffect.Solid)
            {
                AsyncPathfinding.RequestPathfinding(dwarf,
                    new Point((int)dwarf.Position.X, (int)dwarf.Position.Y),
                    new Point(element.Position.X + 1, element.Position.Y), null);

                _numberOfPathRequests++;
            }
            if (WorldMap.Instance.GetMapElement(element.Position.X - 1, element.Position.Y, element.Position.Z) == null ||
                WorldMap.Instance.GetMapElement(element.Position.X - 1, element.Position.Y, element.Position.Z).ElementEffect != MapElementEffect.Solid)
            {
                 AsyncPathfinding.RequestPathfinding(dwarf,
                    new Point((int)dwarf.Position.X, (int)dwarf.Position.Y),
                    new Point(element.Position.X - 1, element.Position.Y), null);

                _numberOfPathRequests++;
            }
            if (WorldMap.Instance.GetMapElement(element.Position.X, element.Position.Y + 1, element.Position.Z) == null ||
                WorldMap.Instance.GetMapElement(element.Position.X, element.Position.Y + 1, element.Position.Z).ElementEffect != MapElementEffect.Solid)
            {
                 AsyncPathfinding.RequestPathfinding(dwarf,
                    new Point((int)dwarf.Position.X, (int)dwarf.Position.Y),
                    new Point(element.Position.X, element.Position.Y + 1), null);

                 _numberOfPathRequests++;
            }
            if (WorldMap.Instance.GetMapElement(element.Position.X, element.Position.Y - 1, element.Position.Z) == null ||
                WorldMap.Instance.GetMapElement(element.Position.X, element.Position.Y - 1, element.Position.Z).ElementEffect != MapElementEffect.Solid)
            {
                 AsyncPathfinding.RequestPathfinding(dwarf,
                    new Point((int)dwarf.Position.X, (int)dwarf.Position.Y),
                    new Point(element.Position.X, element.Position.Y - 1), null);

                 _numberOfPathRequests++;
            }
        }
Example #7
0
        public void AddMapElement(MapElement element)
        {
            if (element.Position.Z == _surfacePoint && element.ElementEffect == MapElementEffect.Solid)
                _astar.SetTile(element.Position.X, element.Position.Y, new TileInfo() { tileType = TileInfo.TileType.Wall });

            _mapElements[element.Position.X, element.Position.Y, element.Position.Z] = element;
        }
Example #8
0
 public void SetDimentions(Vector3Int dim)
 {
     Dimentions = dim;
     MapElements = new MapElement[dim.X, dim.Y, dim.Z];
 }
Example #9
0
 public void AddMapElement(int x, int y, int z, MapElement element)
 {
     MapElements[x, y, z] = element;
     element.Level = Level;
 }
Example #10
0
 public void SetActionMapElement(MapElement element)
 {
     _actionMapElement = element;
 }
Example #11
0
 public MineMapElementTask(MapElement mapElement)
 {
     MapElement = mapElement;
     TaskType = Tasks.TaskType.Mining;
 }