46 lines
1.5 KiB
GDScript
46 lines
1.5 KiB
GDScript
extends Node2D
|
|
|
|
class_name SwimmingZone
|
|
|
|
@export var liquidColor:Color
|
|
@export var swimmingLevelReq:int
|
|
@export var swimmingXp:int
|
|
@export var swimmingSpeed:int = 160
|
|
@export var viscosity:int = 50
|
|
|
|
func _ready():
|
|
%NoSwimShape.polygon = $SwimmingArea.get_child(0).polygon
|
|
$NoSwimBlocker.position = $SwimmingArea.position
|
|
|
|
func _process(delta):
|
|
if LevelManager.skill_check("swimming", swimmingLevelReq):
|
|
%NoSwimShape.disabled = true
|
|
else:
|
|
%NoSwimShape.disabled = false
|
|
|
|
func add_swam_location():
|
|
var locationName = LocationManager.currentLocationName
|
|
SaveManager.save_to_section("SwamAt", str(locationName), true)
|
|
var config = SaveManager.get_save_config()
|
|
var swamLocations = config.get_section_keys("SwamAt")
|
|
if swamLocations.size() >= 5:
|
|
AchievementManager.complete_achievement("Duathlon")
|
|
|
|
func _on_swimming_area_area_entered(area):
|
|
if area.get_parent() is Cow:
|
|
if LevelManager.skill_check("swimming", swimmingLevelReq):
|
|
area.get_parent().add_swimming_area(self)
|
|
add_swam_location()
|
|
elif area.get_parent() is GroundItem:
|
|
area.get_parent().interactingTerrains.append(self)
|
|
elif area.get_parent() is Ball and area.name == "WaterZone":
|
|
area.get_parent().add_swimming_area(self)
|
|
|
|
func _on_swimming_area_area_exited(area):
|
|
if area.get_parent() is Cow:
|
|
area.get_parent().remove_swimming_area(self)
|
|
elif area.get_parent() is GroundItem:
|
|
area.get_parent().interactingTerrains.erase(self)
|
|
elif area.get_parent() is Ball and area.name == "WaterZone":
|
|
area.get_parent().remove_swimming_area(self)
|