// Called when the node enters the scene tree for the first time. public void Start() { if (databaseLoaded == false) { Godot.Collections.Dictionary jsonDictionary = this.GetParent().GetParent().Call("ReadData", "Effect") as Godot.Collections.Dictionary; for (int i = 0; i < jsonDictionary.Count; i++) { Godot.Collections.Dictionary effectData = jsonDictionary["effect" + i] as Godot.Collections.Dictionary; Godot.Collections.Dictionary showList = effectData["data_type"] as Godot.Collections.Dictionary; Godot.Collections.Dictionary value2 = effectData["value2"] as Godot.Collections.Dictionary; GetNode <ItemList>("EffectLabel/PanelContainer/VBoxContainer/Effects/EffectNames").AddItem(effectData["name"].ToString()); if (showList["show"] as bool? == true) { GetNode <ItemList>("EffectLabel/PanelContainer/VBoxContainer/Effects/DataTypes").AddItem(showList["data"].ToString()); } else { GetNode <ItemList>("EffectLabel/PanelContainer/VBoxContainer/Effects/DataTypes").AddItem("Disabled"); } GetNode <ItemList>("EffectLabel/PanelContainer/VBoxContainer/Effects/EffectValue1").AddItem(effectData["value1"].ToString()); if (value2["show"] as bool? == true) { GetNode <ItemList>("EffectLabel/PanelContainer/VBoxContainer/Effects/EffectValue2").AddItem(value2["data"].ToString()); } else { GetNode <ItemList>("EffectLabel/PanelContainer/VBoxContainer/Effects/EffectValue2").AddItem("-1"); } } databaseLoaded = true; } }
private void RefreshData(int id) { Godot.Collections.Dictionary jsonDictionary = this.GetParent().GetParent().Call("ReadData", "Skill") as Godot.Collections.Dictionary; Godot.Collections.Dictionary skillData = jsonDictionary["skill" + id] as Godot.Collections.Dictionary; GetNode <LineEdit>("NameLabel/NameText").Text = skillData["name"] as string; string icon = skillData["icon"] as string; if (icon != "") { GetNode <Sprite>("IconLabel/IconSprite").Texture = GD.Load(skillData["icon"] as string) as Godot.Texture; } GetNode <TextEdit>("DescLabel/DescText").Text = skillData["description"] as string; GetNode <OptionButton>("SkillTypeLabel/SkillTypeButton").Selected = Convert.ToInt32(skillData["skill_type"]); GetNode <SpinBox>("MPCostLabel/MPCostBox").Value = Convert.ToInt32(skillData["mp_cost"]); GetNode <SpinBox>("TPCostLabel/TPCostBox").Value = Convert.ToInt32(skillData["tp_cost"]); GetNode <OptionButton>("TargetLabel/TargetButton").Selected = Convert.ToInt32(skillData["target"]); GetNode <OptionButton>("UsableLabel/UsableButton").Selected = Convert.ToInt32(skillData["usable"]); GetNode <SpinBox>("HitLabel/HitBox").Value = Convert.ToInt32(skillData["success"]); GetNode <OptionButton>("TypeLabel/TypeButton").Selected = Convert.ToInt32(skillData["hit_type"]); GetNode <OptionButton>("DamageLabel/DTypeLabel/DTypeButton").Selected = Convert.ToInt32(skillData["damage_type"]); GetNode <OptionButton>("DamageLabel/ElementLabel/ElementButton").Selected = Convert.ToInt32(skillData["element"]); GetNode <LineEdit>("DamageLabel/DFormulaLabel/FormulaText").Text = skillData["formula"] as string; if (skillData.Contains("effects") == true) { this.ClearEffectList(); Godot.Collections.Array effectList = skillData["effects"] as Godot.Collections.Array; foreach (Godot.Collections.Dictionary effect in effectList) { this.AddEffectList(effect["name"].ToString(), Convert.ToInt32(effect["data_id"]), effect["value1"].ToString(), effect["value2"].ToString()); } } }
private void RefreshPhysicsState(float delta) { if (IsOnFloor()) { timeSinceLeftFloor = 0f; } else { Godot.Collections.Dictionary intersections = GetWorld2d().DirectSpaceState .IntersectRay(feet.GlobalPosition, feet.GlobalPosition + new Vector2(0, 2), exclude: Extensions.ArrayFrom(this)); if (intersections.Count > 1) { // intersections["collider"]; timeSinceLeftFloor = 0f; } else { timeSinceLeftFloor += delta; } } if (Jumped) { timeSinceJumped += delta; } }
private void _on_AddClass_pressed() { GetNode <OptionButton>("ClassButton").AddItem("NewClass"); int id = GetNode <OptionButton>("ClassButton").GetItemCount() - 1; Godot.Collections.Dictionary jsonDictionary = this.GetParent().GetParent().Call("ReadData", "Class") as Godot.Collections.Dictionary; Godot.Collections.Dictionary classData = new Godot.Collections.Dictionary(); Godot.Collections.Dictionary statData = new Godot.Collections.Dictionary(); Godot.Collections.Dictionary skillData = new Godot.Collections.Dictionary(); classData.Add("name", "NewClass"); classData.Add("icon", ""); classData.Add("experience", "level * 30"); statData.Add("hp", "level * 25 + 10"); statData.Add("mp", "level * 15 + 5"); statData.Add("atk", "level * 5 + 3"); statData.Add("def", "level * 5 + 3"); statData.Add("int", "level * 5 + 3"); statData.Add("res", "level * 5 + 3"); statData.Add("spd", "level * 5 + 3"); statData.Add("luk", "level * 5 + 3"); classData.Add("stat_list", statData); skillData.Add(0, 5); classData.Add("skill_list", skillData); jsonDictionary.Add("class" + id, classData); this.GetParent().GetParent().Call("StoreData", "Class", jsonDictionary); }
private void _on_RemoveSkill_pressed() { Godot.Collections.Dictionary jsonDictionary = this.GetParent().GetParent().Call("ReadData", "Skill") as Godot.Collections.Dictionary; if (jsonDictionary.Keys.Count > 1) { int skillId = skillSelected; while (skillId < jsonDictionary.Keys.Count - 1) { jsonDictionary["skill" + skillId] = jsonDictionary["skill" + (skillId + 1)]; skillId += 1; } jsonDictionary.Remove("skill" + skillId); this.GetParent().GetParent().Call("StoreData", "Skill", jsonDictionary); GetNode <OptionButton>("SkillButton").RemoveItem(skillSelected); if (skillSelected == 0) { GetNode <OptionButton>("SkillButton").Select(skillSelected + 1); skillSelected += 1; } else { GetNode <OptionButton>("SkillButton").Select(skillSelected - 1); skillSelected -= 1; } GetNode <OptionButton>("SkillButton").Select(skillSelected); RefreshData(skillSelected); } }
public override void _PhysicsProcess(float delta) { if (do_raycast == true) { do_raycast = false; PhysicsDirectSpaceState spaceState = GetWorld().DirectSpaceState; Godot.Collections.Dictionary results = spaceState.IntersectRay(ray_origin, ray_end, null, 512u); if (results.Count > 0) { if (results["collider"] is Spatial spatial) { if (spatial.GetParent() is Tabs tabs) { currentHighlighted = tabs; tabs.MouseEnter(true); ResetPageFlip(); return; } if (spatial.GetParent() is FlipPages flip) { flipPages = flip; flipPages.Hovering(true); return; } } } if (currentHighlighted != null) { currentHighlighted.MouseEnter(false); currentHighlighted = null; } ResetPageFlip(); } }
//*-------------------------------------------------------------------------*// #region INTERFACE IMPLEMENTATION public void Enter_State(Godot.Collections.Dictionary <string, object> pParam) { //_player.isActive = false; _player.Position = _startPosition; // to respawn the character at the start of the level // TODO: ajouter une animation pour apparaitre et utiliser _on_Spawn_AnimationFinished Nucleus_Utils.StateMachine_Player.TransitionTo("Move/Idle", Nucleus_Utils.StateMachine_Player.TransitionToParam_Void); /* * if (_player.Skin != null) * { * _player.Skin.PlayAnimation("spawn"); * _player.Skin.Connect("AnimationFinished", this, nameof(_on_Spawn_AnimationFinished)); * } * else * { * // Force to display the Idle state * _on_Spawn_AnimationFinished(""); * } */ }
public static void Interact() { Game.PossessedPlayer.MatchSome( (Plr) => { Vector3 Start = Plr.Translation; Vector3 End = Start + new Vector3(0, 0, Player.InteractReach) .Rotated(new Vector3(1, 0, 0), Deg2Rad(Plr.ActualLookVertical)) .Rotated(new Vector3(0, 1, 0), Deg2Rad(Plr.LookHorizontal)); var Exclude = new Godot.Collections.Array { Plr }; PhysicsDirectSpaceState State = Plr.GetWorld().DirectSpaceState; Godot.Collections.Dictionary Results = State.IntersectRay(Start, End, Exclude, 4); if (Results.Count > 0) { object RawCollider = Results["collider"]; if (RawCollider is Locker CollidedLocker) { Menu.BuildInteractInventory(CollidedLocker); } } } ); }
private void _on_AddButton_pressed() { GetNode <OptionButton>("CharacterButton").AddItem("NewCharacter"); int id = GetNode <OptionButton>("CharacterButton").GetItemCount() - 1; Godot.Collections.Dictionary jsonDictionary = this.GetParent().GetParent().Call("ReadData", "Character") as Godot.Collections.Dictionary; Godot.Collections.Dictionary characterData = new Godot.Collections.Dictionary(); Godot.Collections.Dictionary etypeData = new Godot.Collections.Dictionary(); Godot.Collections.Dictionary einitData = new Godot.Collections.Dictionary(); characterData.Add("faceImage", "res://"); characterData.Add("charaImage", "res://"); characterData.Add("name", "NewCharacter"); characterData.Add("class", 0); characterData.Add("description", ""); characterData.Add("initialLevel", 1); characterData.Add("maxLevel", 99); etypeData.Add("w0", 0); etypeData.Add("w1", 1); etypeData.Add("a2", 0); etypeData.Add("a3", 3); einitData.Add("0", -1); einitData.Add("1", -1); einitData.Add("2", -1); einitData.Add("3", -1); characterData.Add("initial_equip", einitData); characterData.Add("equip_types", etypeData); jsonDictionary.Add("chara" + id, characterData); this.GetParent().GetParent().Call("StoreData", "Character", jsonDictionary); }
private void _on_RemoveArmor_pressed() { Godot.Collections.Dictionary jsonDictionary = this.GetParent().GetParent().Call("ReadData", "Armor") as Godot.Collections.Dictionary; if (jsonDictionary.Keys.Count > 1) { int armorId = armorSelected; while (armorId < jsonDictionary.Keys.Count - 1) { jsonDictionary["armor" + armorId] = jsonDictionary["armor" + (armorId + 1)]; armorId += 1; } jsonDictionary.Remove("armor" + armorId); this.GetParent().GetParent().Call("StoreData", "Armor", jsonDictionary); GetNode <OptionButton>("ArmorButton").RemoveItem(armorSelected); if (armorSelected == 0) { GetNode <OptionButton>("ArmorButton").Select(armorSelected + 1); armorSelected += 1; } else { GetNode <OptionButton>("ArmorButton").Select(armorSelected - 1); armorSelected -= 1; } GetNode <OptionButton>("ArmorButton").Select(armorSelected); RefreshData(armorSelected); } }
public void StoreData(String file, Godot.Collections.Dictionary save) { Godot.File databaseFile = new Godot.File(); databaseFile.Open("res://databases/" + file + ".json", Godot.File.ModeFlags.Write); databaseFile.StoreString(JSON.Print(save)); databaseFile.Close(); }
public void loadJson(string filePath) { var file = new File(); file.Open(filePath, 1); string text = file.GetAsText(); JSONParseResult dict = JSON.Parse(text); file.Close(); if (dict.Error != 0) { GD.Print("ErrorString:", dict.ErrorString); GD.Print("ErrorType:", dict.Error); GD.Print("ErrorLine:", dict.ErrorLine); } else { var parsed = new Godot.Collections.Dictionary <object, object>(); if (dict.Result is Godot.Collections.Dictionary) { //this does somehow not work and always returns null //thats why I wrote a parser in GDscript and then send it over parsed = (Godot.Collections.Dictionary <object, object>)dict.Result; GD.Print("parsed: "); GD.Print(parsed); } } }
// Called when the node enters the scene tree for the first time. public void Start() { Godot.Collections.Dictionary jsonDictionary = this.GetParent().GetParent().Call("ReadData", "Item") as Godot.Collections.Dictionary; for (int i = 0; i < jsonDictionary.Count; i++) { Godot.Collections.Dictionary itemData = jsonDictionary["item" + i] as Godot.Collections.Dictionary; if (i > GetNode <OptionButton>("ItemButton").GetItemCount() - 1) { GetNode <OptionButton>("ItemButton").AddItem(itemData["name"] as string); } else { GetNode <OptionButton>("ItemButton").SetItemText(i, itemData["name"] as string); } } jsonDictionary = this.GetParent().GetParent().Call("ReadData", "System") as Godot.Collections.Dictionary; Godot.Collections.Dictionary systemData = jsonDictionary["elements"] as Godot.Collections.Dictionary; for (int i = 0; i < systemData.Count; i++) { if (i > GetNode <OptionButton>("DamageLabel/ElementLabel/ElementButton").GetItemCount() - 1) { GetNode <OptionButton>("DamageLabel/ElementLabel/ElementButton").AddItem(systemData[i.ToString()] as string); } else { GetNode <OptionButton>("DamageLabel/ElementLabel/ElementButton").SetItemText(i, systemData[i.ToString()] as string); } } RefreshData(itemSelected); }
private void _on_RemoveItem_pressed() { Godot.Collections.Dictionary jsonDictionary = this.GetParent().GetParent().Call("ReadData", "Item") as Godot.Collections.Dictionary; if (jsonDictionary.Keys.Count > 1) { int itemId = itemSelected; while (itemId < jsonDictionary.Keys.Count - 1) { jsonDictionary["item" + itemId] = jsonDictionary["item" + (itemId + 1)]; itemId += 1; } jsonDictionary.Remove("item" + itemId); this.GetParent().GetParent().Call("StoreData", "Item", jsonDictionary); GetNode <OptionButton>("ItemButton").RemoveItem(itemSelected); if (itemSelected == 0) { GetNode <OptionButton>("ItemButton").Select(itemSelected + 1); itemSelected += 1; } else { GetNode <OptionButton>("ItemButton").Select(itemSelected - 1); itemSelected -= 1; } GetNode <OptionButton>("ItemButton").Select(itemSelected); RefreshData(itemSelected); } }
private void _on_AddWeaponButton_pressed() { GetNode <OptionButton>("WeaponButton").AddItem("NewWeapon"); int id = GetNode <OptionButton>("WeaponButton").GetItemCount() - 1; Godot.Collections.Dictionary jsonDictionary = this.GetParent().GetParent().Call("ReadData", "Weapon") as Godot.Collections.Dictionary; Godot.Collections.Dictionary weaponData = new Godot.Collections.Dictionary(); Godot.Collections.Dictionary weaponStats = new Godot.Collections.Dictionary(); weaponData.Add("name", "NewWeapon"); weaponData.Add("icon", ""); weaponData.Add("description", "New created weapon"); weaponData.Add("weapon_type", 0); weaponData.Add("slot_type", 0); weaponData.Add("price", 50); weaponData.Add("element", 0); weaponStats.Add("hp", "0"); weaponStats.Add("mp", "0"); weaponStats.Add("atk", "10"); weaponStats.Add("def", "2"); weaponStats.Add("int", "2"); weaponStats.Add("res", "1"); weaponStats.Add("spd", "0"); weaponStats.Add("luk", "0"); weaponData.Add("stat_list", weaponStats); jsonDictionary.Add("weapon" + id, weaponData); this.GetParent().GetParent().Call("StoreData", "Weapon", jsonDictionary); }
private void _on_RemoveCharacterButton_pressed() { Godot.Collections.Dictionary jsonDictionary = this.GetParent().GetParent().Call("ReadData", "Character") as Godot.Collections.Dictionary; if (jsonDictionary.Keys.Count > 1) { int chara = characterSelected; while (chara < jsonDictionary.Keys.Count - 1) { jsonDictionary["chara" + chara] = jsonDictionary["chara" + (chara + 1)]; chara += 1; } jsonDictionary.Remove("chara" + chara); this.GetParent().GetParent().Call("StoreData", "Character", jsonDictionary); GetNode <OptionButton>("CharacterButton").RemoveItem(characterSelected); if (characterSelected == 0) { GetNode <OptionButton>("CharacterButton").Select(characterSelected + 1); characterSelected += 1; } else { GetNode <OptionButton>("CharacterButton").Select(characterSelected - 1); characterSelected -= 1; } GetNode <OptionButton>("CharacterButton").Select(characterSelected); RefreshData(characterSelected); } }
private void _on_RemoveWeapon_pressed() { Godot.Collections.Dictionary jsonDictionary = this.GetParent().GetParent().Call("ReadData", "Weapon") as Godot.Collections.Dictionary; if (jsonDictionary.Keys.Count > 1) { int weaponId = weaponSelected; while (weaponId < jsonDictionary.Keys.Count - 1) { jsonDictionary["weapon" + weaponId] = jsonDictionary["weapon" + (weaponId + 1)]; weaponId += 1; } jsonDictionary.Remove("weapon" + weaponId); this.GetParent().GetParent().Call("StoreData", "Weapon", jsonDictionary); GetNode <OptionButton>("WeaponButton").RemoveItem(weaponSelected); if (weaponSelected == 0) { GetNode <OptionButton>("WeaponButton").Select(weaponSelected + 1); weaponSelected += 1; } else { GetNode <OptionButton>("WeaponButton").Select(weaponSelected - 1); weaponSelected -= 1; } GetNode <OptionButton>("WeaponButton").Select(weaponSelected); RefreshData(weaponSelected); } }
public void Physics_Update(float delta) { // Use Steering Behaviour to "move" the player to the hook, adding a pushing force when he arrive on it _velocity = Utils.Steering_Seek(_velocity, Utils.StateMachine_Player.RootNode.GlobalPosition, _target_GlobalPosition, HookMaxSpeed * _velocity_multiplier); _velocity = (_velocity.Length() > PushWhenArrive) ? _velocity : _velocity.Normalized() * PushWhenArrive; _velocity = Utils.StateMachine_Player.RootNode.MoveAndSlide(_velocity, Utils.VECTOR_FLOOR); // Get distance to the target float distance = Utils.GetDistanceBetween_2_Objects(Utils.StateMachine_Player.RootNode.GlobalPosition, _target_GlobalPosition); // Check if we are less that 1 frame (_velocity.Length() * delta) from the target to apply the push and change state if (distance < (_velocity.Length() * delta)) { _velocity = _velocity.Normalized() * PushWhenArrive; Godot.Collections.Dictionary <string, object> param = new Godot.Collections.Dictionary <string, object>(); param.Add("velocity", _velocity); Utils.StateMachine_Player.TransitionTo("Move/Air", param); } if (Utils.StateMachine_Player.RootNode.IsOnFloor()) { Utils.StateMachine_Player.TransitionTo("Move/Run", Utils.StateMachine_Player.TransitionToParam_Void); } }
private void SaveSlots() { Godot.Collections.Dictionary jsonDictionary = this.GetParent().GetParent().Call("ReadData", "System") as Godot.Collections.Dictionary; Godot.Collections.Dictionary slotsData = new Godot.Collections.Dictionary(); int slotSize = GetNode <ItemList>("EquipmentLabel/EquipContainer/SetContainer/SetDivisor/KindList").GetItemCount(); for (int i = 0; i < slotSize; i++) { String kind = GetNode <ItemList>("EquipmentLabel/EquipContainer/SetContainer/SetDivisor/KindList").GetItemText(i); String id = ""; switch (kind) { case "Weapon": id = "w"; break; case "Armor": id = "a"; break; } String text = GetNode <ItemList>("EquipmentLabel/EquipContainer/SetContainer/SetDivisor/TypeList").GetItemText(i); id += i.ToString(); slotsData.Add(id.ToString(), text); } jsonDictionary["slots"] = slotsData; this.GetParent().GetParent().Call("StoreData", "System", jsonDictionary); }
public void RegisterProperty( string name, Godot.Variant.Type type, GetPropertyFunction getFunction, SetPropertyFunction setFunction ) { // calculate name string propertyName = ""; foreach (string group in currentGroup) { propertyName += $"{group}/"; } propertyName += name; // add property to property list var newProperty = new Godot.Collections.Dictionary(); newProperty["name"] = propertyName; newProperty["type"] = type; newProperty["usage"] = Godot.PropertyUsageFlags.Default; propertyList.Add(newProperty); // setup get and set logic getPropertyFunctions.Add(propertyName, getFunction); setPropertyFunctions.Add(propertyName, setFunction); }
private int CheckCollisions(Vector2 StartPosition, Vector2 EndPosition) { int PossibleLength = 0; Physics2DDirectSpaceState spaceState = GetWorld2d().DirectSpaceState; Vector2 Direction = (EndPosition - StartPosition).Normalized(); Vector2 rayEnd = (StartPosition + (Direction * (25 + (ChainLength * LengthOfChainLink)))); Godot.Collections.Dictionary result = spaceState.IntersectRay(StartPosition, rayEnd, PlayerArr); Vector2 positionOfChainEnd = StartPosition; if (result.Count != 0) { Vector2 collisionPosition = (Vector2)result["position"]; double distanceBetween = Math.Sqrt(Math.Pow((collisionPosition.x - positionOfChainEnd.x), 2) + Math.Pow((collisionPosition.y - positionOfChainEnd.y), 2)); double unitsBetween = (distanceBetween / LengthOfChainLink); PossibleLength = Convert.ToInt32(Math.Floor(unitsBetween)); } else { PossibleLength = ChainLength; } return(PossibleLength); }
public override void _Ready() { CrashAudio = GetNode <AudioStreamPlayer2D>("CrashAudio"); HookLaunchAudio = GetNode <AudioStreamPlayer2D>("HookLaunchAudio"); PickupCreatureAudio = GetNode <AudioStreamPlayer2D>("PickupCreatureAudio"); CreaturesCaught = new Godot.Collections.Dictionary <string, int>(); CreaturesCost = new Godot.Collections.Dictionary <string, int>(); Hookable = true; Hook = GetNode <Node2D>("Hook"); HookChain = GetNode <ColorRect>("HookChain"); OriginalHookChainHeight = HookChain.GetRect().Size.y; HookHitBoxCollision = GetNode <CollisionShape2D>("Hook/Claw/Area2D/CollisionShape2D"); HookHitBoxCollision.Disabled = true; HookLaunch = GetNode <Tween>("HookLaunch"); HookRetract = GetNode <Tween>("HookRetract"); HookChainLaunch = GetNode <Tween>("HookChainLaunch"); HookChainRetract = GetNode <Tween>("HookChainRetract"); OriginalHookPosition = Hook.Position; CrashParticles = GetNode <Particles2D>("CrashParticles"); Bubbler = GetNode <Particles2D>("Bubbler"); }
private void _on_RemoveClass_pressed() { Godot.Collections.Dictionary jsonDictionary = this.GetParent().GetParent().Call("ReadData", "Class") as Godot.Collections.Dictionary; if (jsonDictionary.Keys.Count > 1) { int classId = classSelected; while (classId < jsonDictionary.Keys.Count - 1) { jsonDictionary["class" + classId] = jsonDictionary["class" + (classId + 1)]; classId += 1; } jsonDictionary.Remove("class" + classId); this.GetParent().GetParent().Call("StoreData", "Class", jsonDictionary); GetNode <OptionButton>("ClassButton").RemoveItem(classSelected); if (classSelected == 0) { GetNode <OptionButton>("ClassButton").Select(classSelected + 1); classSelected += 1; } else { GetNode <OptionButton>("ClassButton").Select(classSelected - 1); classSelected -= 1; } GetNode <OptionButton>("ClassButton").Select(classSelected); RefreshData(classSelected); } }
private void _on_AddEnemy_pressed() { GetNode <OptionButton>("EnemyButton").AddItem("NewEnemy"); int id = GetNode <OptionButton>("EnemyButton").GetItemCount() - 1; Godot.Collections.Dictionary jsonDictionary = this.GetParent().GetParent().Call("ReadData", "Enemy") as Godot.Collections.Dictionary; Godot.Collections.Dictionary enemyData = new Godot.Collections.Dictionary(); Godot.Collections.Dictionary statsData = new Godot.Collections.Dictionary(); Godot.Collections.Dictionary dropData = new Godot.Collections.Dictionary(); enemyData.Add("name", "Slime"); enemyData.Add("graphicImage", ""); statsData.Add("hp", "150"); statsData.Add("mp", "50"); statsData.Add("atk", "18"); statsData.Add("def", "16"); statsData.Add("int", "8"); statsData.Add("res", "4"); statsData.Add("spd", "12"); statsData.Add("luk", "10"); dropData.Add("i0", 80); enemyData.Add("experience", 6); enemyData.Add("money", 50); enemyData.Add("stat_list", statsData); enemyData.Add("drop_list", dropData); jsonDictionary.Add("enemy" + id, enemyData); this.GetParent().GetParent().Call("StoreData", "Enemy", jsonDictionary); }
private void SaveSkillData() { Godot.Collections.Dictionary jsonDictionary = this.GetParent().GetParent().Call("ReadData", "Skill") as Godot.Collections.Dictionary; Godot.Collections.Dictionary skillData = jsonDictionary["skill" + skillSelected] as Godot.Collections.Dictionary; Godot.Collections.Array effectList = new Godot.Collections.Array(); skillData["name"] = GetNode <LineEdit>("NameLabel/NameText").Text; GetNode <OptionButton>("SkillButton").SetItemText(skillSelected, GetNode <LineEdit>("NameLabel/NameText").Text); skillData["icon"] = iconPath; skillData["description"] = GetNode <TextEdit>("DescLabel/DescText").Text; skillData["skill_type"] = GetNode <OptionButton>("SkillTypeLabel/SkillTypeButton").Selected; skillData["mp_cost"] = GetNode <SpinBox>("MPCostLabel/MPCostBox").Value; skillData["tp_cost"] = GetNode <SpinBox>("TPCostLabel/TPCostBox").Value; skillData["target"] = GetNode <OptionButton>("TargetLabel/TargetButton").Selected; skillData["usable"] = GetNode <OptionButton>("UsableLabel/UsableButton").Selected; skillData["success"] = GetNode <SpinBox>("HitLabel/HitBox").Value; skillData["hit_type"] = GetNode <OptionButton>("TypeLabel/TypeButton").Selected; skillData["damage_type"] = GetNode <OptionButton>("DamageLabel/DTypeLabel/DTypeButton").Selected; skillData["element"] = GetNode <OptionButton>("DamageLabel/ElementLabel/ElementButton").Selected; skillData["formula"] = GetNode <LineEdit>("DamageLabel/DFormulaLabel/FormulaText").Text; int effectSize = GetNode <ItemList>("EffectLabel/PanelContainer/VBoxContainer/HBoxContainer/EffectNames").GetItemCount(); for (int i = 0; i < effectSize; i++) { Godot.Collections.Dictionary effectData = new Godot.Collections.Dictionary(); effectData["name"] = GetNode <ItemList>("EffectLabel/PanelContainer/VBoxContainer/HBoxContainer/EffectNames").GetItemText(i); effectData["data_id"] = GetNode <ItemList>("EffectLabel/PanelContainer/VBoxContainer/HBoxContainer/DataType").GetItemText(i); effectData["value1"] = GetNode <ItemList>("EffectLabel/PanelContainer/VBoxContainer/HBoxContainer/EffectValue1").GetItemText(i); effectData["value2"] = GetNode <ItemList>("EffectLabel/PanelContainer/VBoxContainer/HBoxContainer/EffectValue2").GetItemText(i); effectList.Add(effectData); } skillData["effects"] = effectList; this.GetParent().GetParent().Call("StoreData", "Skill", jsonDictionary); }
private void _on_RemoveEnemy_pressed() { Godot.Collections.Dictionary jsonDictionary = this.GetParent().GetParent().Call("ReadData", "Enemy") as Godot.Collections.Dictionary; if (jsonDictionary.Keys.Count > 1) { int enemyId = enemySelected; while (enemyId < jsonDictionary.Keys.Count - 1) { jsonDictionary["Enemy" + enemyId] = jsonDictionary["Enemy" + (enemyId + 1)]; enemyId += 1; } jsonDictionary.Remove("Enemy" + enemyId); this.GetParent().GetParent().Call("StoreData", "Enemy", jsonDictionary); GetNode <OptionButton>("EnemyButton").RemoveItem(enemySelected); if (enemySelected == 0) { GetNode <OptionButton>("EnemyButton").Select(enemySelected + 1); enemySelected += 1; } else { GetNode <OptionButton>("EnemyButton").Select(enemySelected - 1); enemySelected -= 1; } GetNode <OptionButton>("EnemyButton").Select(enemySelected); RefreshData(enemySelected); } }
private void _on_FileDialog_confirmed() { String path = GetNode <FileDialog>("FileDialog").CurrentPath; path += ".save"; var saveFile = new File(); saveFile.Open(path, File.ModeFlags.Write); Godot.Collections.Array savedTiles = GetParent().GetNode <BiomeGrid>("BiomeGrid").Save(); Godot.Collections.Array savedMeat = GetParent().GetNode <MultiMeshMeat>("MultiMeshMeat").Save(); Godot.Collections.Array globalTimeArray = GetParent().GetNode <SpeciesHolder>("SpeciesHolder").GetGlobalTimeArray(); Godot.Collections.Array savedSpecies = GetParent().GetNode <SpeciesHolder>("SpeciesHolder").Save(); Godot.Collections.Array plantBiomass = GetParent().GetNode <BiomeGrid>("BiomeGrid").GetPlantBiomassArray(); Godot.Collections.Array meatBiomass = GetParent().GetNode <MultiMeshMeat>("MultiMeshMeat").GetMeatBiomassArray(); float GlobalCurrentWaitingTime = GetParent().GetNode <SpeciesHolder>("SpeciesHolder").GetCurrentWaitingTime(); float BiomesCurrentWaitingTime = GetParent().GetNode <BiomeGrid>("BiomeGrid").GetCurrentWaitingTime(); Godot.Collections.Dictionary <String, object> saveData = new Godot.Collections.Dictionary <String, object>() { { "WorldSize", Global.worldSize }, { "PlantGrowthRate", Global.biomeGrowthRate }, { "GloablTimeArray", globalTimeArray }, { "PlantBiomass", plantBiomass }, { "MeatBiomass", meatBiomass }, { "BiomeTiles", savedTiles }, { "Meat", savedMeat }, { "Species", savedSpecies }, { "GlobalWaitingTime", GlobalCurrentWaitingTime }, { "BiomesWaitingTime", BiomesCurrentWaitingTime } }; saveFile.StoreLine(JSON.Print(saveData)); }
private void _on_DropEditOkButton_pressed() { Godot.Collections.Dictionary itemList = this.GetParent().GetParent().Call("ReadData", "Item") as Godot.Collections.Dictionary; Godot.Collections.Dictionary weaponList = this.GetParent().GetParent().Call("ReadData", "Weapon") as Godot.Collections.Dictionary; Godot.Collections.Dictionary armorList = this.GetParent().GetParent().Call("ReadData", "Armor") as Godot.Collections.Dictionary; int id = GetNode <OptionButton>("DropEdit/Type/OptionButton").GetSelectedId(); int selected_id = GetNode <OptionButton>("DropEdit/Drop/OptionButton").GetSelectedId(); int chance = Convert.ToInt32(GetNode <SpinBox>("DropEdit/Chance/SpinBox").Value); switch (id) { case 0: dropIdArray.Add("i" + selected_id); Godot.Collections.Dictionary itemData = itemList["item" + selected_id] as Godot.Collections.Dictionary; GetNode <ItemList>("DropsLabel/DropsContainer/VBoxContainer/HBoxContainer/DropsList").AddItem(itemData["name"].ToString()); break; case 1: dropIdArray.Add("w" + selected_id); Godot.Collections.Dictionary weaponData = weaponList["weapon" + selected_id] as Godot.Collections.Dictionary; GetNode <ItemList>("DropsLabel/DropsContainer/VBoxContainer/HBoxContainer/DropsList").AddItem(weaponData["name"].ToString()); break; case 2: dropIdArray.Add("a" + selected_id); Godot.Collections.Dictionary armorData = armorList["armor" + selected_id] as Godot.Collections.Dictionary; GetNode <ItemList>("DropsLabel/DropsContainer/VBoxContainer/HBoxContainer/DropsList").AddItem(armorData["name"].ToString()); break; } GetNode <ItemList>("DropsLabel/DropsContainer/VBoxContainer/HBoxContainer/ChanceList").AddItem(chance.ToString()); GetNode <WindowDialog>("DropEdit").Hide(); }
public override void _Ready() { _tileMap = GetNode <TileMap>("testlevel/Tile Layer 1"); // Get metadata for all tiles in the tile set Godot.Collections.Dictionary tileMaterials = (Godot.Collections.Dictionary)_tileMap.TileSet.GetMeta("tile_meta"); // Get the 'material' (terrain) for each tile and add them to this array Terrain[] tileTerrains = new Terrain[tileMaterials.Count]; int i = 0; foreach (var key in tileMaterials.Keys) { if (tileMaterials[key] is Godot.Collections.Dictionary mat) { tileTerrains[i] = StringToTerrain(mat["material"].ToString()); i++; } } // Build dictionary for every tile in the tile map and its terrain type foreach (Vector2 tilePos in _tileMap.GetUsedCells()) { _cellTerrains.Add(tilePos, tileTerrains[_tileMap.GetCellv(tilePos) - 1]); } }
public Godot.Collections.Array Save() { Godot.Collections.Array savedTiles = (Godot.Collections.Array) new Godot.Collections.Array(); foreach (Vector3 key in GroundTiles.Keys) { Godot.Collections.Dictionary <String, object> TileDictionary = new Godot.Collections.Dictionary <String, object>() { { "BiomeType", (int)(GroundTiles[key].type) }, { "PlantTranslationX", GroundTiles[key].plantSpatial.Translation.x }, { "PlantTranslationY", GroundTiles[key].plantSpatial.Translation.y }, { "PlantTranslationZ", GroundTiles[key].plantSpatial.Translation.z }, { "PlantScaleX", GroundTiles[key].plantSpatial.Scale.x }, { "PlantScaleY", GroundTiles[key].plantSpatial.Scale.y }, { "PlantScaleZ", GroundTiles[key].plantSpatial.Scale.z }, { "PlantGrowthTime", GroundTiles[key].plantGrowthTime }, { "EatersCount", GroundTiles[key].EatersCount }, { "IsPlantGrowing", GroundTiles[key].isPlantGrowing }, { "HasPlant", GroundTiles[key].hasPlant }, { "GridIndexX", GroundTiles[key].gridIndex.x }, { "GridIndexY", GroundTiles[key].gridIndex.y }, { "GridIndexZ", GroundTiles[key].gridIndex.z }, }; savedTiles.Add(TileDictionary); } return(savedTiles); }