It's Cow Game! Version 2.04!

This commit is contained in:
PajamaBee 2024-09-19 23:06:51 -05:00
commit a9e1ed9ddd
3148 changed files with 95332 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://b32jksi1wsmvp"
path="res://.godot/imported/HarvestingTree.png-47a65796e5dbacfa9eec438f603c3156.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Objects/SkillSpecific/Gardening/HarvestingTree/HarvestingTree.png"
dest_files=["res://.godot/imported/HarvestingTree.png-47a65796e5dbacfa9eec438f603c3156.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View file

@ -0,0 +1,298 @@
extends Node2D
class_name PlantingSpot
enum PlantState {Empty, Planted, GrownTree}
@export var plantZoneName = "plant"
var currentState = PlantState.Empty
var currentItem
var queuedStates = []
var currentAction = ""
var currentActionProgress = 0
var currentActionSpeed = 30
var plantLives = 0
var timeBoosted = 0
var harvestCombo = 0
var rng = RandomNumberGenerator.new()
func _ready():
setup()
check_for_state_updates()
func _process(delta):
check_for_state_updates()
if currentAction == "Digging":
if GameVariables.player.cowState != "Digging":
cancel_digging()
else:
currentActionProgress += delta * currentActionSpeed
%DiggingBar.value = currentActionProgress
if currentActionProgress >= 100:
dig_up_complete()
elif currentAction == "Harvesting":
if GameVariables.player.cowState != "Harvesting":
cancel_harvesting()
else:
currentActionProgress += delta * currentActionSpeed
%HarvestingBar.value = currentActionProgress
if currentActionProgress >= 100:
currentActionProgress = 0
harvest_item()
if !harvest_life_check():
plantLives -= 1
if plantLives <= 0:
finish_harvesting()
func setup():
var plantDetails = PlantManager.get_plant_spot_details(plantZoneName)
if plantDetails != null:
plantLives = plantDetails.plantLives
timeBoosted = plantDetails.timeBoosted
queuedStates = plantDetails.queuedStates
set_state(plantDetails.state, plantDetails.item)
else:
set_state(PlantState.Empty, null)
func open_planting_menu():
if currentState == PlantState.Empty:
$PlantingWindow.popup_centered()
$PlantingWindow.opened()
func open_fertilization_menu():
if currentState == PlantState.Planted:
$FertilizingWindow.popup_centered()
$FertilizingWindow.opened()
func dig_up():
if currentState != PlantState.Planted and currentState != PlantState.GrownTree:
return
if currentAction == "Harvesting":
cancel_harvesting()
currentAction = "Digging"
GameVariables.player.change_state("Digging")
currentActionProgress = 0
%DiggingBar.value = 0
%DiggingBar.visible = true
func dig_up_complete():
InventoryManager.add_item_to_inventory(currentItem.duplicate())
MessageManager.item_popup(currentItem.duplicate())
queuedStates = []
set_state(PlantState.Empty, null)
cancel_digging()
func cancel_digging():
currentAction = ""
%DiggingBar.visible = false
GameVariables.player.change_state("Idle")
func harvest():
if currentState != PlantState.GrownTree:
return
if currentAction == "Digging":
cancel_digging()
currentAction = "Harvesting"
GameVariables.player.change_state("Harvesting")
currentActionProgress = 0
harvestCombo = 0
%HarvestingBar.value = 0
%HarvestingBar.visible = true
func harvest_item():
InventoryManager.add_item_to_inventory(currentItem.duplicate())
MessageManager.item_popup(currentItem.duplicate())
harvestCombo += 1
if harvestCombo >= 10:
if currentItem.get_name(false) == "Sugar":
AchievementManager.complete_achievement("Bountiful Harvest")
var itemXP = 2
itemXP += floori(currentItem.get_value() * 1.7)
if itemXP <= 0:
itemXP = 1
LevelManager.add_XP("gardening", itemXP)
LevelManager.get_skill("appreciating").experience_item(currentItem, "harvested")
func cancel_harvesting():
currentAction = ""
%HarvestingBar.visible = false
GameVariables.player.change_state("Idle")
func finish_harvesting():
currentAction = ""
%HarvestingBar.visible = false
queuedStates = []
set_state(PlantState.Empty, null)
GameVariables.player.change_state("Idle")
func harvest_life_check():
var successChance = 35
successChance -= currentItem.get_value() * 1.5
successChance += currentItem.get_edibility() * 0.5
successChance += LevelManager.get_skill("gardening").currentLevel * 1
var minChance = LevelManager.get_skill("gardening").currentLevel * 0.25
if currentItem.get_edibility() > 0:
minChance += currentItem.get_edibility() * 0.05
if successChance < minChance:
successChance = minChance
if successChance > 88:
successChance = 88
var result = rng.randf_range(1, 100)
if result <= successChance:
return true
return false
func check_for_state_updates():
var currentTime = Time.get_unix_time_from_system()
var latestReadyState = null
var statesToRemove = []
for state in queuedStates:
if currentTime + timeBoosted >= state.time:
if latestReadyState == null or latestReadyState.time < state.time:
latestReadyState = state
statesToRemove.append(state)
for state in statesToRemove:
queuedStates.erase(state)
if latestReadyState != null:
set_state(latestReadyState.state, latestReadyState.item)
func get_time_to_next_state_change():
var currentTime = Time.get_unix_time_from_system()
var lowestTime = null
for state in queuedStates:
var timeToState = state.time - (currentTime + timeBoosted)
if lowestTime == null or timeToState < lowestTime:
lowestTime = timeToState
return lowestTime
func set_state(state, item):
if $FertilizingWindow.visible:
$FertilizingWindow.hide()
get_tree().paused = false
if currentAction == "Digging":
if GameVariables.player.cowState == "Digging":
GameVariables.player.change_state("Idle")
cancel_digging()
elif currentAction == "Harvesting":
if GameVariables.player.cowState == "Harvesting":
GameVariables.player.change_state("Idle")
cancel_harvesting()
%HarvestingTree.visible = false
if state == PlantState.Empty:
currentItem = null
%PlantedItem.texture = null
%GrownPanel.visible = false
plantLives = 1
timeBoosted = 0
elif state == PlantState.Planted:
currentItem = item
%PlantedItem.texture = item.get_sprite()
%GrownPanel.visible = false
elif state == PlantState.GrownTree:
currentItem = item
%PlantedItem.texture = null
%HarvestingTree.visible = true
%HarvestableSprite1.texture = item.get_sprite()
%HarvestableSprite2.texture = item.get_sprite()
%HarvestableSprite3.texture = item.get_sprite()
%GrownPanel.visible = true
currentState = state
save_details()
func add_plant_lives(amount):
plantLives += amount
save_details()
func add_time_boosted(amountToBoost):
timeBoosted += amountToBoost
save_details()
func save_details():
PlantManager.store_plant_spot_details(plantZoneName, self)
func plant_item(item):
queuedStates = []
var growthTime = get_growth_time(item)
queuedStates.append(create_queued_state(PlantState.GrownTree, item, growthTime))
check_for_queued_state_override(item)
plantLives = get_starting_lives(item)
if plantZoneName == "pigeonGrovePlant" and item.get_name(false).contains("Evidence"):
SaveManager.set_save_value("jonaldPigeonEvidencePlanted", true)
set_state(PlantState.Planted, item)
func check_for_queued_state_override(item):
if item.get_name(false) == "Sunflower Seed":
queuedStates[0].item = preload("res://Items/Plants/Sunflower.gd").new()
if item.get_name(false) == "Mustard Seed":
queuedStates[0].item = preload("res://Items/Foods/Condiments/Mustard.gd").new()
if item.get_name(false) == "Grow Your Own Mushroom Kit":
queuedStates[0].item = MushroomGenerator.get_a_mushroom()
func get_starting_lives(item):
return 1
func get_growth_time(item:Item):
var growthTime = 45
growthTime += item.get_value() * 8
growthTime += (100 - item.get_edibility()) * 6
if Item.modifications.Wet in item.itemModifications:
growthTime = growthTime * 0.6
growthTime = floori(growthTime)
if growthTime < 1:
growthTime = 1
return growthTime
func create_queued_state(state, plant, timeToPass):
var currentTime = Time.get_unix_time_from_system()
var newQueuedState = {}
newQueuedState.state = state
newQueuedState.item = plant
newQueuedState.time = currentTime + timeToPass
return newQueuedState

Binary file not shown.

After

Width:  |  Height:  |  Size: 304 B

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://chsmw1poq32gu"
path="res://.godot/imported/PlantingSpot.png-e06d0c86b479dc651a5485afb48040b6.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Objects/SkillSpecific/Gardening/PlantingSpot.png"
dest_files=["res://.godot/imported/PlantingSpot.png-e06d0c86b479dc651a5485afb48040b6.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View file

@ -0,0 +1,178 @@
[gd_scene load_steps=18 format=3 uid="uid://dyum5p1i4skee"]
[ext_resource type="PackedScene" uid="uid://cujx1a8vwxsj8" path="res://Objects/world_object.tscn" id="1_o8hry"]
[ext_resource type="Texture2D" uid="uid://chsmw1poq32gu" path="res://Objects/SkillSpecific/Gardening/PlantingSpot.png" id="2_1jtgw"]
[ext_resource type="Script" path="res://Objects/SkillSpecific/Gardening/PlantingSpot.gd" id="2_wl8q1"]
[ext_resource type="Texture2D" uid="uid://c3m2e2k7pa3al" path="res://Items/Foods/Fruits/Sprites/Apple.png" id="3_2uyv6"]
[ext_resource type="Texture2D" uid="uid://b32jksi1wsmvp" path="res://Objects/SkillSpecific/Gardening/HarvestingTree/HarvestingTree.png" id="4_4aabt"]
[ext_resource type="Texture2D" uid="uid://d11tc6ts1khob" path="res://Items/Foods/Fruits/Sprites/Tomato.png" id="5_lxiyu"]
[ext_resource type="PackedScene" uid="uid://cjend4i0ag1bq" path="res://UI/Gardening/PlantingWindow.tscn" id="5_pc6bo"]
[ext_resource type="PackedScene" uid="uid://bqibe7ha6r5ls" path="res://Interactions/Interactable/interactable.tscn" id="6_00gxq"]
[ext_resource type="PackedScene" uid="uid://c5ov4p0febsqt" path="res://UI/Gardening/FertilizingWindow.tscn" id="7_cikuu"]
[ext_resource type="PackedScene" uid="uid://cjocgnhcqft5t" path="res://Interactions/GardeningSpot/GardeningSpot.tscn" id="9_6evsd"]
[sub_resource type="SpriteFrames" id="SpriteFrames_8pqi2"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": ExtResource("2_1jtgw")
}],
"loop": true,
"name": &"default",
"speed": 5.0
}]
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_514te"]
[sub_resource type="CircleShape2D" id="CircleShape2D_a8rsb"]
radius = 34.3657
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_33pvk"]
bg_color = Color(0.729412, 0.556863, 0.482353, 1)
border_width_left = 2
border_width_top = 2
border_width_right = 2
border_width_bottom = 2
border_color = Color(0, 0, 0, 1)
corner_radius_top_left = 6
corner_radius_top_right = 6
corner_radius_bottom_right = 6
corner_radius_bottom_left = 6
anti_aliasing = false
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_8ce7q"]
bg_color = Color(0.239216, 0.14902, 0.0745098, 1)
border_width_left = 2
border_width_top = 2
border_width_right = 2
border_width_bottom = 2
border_color = Color(0.8, 0.8, 0.8, 0)
corner_radius_top_left = 6
corner_radius_top_right = 6
corner_radius_bottom_right = 6
corner_radius_bottom_left = 6
anti_aliasing = false
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_4qsgr"]
bg_color = Color(0.709804, 0.870588, 0.556863, 1)
border_width_left = 2
border_width_top = 2
border_width_right = 2
border_width_bottom = 2
border_color = Color(0, 0, 0, 1)
corner_radius_top_left = 6
corner_radius_top_right = 6
corner_radius_bottom_right = 6
corner_radius_bottom_left = 6
anti_aliasing = false
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_bhbot"]
bg_color = Color(0.239216, 0.729412, 0.0745098, 1)
border_width_left = 2
border_width_top = 2
border_width_right = 2
border_width_bottom = 2
border_color = Color(0.8, 0.8, 0.8, 0)
corner_radius_top_left = 6
corner_radius_top_right = 6
corner_radius_bottom_right = 6
corner_radius_bottom_left = 6
anti_aliasing = false
[node name="PlantingSpot" instance=ExtResource("1_o8hry")]
process_mode = 3
script = ExtResource("2_wl8q1")
[node name="PlantedItem" type="Sprite2D" parent="." index="0"]
unique_name_in_owner = true
position = Vector2(0, -25)
texture = ExtResource("3_2uyv6")
[node name="HarvestingTree" type="Node2D" parent="." index="1"]
unique_name_in_owner = true
[node name="HarvestingTreeSprite" type="Sprite2D" parent="HarvestingTree" index="0"]
position = Vector2(2, -64)
texture = ExtResource("4_4aabt")
[node name="HarvestableSprite1" type="Sprite2D" parent="HarvestingTree" index="1"]
unique_name_in_owner = true
position = Vector2(-49, -85)
texture = ExtResource("5_lxiyu")
[node name="HarvestableSprite2" type="Sprite2D" parent="HarvestingTree" index="2"]
unique_name_in_owner = true
position = Vector2(12, -102)
texture = ExtResource("5_lxiyu")
[node name="HarvestableSprite3" type="Sprite2D" parent="HarvestingTree" index="3"]
unique_name_in_owner = true
position = Vector2(51, -55)
texture = ExtResource("5_lxiyu")
[node name="AnimatedSprite2D" parent="." index="2"]
position = Vector2(1, -13)
sprite_frames = SubResource("SpriteFrames_8pqi2")
[node name="CollisionPolygon2D" parent="StaticBody2D" index="0"]
position = Vector2(-3, 52)
polygon = PackedVector2Array(4, -54, 4, -53, 4, -54)
disabled = true
[node name="FertilizingWindow" parent="." index="4" instance=ExtResource("7_cikuu")]
visible = false
[node name="PlantingWindow" parent="." index="5" instance=ExtResource("5_pc6bo")]
visible = false
[node name="Interactable" parent="." index="6" instance=ExtResource("6_00gxq")]
[node name="Panel" parent="Interactable" index="1"]
offset_left = -37.0
offset_top = -34.0
offset_right = 36.0
offset_bottom = 11.0
[node name="GrownPanel" type="Panel" parent="Interactable" index="2"]
unique_name_in_owner = true
offset_left = -73.0
offset_top = -122.0
offset_right = 82.0
offset_bottom = 11.0
theme_override_styles/panel = SubResource("StyleBoxEmpty_514te")
[node name="GardeningSpot" parent="." index="7" instance=ExtResource("9_6evsd")]
[node name="CollisionShape2D" parent="GardeningSpot/InteractionArea" index="0"]
position = Vector2(0, -13)
shape = SubResource("CircleShape2D_a8rsb")
[node name="DiggingBar" type="ProgressBar" parent="." index="8"]
unique_name_in_owner = true
visible = false
offset_left = -56.0
offset_top = -76.0
offset_right = 57.0
offset_bottom = -60.0
theme_override_styles/background = SubResource("StyleBoxFlat_33pvk")
theme_override_styles/fill = SubResource("StyleBoxFlat_8ce7q")
value = 40.0
show_percentage = false
[node name="HarvestingBar" type="ProgressBar" parent="." index="9"]
unique_name_in_owner = true
visible = false
offset_left = -56.0
offset_top = -145.0
offset_right = 57.0
offset_bottom = -129.0
theme_override_styles/background = SubResource("StyleBoxFlat_4qsgr")
theme_override_styles/fill = SubResource("StyleBoxFlat_bhbot")
value = 40.0
show_percentage = false
[connection signal="gui_input" from="Interactable/GrownPanel" to="Interactable" method="_on_panel_gui_input"]
[editable path="Interactable"]
[editable path="Interactable/ActionMenu"]
[editable path="GardeningSpot"]