From 0b603355917ee91f22136737212ebbe1434efbd4 Mon Sep 17 00:00:00 2001 From: Tony Bark <35226681+tonytins@users.noreply.github.com> Date: Thu, 20 May 2021 00:58:17 -0400 Subject: [PATCH] Implemented basic buying functions - Renamed more scripts - Switched license to Artistic 2.0 --- .gitignore | 63 ++- LICENSE | 518 ++++++------------ README.md | 2 +- project.godot | 8 +- scenes/Map.tscn | 10 +- scenes/Start.tscn | 2 +- scenes/Zone.tscn | 1 - scenes/game.tscn | 12 +- scripts/Map.gd | 33 -- scripts/Zone.gd | 53 +- scripts/autoload/{SimData.gd => sim_data.gd} | 2 +- .../autoload/{SimEvents.gd => sim_events.gd} | 0 scripts/{CameraMove.gd => camera_move.gd} | 0 scripts/{Status.gd => city_status.gd} | 0 scripts/{Game.gd => gameplay.gd} | 0 scripts/map_generator.gd | 51 ++ scripts/{StartGame.gd => start_game.gd} | 3 + 17 files changed, 330 insertions(+), 428 deletions(-) delete mode 100644 scripts/Map.gd rename scripts/autoload/{SimData.gd => sim_data.gd} (94%) rename scripts/autoload/{SimEvents.gd => sim_events.gd} (100%) rename scripts/{CameraMove.gd => camera_move.gd} (100%) rename scripts/{Status.gd => city_status.gd} (100%) rename scripts/{Game.gd => gameplay.gd} (100%) create mode 100644 scripts/map_generator.gd rename scripts/{StartGame.gd => start_game.gd} (79%) diff --git a/.gitignore b/.gitignore index cbc6def..8c4c629 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,41 @@ -### Audio ### +# File created using '.gitignore Generator' for Visual Studio Code: https://bit.ly/vscode-gig -*.wav -*.ogg +# Created by https://www.toptal.com/developers/gitignore/api/windows,visualstudiocode,monodevelop,macos,linux,godot,executable,dotnetcore,backup,archives +# Edit at https://www.toptal.com/developers/gitignore?templates=windows,visualstudiocode,monodevelop,macos,linux,godot,executable,dotnetcore,backup,archives -# Created by https://www.gitignore.io/api/linux,godot,macos,backup,windows,dotnetcore,executable,monodevelop,visualstudiocode -# Edit at https://www.gitignore.io/?templates=linux,godot,macos,backup,windows,dotnetcore,executable,monodevelop,visualstudiocode +### Archives ### +# It's better to unpack these files and commit the raw source because +# git has its own built in compression methods. +*.7z +*.jar +*.rar +*.zip +*.gz +*.gzip +*.tgz +*.bzip +*.bzip2 +*.bz2 +*.xz +*.lzma +*.cab +*.xar + +# Packing-only formats +*.iso +*.tar + +# Package management formats +*.dmg +*.xpi +*.gem +*.egg +*.deb +*.rpm +*.msi +*.msm +*.msp +*.txz ### Backup ### *.bak @@ -15,14 +46,13 @@ ### DotnetCore ### # .NET Core build folders -/bin -/obj +bin/ +obj/ # Common node modules locations /node_modules /wwwroot/node_modules - ### Executable ### *.app *.bat @@ -30,7 +60,6 @@ *.com *.exe *.gadget -*.jar *.pif *.vb *.wsf @@ -42,8 +71,12 @@ export.cfg export_presets.cfg +# Imported translations (automatically generated from CSV files) +*.translation + # Mono-specific ignores .mono/ +data_*/ ### Linux ### *~ @@ -69,6 +102,7 @@ export_presets.cfg # Icon must end with two \r Icon + # Thumbnails ._* @@ -104,10 +138,12 @@ test-results/ !.vscode/tasks.json !.vscode/launch.json !.vscode/extensions.json +*.code-workspace ### VisualStudioCode Patch ### # Ignore all local history of files .history +.ionide ### Windows ### # Windows thumbnail cache files @@ -126,13 +162,12 @@ ehthumbs_vista.db $RECYCLE.BIN/ # Windows Installer files -*.cab -*.msi *.msix -*.msm -*.msp # Windows shortcuts *.lnk -# End of https://www.gitignore.io/api/linux,godot,macos,backup,windows,dotnetcore,executable,monodevelop,visualstudiocode \ No newline at end of file +# End of https://www.toptal.com/developers/gitignore/api/windows,visualstudiocode,monodevelop,macos,linux,godot,executable,dotnetcore,backup,archives + +# Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option) + diff --git a/LICENSE b/LICENSE index a612ad9..aa674ff 100644 --- a/LICENSE +++ b/LICENSE @@ -1,373 +1,201 @@ -Mozilla Public License Version 2.0 -================================== + The Artistic License 2.0 -1. Definitions --------------- + Copyright (c) 2000-2006, The Perl Foundation. -1.1. "Contributor" - means each individual or legal entity that creates, contributes to - the creation of, or owns Covered Software. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. -1.2. "Contributor Version" - means the combination of the Contributions of others (if any) used - by a Contributor and that particular Contributor's Contribution. +Preamble -1.3. "Contribution" - means Covered Software of a particular Contributor. +This license establishes the terms under which a given free software +Package may be copied, modified, distributed, and/or redistributed. +The intent is that the Copyright Holder maintains some artistic +control over the development of that Package while still keeping the +Package available as open source and free software. -1.4. "Covered Software" - means Source Code Form to which the initial Contributor has attached - the notice in Exhibit A, the Executable Form of such Source Code - Form, and Modifications of such Source Code Form, in each case - including portions thereof. +You are always permitted to make arrangements wholly outside of this +license directly with the Copyright Holder of a given Package. If the +terms of this license do not permit the full use that you propose to +make of the Package, you should contact the Copyright Holder and seek +a different licensing arrangement. -1.5. "Incompatible With Secondary Licenses" - means +Definitions - (a) that the initial Contributor has attached the notice described - in Exhibit B to the Covered Software; or + "Copyright Holder" means the individual(s) or organization(s) + named in the copyright notice for the entire Package. - (b) that the Covered Software was made available under the terms of - version 1.1 or earlier of the License, but not also under the - terms of a Secondary License. + "Contributor" means any party that has contributed code or other + material to the Package, in accordance with the Copyright Holder's + procedures. -1.6. "Executable Form" - means any form of the work other than Source Code Form. + "You" and "your" means any person who would like to copy, + distribute, or modify the Package. -1.7. "Larger Work" - means a work that combines Covered Software with other material, in - a separate file or files, that is not Covered Software. + "Package" means the collection of files distributed by the + Copyright Holder, and derivatives of that collection and/or of + those files. A given Package may consist of either the Standard + Version, or a Modified Version. -1.8. "License" - means this document. + "Distribute" means providing a copy of the Package or making it + accessible to anyone else, or in the case of a company or + organization, to others outside of your company or organization. -1.9. "Licensable" - means having the right to grant, to the maximum extent possible, - whether at the time of the initial grant or subsequently, any and - all of the rights conveyed by this License. + "Distributor Fee" means any fee that you charge for Distributing + this Package or providing support for this Package to another + party. It does not mean licensing fees. -1.10. "Modifications" - means any of the following: + "Standard Version" refers to the Package if it has not been + modified, or has been modified only in ways explicitly requested + by the Copyright Holder. - (a) any file in Source Code Form that results from an addition to, - deletion from, or modification of the contents of Covered - Software; or + "Modified Version" means the Package, if it has been changed, and + such changes were not explicitly requested by the Copyright + Holder. - (b) any new file in Source Code Form that contains any Covered - Software. + "Original License" means this Artistic License as Distributed with + the Standard Version of the Package, in its current version or as + it may be modified by The Perl Foundation in the future. -1.11. "Patent Claims" of a Contributor - means any patent claim(s), including without limitation, method, - process, and apparatus claims, in any patent Licensable by such - Contributor that would be infringed, but for the grant of the - License, by the making, using, selling, offering for sale, having - made, import, or transfer of either its Contributions or its - Contributor Version. + "Source" form means the source code, documentation source, and + configuration files for the Package. -1.12. "Secondary License" - means either the GNU General Public License, Version 2.0, the GNU - Lesser General Public License, Version 2.1, the GNU Affero General - Public License, Version 3.0, or any later versions of those - licenses. + "Compiled" form means the compiled bytecode, object code, binary, + or any other form resulting from mechanical transformation or + translation of the Source form. -1.13. "Source Code Form" - means the form of the work preferred for making modifications. -1.14. "You" (or "Your") - means an individual or a legal entity exercising rights under this - License. For legal entities, "You" includes any entity that - controls, is controlled by, or is under common control with You. For - purposes of this definition, "control" means (a) the power, direct - or indirect, to cause the direction or management of such entity, - whether by contract or otherwise, or (b) ownership of more than - fifty percent (50%) of the outstanding shares or beneficial - ownership of such entity. +Permission for Use and Modification Without Distribution -2. License Grants and Conditions --------------------------------- +(1) You are permitted to use the Standard Version and create and use +Modified Versions for any purpose without restriction, provided that +you do not Distribute the Modified Version. -2.1. Grants -Each Contributor hereby grants You a world-wide, royalty-free, -non-exclusive license: +Permissions for Redistribution of the Standard Version -(a) under intellectual property rights (other than patent or trademark) - Licensable by such Contributor to use, reproduce, make available, - modify, display, perform, distribute, and otherwise exploit its - Contributions, either on an unmodified basis, with Modifications, or - as part of a Larger Work; and +(2) You may Distribute verbatim copies of the Source form of the +Standard Version of this Package in any medium without restriction, +either gratis or for a Distributor Fee, provided that you duplicate +all of the original copyright notices and associated disclaimers. At +your discretion, such verbatim copies may or may not include a +Compiled form of the Package. -(b) under Patent Claims of such Contributor to make, use, sell, offer - for sale, have made, import, and otherwise transfer either its - Contributions or its Contributor Version. +(3) You may apply any bug fixes, portability changes, and other +modifications made available from the Copyright Holder. The resulting +Package will still be considered the Standard Version, and as such +will be subject to the Original License. -2.2. Effective Date -The licenses granted in Section 2.1 with respect to any Contribution -become effective for each Contribution on the date the Contributor first -distributes such Contribution. +Distribution of Modified Versions of the Package as Source -2.3. Limitations on Grant Scope +(4) You may Distribute your Modified Version as Source (either gratis +or for a Distributor Fee, and with or without a Compiled form of the +Modified Version) provided that you clearly document how it differs +from the Standard Version, including, but not limited to, documenting +any non-standard features, executables, or modules, and provided that +you do at least ONE of the following: -The licenses granted in this Section 2 are the only rights granted under -this License. No additional rights or licenses will be implied from the -distribution or licensing of Covered Software under this License. -Notwithstanding Section 2.1(b) above, no patent license is granted by a -Contributor: - -(a) for any code that a Contributor has removed from Covered Software; - or - -(b) for infringements caused by: (i) Your and any other third party's - modifications of Covered Software, or (ii) the combination of its - Contributions with other software (except as part of its Contributor - Version); or - -(c) under Patent Claims infringed by Covered Software in the absence of - its Contributions. - -This License does not grant any rights in the trademarks, service marks, -or logos of any Contributor (except as may be necessary to comply with -the notice requirements in Section 3.4). - -2.4. Subsequent Licenses - -No Contributor makes additional grants as a result of Your choice to -distribute the Covered Software under a subsequent version of this -License (see Section 10.2) or under the terms of a Secondary License (if -permitted under the terms of Section 3.3). - -2.5. Representation - -Each Contributor represents that the Contributor believes its -Contributions are its original creation(s) or it has sufficient rights -to grant the rights to its Contributions conveyed by this License. - -2.6. Fair Use - -This License is not intended to limit any rights You have under -applicable copyright doctrines of fair use, fair dealing, or other -equivalents. - -2.7. Conditions - -Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted -in Section 2.1. - -3. Responsibilities -------------------- - -3.1. Distribution of Source Form - -All distribution of Covered Software in Source Code Form, including any -Modifications that You create or to which You contribute, must be under -the terms of this License. You must inform recipients that the Source -Code Form of the Covered Software is governed by the terms of this -License, and how they can obtain a copy of this License. You may not -attempt to alter or restrict the recipients' rights in the Source Code -Form. - -3.2. Distribution of Executable Form - -If You distribute Covered Software in Executable Form then: - -(a) such Covered Software must also be made available in Source Code - Form, as described in Section 3.1, and You must inform recipients of - the Executable Form how they can obtain a copy of such Source Code - Form by reasonable means in a timely manner, at a charge no more - than the cost of distribution to the recipient; and - -(b) You may distribute such Executable Form under the terms of this - License, or sublicense it under different terms, provided that the - license for the Executable Form does not attempt to limit or alter - the recipients' rights in the Source Code Form under this License. - -3.3. Distribution of a Larger Work - -You may create and distribute a Larger Work under terms of Your choice, -provided that You also comply with the requirements of this License for -the Covered Software. If the Larger Work is a combination of Covered -Software with a work governed by one or more Secondary Licenses, and the -Covered Software is not Incompatible With Secondary Licenses, this -License permits You to additionally distribute such Covered Software -under the terms of such Secondary License(s), so that the recipient of -the Larger Work may, at their option, further distribute the Covered -Software under the terms of either this License or such Secondary -License(s). - -3.4. Notices - -You may not remove or alter the substance of any license notices -(including copyright notices, patent notices, disclaimers of warranty, -or limitations of liability) contained within the Source Code Form of -the Covered Software, except that You may alter any license notices to -the extent required to remedy known factual inaccuracies. - -3.5. Application of Additional Terms - -You may choose to offer, and to charge a fee for, warranty, support, -indemnity or liability obligations to one or more recipients of Covered -Software. However, You may do so only on Your own behalf, and not on -behalf of any Contributor. You must make it absolutely clear that any -such warranty, support, indemnity, or liability obligation is offered by -You alone, and You hereby agree to indemnify every Contributor for any -liability incurred by such Contributor as a result of warranty, support, -indemnity or liability terms You offer. You may include additional -disclaimers of warranty and limitations of liability specific to any -jurisdiction. - -4. Inability to Comply Due to Statute or Regulation ---------------------------------------------------- - -If it is impossible for You to comply with any of the terms of this -License with respect to some or all of the Covered Software due to -statute, judicial order, or regulation then You must: (a) comply with -the terms of this License to the maximum extent possible; and (b) -describe the limitations and the code they affect. Such description must -be placed in a text file included with all distributions of the Covered -Software under this License. Except to the extent prohibited by statute -or regulation, such description must be sufficiently detailed for a -recipient of ordinary skill to be able to understand it. - -5. Termination --------------- - -5.1. The rights granted under this License will terminate automatically -if You fail to comply with any of its terms. However, if You become -compliant, then the rights granted under this License from a particular -Contributor are reinstated (a) provisionally, unless and until such -Contributor explicitly and finally terminates Your grants, and (b) on an -ongoing basis, if such Contributor fails to notify You of the -non-compliance by some reasonable means prior to 60 days after You have -come back into compliance. Moreover, Your grants from a particular -Contributor are reinstated on an ongoing basis if such Contributor -notifies You of the non-compliance by some reasonable means, this is the -first time You have received notice of non-compliance with this License -from such Contributor, and You become compliant prior to 30 days after -Your receipt of the notice. - -5.2. If You initiate litigation against any entity by asserting a patent -infringement claim (excluding declaratory judgment actions, -counter-claims, and cross-claims) alleging that a Contributor Version -directly or indirectly infringes any patent, then the rights granted to -You by any and all Contributors for the Covered Software under Section -2.1 of this License shall terminate. - -5.3. In the event of termination under Sections 5.1 or 5.2 above, all -end user license agreements (excluding distributors and resellers) which -have been validly granted by You or Your distributors under this License -prior to termination shall survive termination. - -************************************************************************ -* * -* 6. Disclaimer of Warranty * -* ------------------------- * -* * -* Covered Software is provided under this License on an "as is" * -* basis, without warranty of any kind, either expressed, implied, or * -* statutory, including, without limitation, warranties that the * -* Covered Software is free of defects, merchantable, fit for a * -* particular purpose or non-infringing. The entire risk as to the * -* quality and performance of the Covered Software is with You. * -* Should any Covered Software prove defective in any respect, You * -* (not any Contributor) assume the cost of any necessary servicing, * -* repair, or correction. This disclaimer of warranty constitutes an * -* essential part of this License. No use of any Covered Software is * -* authorized under this License except under this disclaimer. * -* * -************************************************************************ - -************************************************************************ -* * -* 7. Limitation of Liability * -* -------------------------- * -* * -* Under no circumstances and under no legal theory, whether tort * -* (including negligence), contract, or otherwise, shall any * -* Contributor, or anyone who distributes Covered Software as * -* permitted above, be liable to You for any direct, indirect, * -* special, incidental, or consequential damages of any character * -* including, without limitation, damages for lost profits, loss of * -* goodwill, work stoppage, computer failure or malfunction, or any * -* and all other commercial damages or losses, even if such party * -* shall have been informed of the possibility of such damages. This * -* limitation of liability shall not apply to liability for death or * -* personal injury resulting from such party's negligence to the * -* extent applicable law prohibits such limitation. Some * -* jurisdictions do not allow the exclusion or limitation of * -* incidental or consequential damages, so this exclusion and * -* limitation may not apply to You. * -* * -************************************************************************ - -8. Litigation -------------- - -Any litigation relating to this License may be brought only in the -courts of a jurisdiction where the defendant maintains its principal -place of business and such litigation shall be governed by laws of that -jurisdiction, without reference to its conflict-of-law provisions. -Nothing in this Section shall prevent a party's ability to bring -cross-claims or counter-claims. - -9. Miscellaneous ----------------- - -This License represents the complete agreement concerning the subject -matter hereof. If any provision of this License is held to be -unenforceable, such provision shall be reformed only to the extent -necessary to make it enforceable. Any law or regulation which provides -that the language of a contract shall be construed against the drafter -shall not be used to construe this License against a Contributor. - -10. Versions of the License ---------------------------- - -10.1. New Versions - -Mozilla Foundation is the license steward. Except as provided in Section -10.3, no one other than the license steward has the right to modify or -publish new versions of this License. Each version will be given a -distinguishing version number. - -10.2. Effect of New Versions - -You may distribute the Covered Software under the terms of the version -of the License under which You originally received the Covered Software, -or under the terms of any subsequent version published by the license -steward. - -10.3. Modified Versions - -If you create software not governed by this License, and you want to -create a new license for such software, you may create and use a -modified version of this License if you rename the license and remove -any references to the name of the license steward (except to note that -such modified license differs from this License). - -10.4. Distributing Source Code Form that is Incompatible With Secondary -Licenses - -If You choose to distribute Source Code Form that is Incompatible With -Secondary Licenses under the terms of this version of the License, the -notice described in Exhibit B of this License must be attached. - -Exhibit A - Source Code Form License Notice -------------------------------------------- - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - -If it is not possible or desirable to put the notice in a particular -file, then You may include the notice in a location (such as a LICENSE -file in a relevant directory) where a recipient would be likely to look -for such a notice. - -You may add additional accurate notices of copyright ownership. - -Exhibit B - "Incompatible With Secondary Licenses" Notice ---------------------------------------------------------- - - This Source Code Form is "Incompatible With Secondary Licenses", as - defined by the Mozilla Public License, v. 2.0. + (a) make the Modified Version available to the Copyright Holder + of the Standard Version, under the Original License, so that the + Copyright Holder may include your modifications in the Standard + Version. + + (b) ensure that installation of your Modified Version does not + prevent the user installing or running the Standard Version. In + addition, the Modified Version must bear a name that is different + from the name of the Standard Version. + + (c) allow anyone who receives a copy of the Modified Version to + make the Source form of the Modified Version available to others + under + + (i) the Original License or + + (ii) a license that permits the licensee to freely copy, + modify and redistribute the Modified Version using the same + licensing terms that apply to the copy that the licensee + received, and requires that the Source form of the Modified + Version, and of any works derived from it, be made freely + available in that license fees are prohibited but Distributor + Fees are allowed. + + +Distribution of Compiled Forms of the Standard Version +or Modified Versions without the Source + +(5) You may Distribute Compiled forms of the Standard Version without +the Source, provided that you include complete instructions on how to +get the Source of the Standard Version. Such instructions must be +valid at the time of your distribution. If these instructions, at any +time while you are carrying out such distribution, become invalid, you +must provide new instructions on demand or cease further distribution. +If you provide valid instructions or cease distribution within thirty +days after you become aware that the instructions are invalid, then +you do not forfeit any of your rights under this license. + +(6) You may Distribute a Modified Version in Compiled form without +the Source, provided that you comply with Section 4 with respect to +the Source of the Modified Version. + + +Aggregating or Linking the Package + +(7) You may aggregate the Package (either the Standard Version or +Modified Version) with other packages and Distribute the resulting +aggregation provided that you do not charge a licensing fee for the +Package. Distributor Fees are permitted, and licensing fees for other +components in the aggregation are permitted. The terms of this license +apply to the use and Distribution of the Standard or Modified Versions +as included in the aggregation. + +(8) You are permitted to link Modified and Standard Versions with +other works, to embed the Package in a larger work of your own, or to +build stand-alone binary or bytecode versions of applications that +include the Package, and Distribute the result without restriction, +provided the result does not expose a direct interface to the Package. + + +Items That are Not Considered Part of a Modified Version + +(9) Works (including, but not limited to, modules and scripts) that +merely extend or make use of the Package, do not, by themselves, cause +the Package to be a Modified Version. In addition, such works are not +considered parts of the Package itself, and are not subject to the +terms of this license. + + +General Provisions + +(10) Any use, modification, and distribution of the Standard or +Modified Versions is governed by this Artistic License. By using, +modifying or distributing the Package, you accept this license. Do not +use, modify, or distribute the Package, if you do not accept this +license. + +(11) If your Modified Version has been derived from a Modified +Version made by someone other than you, you are nevertheless required +to ensure that your Modified Version complies with the requirements of +this license. + +(12) This license does not grant you the right to use any trademark, +service mark, tradename, or logo of the Copyright Holder. + +(13) This license includes the non-exclusive, worldwide, +free-of-charge patent license to make, have made, use, offer to sell, +sell, import and otherwise transfer the Package with respect to any +patent claims licensable by the Copyright Holder that are necessarily +infringed by the Package. If you institute patent litigation +(including a cross-claim or counterclaim) against any party alleging +that the Package constitutes direct or contributory patent +infringement, then this Artistic License to you shall terminate on the +date that such litigation is filed. + +(14) Disclaimer of Warranty: +THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS +IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED +WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR +NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL +LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/README.md b/README.md index aaf0545..5ea92e2 100644 --- a/README.md +++ b/README.md @@ -28,4 +28,4 @@ Note: this is subject to change in the future. ## License -This project is licensed under the MPL 2.0 License - see the [LICENSE](LICENSE) file for details +This project is licensed under the Artistic-2.0 License - see the [LICENSE](LICENSE) file for details diff --git a/project.godot b/project.godot index f74a315..11c331d 100644 --- a/project.godot +++ b/project.godot @@ -15,15 +15,15 @@ _global_script_class_icons={ [application] config/name="City Limits" -run/main_scene="res://scenes/Start.tscn" +run/main_scene="res://scenes/Game.tscn" config/icon="res://icon.png" config/windows_native_icon="res://icon.ico" [autoload] -CityData="*res://scripts/autoload/SimData.gd" -SimData="*res://scripts/autoload/SimData.gd" -SimEvents="*res://scripts/autoload/SimEvents.gd" +CityData="*res://scripts/autoload/sim_data.gd" +SimData="*res://scripts/autoload/sim_data.gd" +SimEvents="*res://scripts/autoload/sim_events.gd" [display] diff --git a/scenes/Map.tscn b/scenes/Map.tscn index 489cd15..30f0da6 100644 --- a/scenes/Map.tscn +++ b/scenes/Map.tscn @@ -1,22 +1,22 @@ [gd_scene load_steps=5 format=2] [ext_resource path="res://sprites/water.tres" type="TileSet" id=1] -[ext_resource path="res://scripts/Map.gd" type="Script" id=2] +[ext_resource path="res://scripts/map_generator.gd" type="Script" id=2] [ext_resource path="res://sprites/terrian.tres" type="TileSet" id=4] -[ext_resource path="res://scripts/CameraMove.gd" type="Script" id=5] +[ext_resource path="res://scripts/camera_move.gd" type="Script" id=5] -[node name="world" type="Node2D"] +[node name="World" type="Node2D"] script = ExtResource( 2 ) __meta__ = { "_edit_lock_": true } -[node name="water" type="TileMap" parent="."] +[node name="Water" type="TileMap" parent="."] tile_set = ExtResource( 1 ) cell_size = Vector2( 16, 16 ) format = 1 -[node name="terrian" type="TileMap" parent="."] +[node name="Terrian" type="TileMap" parent="."] tile_set = ExtResource( 4 ) cell_size = Vector2( 16, 16 ) format = 1 diff --git a/scenes/Start.tscn b/scenes/Start.tscn index 7d23b84..25ed1c8 100644 --- a/scenes/Start.tscn +++ b/scenes/Start.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=3 format=2] -[ext_resource path="res://scripts/StartGame.gd" type="Script" id=1] +[ext_resource path="res://scripts/start_game.gd" type="Script" id=1] [ext_resource path="res://scenes/Map.tscn" type="PackedScene" id=2] [node name="SartMenu" type="Node"] diff --git a/scenes/Zone.tscn b/scenes/Zone.tscn index dd6cea1..56fc41e 100644 --- a/scenes/Zone.tscn +++ b/scenes/Zone.tscn @@ -29,7 +29,6 @@ script = ExtResource( 1 ) [node name="Quarters" type="Timer" parent="."] wait_time = 10.0 -autostart = true [node name="Sprite" type="Sprite" parent="."] texture = ExtResource( 2 ) diff --git a/scenes/game.tscn b/scenes/game.tscn index 01593eb..c0e8ecf 100644 --- a/scenes/game.tscn +++ b/scenes/game.tscn @@ -2,8 +2,8 @@ [ext_resource path="res://scenes/Map.tscn" type="PackedScene" id=1] [ext_resource path="res://scenes/Advise.tscn" type="PackedScene" id=2] -[ext_resource path="res://scripts/Status.gd" type="Script" id=3] -[ext_resource path="res://scripts/Game.gd" type="Script" id=4] +[ext_resource path="res://scripts/city_status.gd" type="Script" id=3] +[ext_resource path="res://scripts/gameplay.gd" type="Script" id=4] [ext_resource path="res://sprites/police.png" type="Texture" id=5] [ext_resource path="res://sprites/firestation.png" type="Texture" id=6] @@ -42,7 +42,7 @@ __meta__ = { [node name="Status" type="VBoxContainer" parent="Controls/GUI/Status/Toolbar"] margin_right = 93.0 -margin_bottom = 66.0 +margin_bottom = 65.0 script = ExtResource( 3 ) __meta__ = { "_edit_use_anchors_": true @@ -86,11 +86,13 @@ text = "#" [node name="PoliceBtn" type="TextureButton" parent="Controls/GUI/Status/Toolbar"] margin_left = 97.0 margin_right = 145.0 -margin_bottom = 66.0 +margin_bottom = 65.0 texture_normal = ExtResource( 5 ) [node name="FireBtn" type="TextureButton" parent="Controls/GUI/Status/Toolbar"] margin_left = 149.0 margin_right = 197.0 -margin_bottom = 66.0 +margin_bottom = 65.0 texture_normal = ExtResource( 6 ) + +[connection signal="pressed" from="Controls/GUI/Status/Toolbar/PoliceBtn" to="Map" method="_on_PoliceBtn_pressed"] diff --git a/scripts/Map.gd b/scripts/Map.gd deleted file mode 100644 index 46d536a..0000000 --- a/scripts/Map.gd +++ /dev/null @@ -1,33 +0,0 @@ -extends Node2D - -var noise: OpenSimplexNoise -var map_size = Vector2(80, 60) -var terrian_cap = 0.3 - -func _ready(): - - randomize() - noise = OpenSimplexNoise.new() - noise.seed = randi() - noise.octaves = 1.5 - noise.period = 12 - - make_terrian_map() - make_water() - -func make_terrian_map(): - for x in map_size.x: - for y in map_size.y: - var a = noise.get_noise_2d(x, y) - if a < terrian_cap: - $terrian.set_cell(x, y, 0) - - $terrian.update_bitmask_region(Vector2(0.0, 0.0), Vector2(map_size.x, map_size.y)) - -func make_water(): - for x in map_size.x: - for y in map_size.y: - if $terrian.get_cell(x, y): - $water.set_cell(x, y, 0) - - $water.update_bitmask_region(Vector2(0.0, 0.0), Vector2(map_size.x, map_size.y)) diff --git a/scripts/Zone.gd b/scripts/Zone.gd index a13bc60..052ab03 100644 --- a/scripts/Zone.gd +++ b/scripts/Zone.gd @@ -1,5 +1,8 @@ extends KinematicBody2D +signal grabbed +signal power + export var cost: int = 10000 export var income: int export var expense: int @@ -9,38 +12,52 @@ onready var quarters = $Quarters onready var player = $AnimationPlayer var can_grab = false +var is_powered = false var grabbed_offset = Vector2() func _ready(): SimEvents.connect("pay_expense", self, "_get_expense") - - # Once placed in-world, it'll substract from your budget - if SimData.budget >= cost: - SimData.budget -= cost + connect("grabbed", self, "_grab_zone") + connect("power", self, "_power_zone") func _input(event): - if event is InputEventMouseButton: - can_grab = event.pressed + if event is InputEventMouseButton and can_grab: + # Disable grabbing + can_grab = false grabbed_offset = position - get_global_mouse_position() - -func _process(delta): - - player.play("Animante") - - if SimData.budget >= expense: - SimData.budget -= expense - if SimData.budget >= income: - SimData.budget += income - - if Input.is_mouse_button_pressed(BUTTON_LEFT) and can_grab: + # Substract from the player's budget + if SimData.budget >= cost: + SimData.budget -= cost + +func _process(delta): + if can_grab: position = get_global_mouse_position() + grabbed_offset + + if not is_powered: + quarters.stop() + else: + quarters.start() + +func _grab_zone(): + can_grab = true + +func _power_zone(): + quarters.start() + player.play("Animante") func _on_Quarters_timeout(): if SimData.prev_quarter == 4: + if SimData.budget >= expense: + SimData.budget -= expense + + if SimData.budget >= income: + SimData.budget += income + SimData.year += 1 SimData.emit_signal("one_time_zone") SimData.emit_signal("pay_expense") - SimData.prev_quarter = SimData.quarter + SimData.prev_quarter = SimData.quarter + quarters.start() diff --git a/scripts/autoload/SimData.gd b/scripts/autoload/sim_data.gd similarity index 94% rename from scripts/autoload/SimData.gd rename to scripts/autoload/sim_data.gd index 6043ecc..33c2618 100644 --- a/scripts/autoload/SimData.gd +++ b/scripts/autoload/sim_data.gd @@ -7,7 +7,7 @@ var quarter: int = 1 var population: int = 0 var news_ticker: String -var budget: int +var budget: int = 10000000 var prev_budget: int var res_tax: int diff --git a/scripts/autoload/SimEvents.gd b/scripts/autoload/sim_events.gd similarity index 100% rename from scripts/autoload/SimEvents.gd rename to scripts/autoload/sim_events.gd diff --git a/scripts/CameraMove.gd b/scripts/camera_move.gd similarity index 100% rename from scripts/CameraMove.gd rename to scripts/camera_move.gd diff --git a/scripts/Status.gd b/scripts/city_status.gd similarity index 100% rename from scripts/Status.gd rename to scripts/city_status.gd diff --git a/scripts/Game.gd b/scripts/gameplay.gd similarity index 100% rename from scripts/Game.gd rename to scripts/gameplay.gd diff --git a/scripts/map_generator.gd b/scripts/map_generator.gd new file mode 100644 index 0000000..3f69aeb --- /dev/null +++ b/scripts/map_generator.gd @@ -0,0 +1,51 @@ +extends Node2D + +var noise: OpenSimplexNoise +var map_size = Vector2(80, 60) +var terrian_cap = 0.3 + +onready var terrian = $Terrian +onready var water = $Water + +func _ready(): + + randomize() + noise = OpenSimplexNoise.new() + noise.seed = randi() + noise.octaves = 1.5 + noise.period = 12 + + make_terrian_map() + make_water() + +func make_terrian_map(): + for x in map_size.x: + for y in map_size.y: + var a = noise.get_noise_2d(x, y) + if a < terrian_cap: + terrian.set_cell(x, y, 0) + + terrian.update_bitmask_region(Vector2(0.0, 0.0), Vector2(map_size.x, map_size.y)) + +func make_water(): + for x in map_size.x: + for y in map_size.y: + if terrian.get_cell(x, y): + water.set_cell(x, y, 0) + + water.update_bitmask_region(Vector2(0.0, 0.0), Vector2(map_size.x, map_size.y)) + +func fake_click(flags=0): + var ev = InputEvent + ev.type = InputEvent.MOUSE_BUTTON + ev.button_index=BUTTON_LEFT + ev.pressed = true + ev.global_pos = get_global_mouse_position() + ev.meta = flags + get_tree().input_event(ev) + +func _on_PoliceBtn_pressed(): + var police = preload("res://scenes/Zone.tscn") + var instance = police.instance() + add_child(instance) + instance.emit_signal("grabbed") diff --git a/scripts/StartGame.gd b/scripts/start_game.gd similarity index 79% rename from scripts/StartGame.gd rename to scripts/start_game.gd index 4dacb0c..c2755f7 100644 --- a/scripts/StartGame.gd +++ b/scripts/start_game.gd @@ -1,8 +1,11 @@ extends Panel onready var city_name = $Container/CityNameEdit.text +onready var budget = $Container/BudgetMenu func _on_CreateBtn_pressed(): SimData.city_name = city_name + + get_tree().change_scene("res://scenes/Game.tscn")