コード例 #1
0
        public override void OnVoxelsDragged(List <VoxelHandle> voxels, InputManager.MouseButton button)
        {
            var v = Player.VoxSelector.VoxelUnderMouse;

            if (Faction.RoomBuilder.IsBuildDesignation(v))
            {
                var order = Faction.RoomBuilder.GetBuildDesignation(v);
                if (order == null || order.Order == null)
                {
                    return;
                }

                if (!order.Order.IsBuilt)
                {
                    order.Order.SetTint(GameSettings.Default.Colors.GetColor("Negative", Color.Red));
                }
                else
                {
                    order.ToBuild.SetTint(GameSettings.Default.Colors.GetColor("Negative", Color.Red));
                }
            }
            else if (Faction.RoomBuilder.IsInRoom(v))
            {
                Room existingRoom = Faction.RoomBuilder.GetMostLikelyRoom(v);
                if (existingRoom != null)
                {
                    existingRoom.SetTint(GameSettings.Default.Colors.GetColor("Negative", Color.Red));
                }
            }
        }
コード例 #2
0
        public void OnVoxelsDragged(List <VoxelHandle> refs, InputManager.MouseButton button)
        {
            if (Faction == null)
            {
                Faction = World.PlayerFaction;
            }

            if (displayObjects != null)
            {
                foreach (var thing in displayObjects)
                {
                    thing.Delete();
                }
            }

            foreach (BuildRoomOrder order in BuildDesignations)
            {
                order.SetTint(Color.White);
            }

            foreach (Room room in Faction.GetRooms())
            {
                room.SetTint(Color.White);
            }

            if (CurrentRoomData == null)
            {
                return;
            }

            if (button == InputManager.MouseButton.Left)
            {
                World.Tutorial("build " + CurrentRoomData.Name);
                if (CurrentRoomData.Verify(refs, Faction, World))
                {
                    List <Quantitiy <Resource.ResourceTags> > requirements =
                        CurrentRoomData.GetRequiredResources(refs.Count, Faction);

                    string tip = "Needs ";


                    if (requirements.Count == 0)
                    {
                        tip = "";
                    }
                    int i = 0;
                    foreach (var requirement in requirements)
                    {
                        i++;
                        tip += requirement.NumResources.ToString();
                        tip += " ";
                        tip += requirement.ResourceType;
                        tip += "\n";
                    }

                    World.ShowToolPopup("Release to build here.");

                    displayObjects = RoomLibrary.GenerateRoomComponentsTemplate(CurrentRoomData, refs,
                                                                                World.ComponentManager,
                                                                                World.ChunkManager.Content, World.ChunkManager.Graphics);

                    foreach (Body thing in displayObjects)
                    {
                        thing.SetFlagRecursive(GameComponent.Flag.Active, false);
                        SetDisplayColor(thing, Color.Green);
                    }
                }
            }
            else
            {
                foreach (var v in refs.Where(v => v.IsValid && !v.IsEmpty))
                {
                    if (IsBuildDesignation(v))
                    {
                        var order = GetBuildDesignation(v);
                        if (order == null || order.Order == null)
                        {
                            // TODO(mklingen): Don't know how this could happen, but we got a crash here...
                            continue;
                        }
                        if (!order.Order.IsBuilt)
                        {
                            order.Order.SetTint(Color.Red);
                        }
                        else
                        {
                            order.ToBuild.SetTint(Color.Red);
                        }
                        break;
                    }
                    else if (IsInRoom(v))
                    {
                        Room existingRoom = GetMostLikelyRoom(v);
                        if (existingRoom == null)
                        {
                            continue;
                        }
                        existingRoom.SetTint(Color.Red);
                        break;
                    }
                }
            }
        }