diff --git a/Library/Singletons/Generations.cs b/Library/Singletons/Generations.cs deleted file mode 100644 index 3c682ed..0000000 --- a/Library/Singletons/Generations.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace PokePurple.Library.Singletons; - -public class Generations -{ - private List _generations = - [ - new Range(1,151), - new Range(152, 251), - new Range(252, 386), - new Range(387, 493), - new Range(494, 649), - new Range(650, 721), - new Range(722, 809), - new Range(810, 905), - new Range(906, 1025) - ]; - - public int Generation = 1; - - public int PickRandomPokemon() - { - var maxRange = _generations[Generation].End.Value; - var random = new Random(); - var id = random.Next(1, maxRange); - return id; - } -} \ No newline at end of file diff --git a/Library/Singletons/Generations.cs.uid b/Library/Singletons/Generations.cs.uid deleted file mode 100644 index a4d73c0..0000000 --- a/Library/Singletons/Generations.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://dbfww8rxe1kj2 diff --git a/Library/Singletons/GifManager.cs b/Library/Singletons/GifManager.cs index 04f89b6..ca5d889 100644 --- a/Library/Singletons/GifManager.cs +++ b/Library/Singletons/GifManager.cs @@ -7,12 +7,11 @@ public class GifManager private static GifManager? _instance; public static GifManager Instance => _instance ?? (_instance = new GifManager()); - private GodotObject _gifManager; + private Node _gifManager; public GifManager() { - _gifManager = Engine.GetSingleton("GifManager"); - //_gifManager = ((SceneTree)Engine.GetMainLoop()).GetRoot().GetNode("GifManager"); + _gifManager = ((SceneTree)Engine.GetMainLoop()).GetRoot().GetNode("GifManager"); } public AnimatedTexture AnimatedTextureFromBuffer(byte[] data, int max_frames = 0) => _gifManager.Call("animated_texture_from_buffer", data, max_frames).As(); diff --git a/Scenes/WildPokemon.cs b/Scenes/WildPokemon.cs deleted file mode 100644 index 692e4ca..0000000 --- a/Scenes/WildPokemon.cs +++ /dev/null @@ -1,49 +0,0 @@ -using Godot; -using System; -using System.ComponentModel; -using System.Text; -using Godot.Sharp.Extras; -using PokeApiNet; -using PokePurple.Library.Singletons; - -public partial class WildPokemon : Node2D -{ - private Generations _generations = new(); - private Pokemon _pokemon; - private PokeApiClient _apiClient; - private System.Net.Http.HttpClient _http; - [NodePath] private AnimatedSprite2D _pokemonSprite; - - private String _animatedUrl = - "https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/other/showdown/{0}.gif"; - - public override void _Ready() - { - this.OnReady(); - _apiClient = new(); - _http = new(); - _generations.Generation = 8; - InitPokemon(); - } - - public override void _Input(InputEvent @event) - { - if (Input.IsActionJustPressed("debug_pokemon")) - { - InitPokemon(); - } - } - - private async void InitPokemon() - { - var pokeId = _generations.PickRandomPokemon(); - _pokemon = await _apiClient.GetResourceAsync(pokeId); - GD.Print(_pokemon.Name); - var url = String.Format(_animatedUrl, pokeId); - GD.Print(url); - var data = await _http.GetByteArrayAsync(url); - var frames = GifManager.Instance.SpriteFramesFromBuffer(data); - _pokemonSprite.SpriteFrames = frames; - _pokemonSprite.Play(); - } -} diff --git a/Scenes/WildPokemon.cs.uid b/Scenes/WildPokemon.cs.uid deleted file mode 100644 index 1db12bd..0000000 --- a/Scenes/WildPokemon.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://cfn824p8fcutm diff --git a/Scenes/WildPokemon.tscn b/Scenes/WildPokemon.tscn deleted file mode 100644 index f0d44f9..0000000 --- a/Scenes/WildPokemon.tscn +++ /dev/null @@ -1,10 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://k73x3ho8t1x1"] - -[ext_resource type="Script" uid="uid://cfn824p8fcutm" path="res://Scenes/WildPokemon.cs" id="1_3f6p2"] - -[node name="WildPokemon" type="Node2D"] -script = ExtResource("1_3f6p2") - -[node name="PokemonSprite" type="AnimatedSprite2D" parent="."] -position = Vector2(180, 180) -scale = Vector2(2, 2) diff --git a/project.godot b/project.godot index d7db4f8..6a3096d 100644 --- a/project.godot +++ b/project.godot @@ -27,14 +27,6 @@ project/assembly_name="PokePurple" enabled=PackedStringArray("res://addons/twitcher/plugin.cfg") -[input] - -debug_pokemon={ -"deadzone": 0.2, -"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":80,"key_label":0,"unicode":112,"location":0,"echo":false,"script":null) -] -} - [twitcher] editor/game_oauth_token="res://addons/twitcher/default_oauth_token.tres"