axx0 / civ2-clone Goto Github PK
View Code? Open in Web Editor NEWAn open-source re-implementation of Civilization 2
License: GNU General Public License v3.0
An open-source re-implementation of Civilization 2
License: GNU General Public License v3.0
So we can either:
Apologies for noob way of posting the solution:
Game.ActionsCities.cs
` // Change shield production
city.ShieldsProgress += city.Production;
var maxUnitIndex = Game.Rules.UnitTypes.Length;
int cost;
// Units
if (city.ItemInProduction < maxUnitIndex)
{
var unitType = Game.Rules.UnitTypes[city.ItemInProduction];
cost = unitType.Cost * 10;
if (city.ShieldsProgress >= cost)
{
city.ShieldsProgress = 0;
Game.CreateUnit(unitType.Type, city.X, city.Y, false, true, false, false, city.Owner.Id, 0, 0, city.X, city.Y, CommodityType.Hides, OrderType.NoOrders, city, city.X, city.Y, 0, 0);
}
}
// Improvements
else
{
var improvementIndex = city.ItemInProduction - Game.Rules.UnitTypes.Length + 1;
var improvement = Game.Rules.Improvements[improvementIndex];
cost = improvement.Cost * 10;
if (city.ShieldsProgress >= cost)
{
city.ShieldsProgress = 0;
city.AddImprovement(improvement);
}
}
For my convenience I also made additional method of creating units in Game.cs:
public Unit CreateUnit(UnitType type, int x, int y, bool dead, bool firstMove, bool greyStarShield, bool veteran, int civId,
int movePointsLost, int hitPointsLost, int prevX, int prevY, CommodityType caravanCommodity, OrderType orders,
City homeCity, int goToX, int goToY, int linkOtherUnitsOnTop, int linkOtherUnitsUnder)
{
var validTile = CurrentMap.IsValidTileC2(x, y);
var civilization = AllCivilizations[civId];
Unit unit = new Unit
{
Id = civilization.Units.Count,
TypeDefinition = Rules.UnitTypes[(int)type],
Dead = dead || !validTile,
CurrentLocation = validTile ? CurrentMap.TileC2(x, y) : null,
Type = type,
X = x,
Y = y,
MovePointsLost = movePointsLost,
HitPointsLost = hitPointsLost,
FirstMove = firstMove,
GreyStarShield = greyStarShield,
Veteran = veteran,
Owner = civilization,
PrevXY = new int[] { prevX, prevY },
CaravanCommodity = caravanCommodity,
Order = orders,
HomeCity = homeCity,
GoToX = goToX,
GoToY = goToY,
LinkOtherUnitsOnTop = linkOtherUnitsOnTop,
LinkOtherUnitsUnder = linkOtherUnitsUnder
};
civilization.Units.Add(unit);
return unit;
}
We've hardcoded transparency colors but this can give bad results. These colors vary in scenarios.
For Civ2gold the last 3 colors in image palette define transparency.
For TOT the last bit in every 16-bit color seems to set transparency.
Anyway based on this we'll have to set alpha in our images.
Hi guys,
I am trying to run the project but it seems like is missing a lot of dependencies and imports in the code that is in master branch, primarily related to the EtoFormsUI, especially the Ruleset class.
Am I doing something wrong? After importing the missing files, a lot of other errors happened.
I tried reverting to one commit prior, yet the issue persisted. Going back two commits altered the error; the Ruleset class was no longer missing, but now the EtoFormsUI.LocalPlayer class does not implement all the interface members.
I can't even run the project. It's frustrating. I love this game.
Can someone shed some light on my path?
I appreciate that
Severity Code Description Project File Line Suppression State
Error CS0246 The type or namespace name 'MenuElement' could not be found (are you missing a using directive or an assembly reference?) EtoFormsUI C:\Users\feedc\Source\Repos\Civ2-clone\EtoFormsUI\EtoFormsUI\Players\Orders\ImprovementOrder.cs 20 Active
Error CS0246 The type or namespace name 'Ruleset' could not be found (are you missing a using directive or an assembly reference?) EtoFormsUI C:\Users\feedc\Source\Repos\Civ2-clone\EtoFormsUI\EtoFormsUI\Bitmaps\ImageLoader\TerrainLoader.cs 14 Active
Error CS0246 The type or namespace name 'Ruleset' could not be found (are you missing a using directive or an assembly reference?) EtoFormsUI C:\Users\feedc\Source\Repos\Civ2-clone\EtoFormsUI\EtoFormsUI\Bitmaps\ImageLoader\TerrainLoader.cs 27 Active
Error CS0246 The type or namespace name 'Ruleset' could not be found (are you missing a using directive or an assembly reference?) EtoFormsUI C:\Users\feedc\Source\Repos\Civ2-clone\EtoFormsUI\EtoFormsUI\Bitmaps\ImageLoader\UnitLoader.cs 15 Active
Error CS0246 The type or namespace name 'Ruleset' could not be found (are you missing a using directive or an assembly reference?) EtoFormsUI C:\Users\feedc\Source\Repos\Civ2-clone\EtoFormsUI\EtoFormsUI\Bitmaps\Images.ImportBitmaps.cs 16 Active
Error CS0246 The type or namespace name 'Ruleset' could not be found (are you missing a using directive or an assembly reference?) EtoFormsUI C:\Users\feedc\Source\Repos\Civ2-clone\EtoFormsUI\EtoFormsUI\Bitmaps\Images.ImportBitmaps.cs 45 Active
Error CS0246 The type or namespace name 'Ruleset' could not be found (are you missing a using directive or an assembly reference?) EtoFormsUI C:\Users\feedc\Source\Repos\Civ2-clone\EtoFormsUI\EtoFormsUI\Bitmaps\Images.ImportBitmaps.cs 147 Active
Error CS0246 The type or namespace name 'Ruleset' could not be found (are you missing a using directive or an assembly reference?) EtoFormsUI C:\Users\feedc\Source\Repos\Civ2-clone\EtoFormsUI\EtoFormsUI\Bitmaps\Images.ImportBitmaps.cs 172 Active
Error CS0246 The type or namespace name 'PlayerColour' could not be found (are you missing a using directive or an assembly reference?) EtoFormsUI C:\Users\feedc\Source\Repos\Civ2-clone\EtoFormsUI\EtoFormsUI\Bitmaps\MapImages.cs 15 Active
Error CS0246 The type or namespace name 'Ruleset' could not be found (are you missing a using directive or an assembly reference?) EtoFormsUI C:\Users\feedc\Source\Repos\Civ2-clone\EtoFormsUI\EtoFormsUI\Main.ShowPopupBox.cs 17 Active
Error CS0535 'LocalPlayer' does not implement interface member 'IPlayer.MapChanged(List)' EtoFormsUI C:\Users\feedc\Source\Repos\Civ2-clone\EtoFormsUI\EtoFormsUI\Players\LocalPlayer.cs 14 Active
Error CS0535 'LocalPlayer' does not implement interface member 'IPlayer.WaitingAtEndOfTurn()' EtoFormsUI C:\Users\feedc\Source\Repos\Civ2-clone\EtoFormsUI\EtoFormsUI\Players\LocalPlayer.cs 14 Active
Error CS0535 'LocalPlayer' does not implement interface member 'IPlayer.Civilization' EtoFormsUI C:\Users\feedc\Source\Repos\Civ2-clone\EtoFormsUI\EtoFormsUI\Players\LocalPlayer.cs 14 Active
Error CS0535 'LocalPlayer' does not implement interface member 'IPlayer.Ui' EtoFormsUI C:\Users\feedc\Source\Repos\Civ2-clone\EtoFormsUI\EtoFormsUI\Players\LocalPlayer.cs 14 Active
Error CS0246 The type or namespace name 'Ruleset' could not be found (are you missing a using directive or an assembly reference?) EtoFormsUI C:\Users\feedc\Source\Repos\Civ2-clone\EtoFormsUI\EtoFormsUI\Bitmaps\ImageLoader\CityLoader.cs 13 Active
The game crashes when an attack occurs as no animation frames have been provided.
We need to port the Attack animation to the new structure. (I guess it will be a sequence of animation elements similar to move I tried to make the code in the area flexible for possible future extensions)
TOT has an additional GameType parameter in sav file, which can either be:
From what I've tested sofar - if you load e.g. midgard scenario, which is a fantasy game, it first starts looking for assets in local midgard folder. Missing assets are then searched in "Fantasy" folder. If those assets are also missing in Fantasy folder or if that folder is for whatever reason missing, it then additionally searches for assets in "Original" folder.
Stuff like this needs to be added when defining search paths in LoadFile/Scenario dialogs and also when starting a new TOT game.
I'll try to deal with this, just putting issue here is any discussion is needed.
The minimap isn't working, it doesn't highlight the selected area from the map control and clicking it does nothing
Hello. First of all, I post here since it seems that Github is the only active place of the Civ2 clone project. I'm sorry if the Issues section is not the right place to post feature requests.
One thing that Civ2 bugs me is it use nearest-neighbor interpolation scaling when zooming in/out. This cause two problems:
First, graphic looks pixelated when zooming in. Back in 1999, when played Civ2 with a CRT screen, this problem was inconspicuous since CRT screens have built-in anti-aliasing. But this problem becomes obvious when using a modern LCD screen.
Pixelated graphic when zooming in:
Second, a even more serious problem cause by nearest-neighbor interpolation is that, graphics distorted when doing non-integer scaling. And all unit graphic in UI of Civ2 are scaling non-integerly.
Here you can see the pikes and lances (which supposed to be straight) of the units are seriously distorted:
Using bilinear/bicubic interpolation scaling on zooming can fix the problem. So I request that, if possible, add an option to enable bilinear/bicubic interpolation scaling in the Civ2-clone project.
Thanks for reading my post!
Map seems to be redrawn every time a unit moves, even if it moves within the view
Raylib uses a font which doesn't look anything like the one from the original game and thus needs to be changed.
Civ2 uses 2 fonts: Times new roman + Arial
So we can either
Your thoughts please.
Line 377 of the RulesParser refers to ImprovementType.Pyramids as the first wonder index.
var firstWonderIndex = Rules.Improvements.First(i => i.Type == ImprovementType.Pyramids).Id;
this works for MPG but TOT has an additional improvement so in TOT this is going to the (Capitalization) instead which will break city improvements.
Is there a way to do this more flexibly? Do we know at this stage of parsing the rules if we're looking at TOT or MPG?
Perhaps we could base this on the name? Could we assume that the first wonder is the first thing after Capitalisation? Or perhaps the first after a city improvement that has brackets around the name?
The Eto version had most unit actions working, it probably wouldn't be to complex to migrate that code over
Raylib-cs is in maintenance mode and probably won't be updated fro .net8 but .net6 goes out of support later this year.
Perhaps we should evaluate moving to https://github.com/MrScautHD/Raylib-CSharp
Hello, I am testing this on an M2 Max running Sonoma 14.1.1 and on building the project I get the following error on running the .NET Core Launch Mac build configuration (after clean/build) :
Civ2-clone/RaylibUI/bin/Debug/net6.0/RaylibUI.Mac' does not exist.
I don't see this RaylibUI.Mac file inside the net6.0 folder. I looked at upgrading to 5.0.0 of Raylib-cs, but there were quite a few errors with that change.
We need to update the look of dialogs when loading a .sav or scenarios which have custom dialog and icon pictures.
Currently ImageUtils.SetLook(main.ActiveInterface);
is only set at beginning of game in MainMenu.cs and left as-is.
For example, the wallpaper for TOT's status panel should be different for what's currently implemented (the icons.gif in TOT root directory is from MGE, the game should look for icon file in the local folder or one of the "fallback" folders (Original, Fantasy, SciFi)).
I've recently added a structure to a Tile that records what a civ can see in terms of improvements vs what is actually there, is this information stored in the sav file? We should probably load it, I'm going to rework the map rendering so each civ's map show what they know rather than the actual game state
Maybe put some description and start creating issues to people help?
Hi!
Just found this:) It would be helpful if just a bit more information could be added in the README on how to get started.
Thanks!
Stlye-wise it looks like a different game, but except for some new features the base game is the same as classic Civ 2.
The default menu layout is for MPG the TOT interface needs to adjust this to reflect the different layout of the TOT menu.txt
Support for drawing with different zoom levels needs to be ported over from Eto where I think it was working well.
Population, gold, info etc. need to be added to status panel. Offsets of what's currently drawn also needs to be updated.
I'll try to deal with this.
(for .txt files like Game/game, Labels/labels, etc.)
See here:
Civ2-clone/Engine/src/Utils.cs
Lines 27 to 62 in 589361d
Civ 2 is the best version of the game.
Let's make a website!
Is there an android version planned?
This line chooses the next civ _activeCiv = AllCivilizations[_activeCiv.Id + 1];
If a civ is dead it crashes the game.
This appears to be missing and needs to be ported from Eto logic.
Currently the units have no shields, this should be interface dependent since they are different in civ2 and TOT. Perhaps some sort of GetUnitTexture method on the active interface
The menus look wrong, the styles for MPG and TOT should be corrected
Noticed this just before, have not investigated why I think there might be a mistake in the maths
@reubene should this line
Civ2-clone/Engine/src/FastRandom.cs
Line 52 in 4ec54ee
max+1
?I tried pointing the app at a copy of TOT it didn't go well, we probably should support loading the images from the TOT DLLs as well
The Raylib.LoadImageFromMemory
function for _imageCache
LoadPropertiesFromPic
function in RaylibUtils).
We probably don't need to define transparent colours in BitmapStorage and then do this:
Extraction of images and textures in CityLoader
, TerrainLoader
, etc. differs from the implementation mentioned in 1) with _imageCache. This needs to be cleaned up so that the bitmap & texture loading logic is consistent throughout the project.
I can try to deal with this.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.