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_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_AddState_pressed() { GetNode <OptionButton>("StateButton").AddItem("NewState"); int id = GetNode <OptionButton>("StateButton").GetItemCount() - 1; Godot.Collections.Dictionary jsonDictionary = this.GetParent().GetParent().Call("ReadData", "State") as Godot.Collections.Dictionary; Godot.Collections.Dictionary stateData = new Godot.Collections.Dictionary(); Godot.Collections.Dictionary eraseCondition = new Godot.Collections.Dictionary(); Godot.Collections.Dictionary messages = new Godot.Collections.Dictionary(); Godot.Collections.Dictionary customEraseConditions = new Godot.Collections.Dictionary(); stateData.Add("name", "NewState"); stateData.Add("icon", ""); stateData.Add("restriction", 4); stateData.Add("priority", 100); eraseCondition.Add("turns_min", 0); eraseCondition.Add("turns_max", 0); eraseCondition.Add("erase_damage", 0); eraseCondition.Add("erase_setps", 0); stateData.Add("erase_conditions", eraseCondition); messages.Add("0", "Insert a custom message"); stateData.Add("messages", messages); customEraseConditions.Add("0", "Insert a custom condition"); stateData.Add("custom_erase_conditions", customEraseConditions); jsonDictionary.Add("state" + id, stateData); this.GetParent().GetParent().Call("StoreData", "State", jsonDictionary); }
private void _syncBots() { // Calculate the target amount of spawned bots String botId = AgentPrefix + AgentBotCounter; SpawnBots.Add(botId, GetTeamMapAIs()[(int)Team.TeamCode.TEAMALPHA].CreateUnit(AgentPrefix + AgentBotCounter, AgentPrefix + AgentBotCounter, false)); _spawnBotTargetBase.Add(botId, (int)AgentBotCounter); AgentBotCounter++; botId = AgentPrefix + AgentBotCounter; SpawnBots.Add(botId, GetTeamMapAIs()[(int)Team.TeamCode.TEAMBETA].CreateUnit(AgentPrefix + AgentBotCounter, AgentPrefix + AgentBotCounter, false)); _spawnBotTargetBase.Add(botId, (int)AgentBotCounter); AgentBotCounter++; }
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 _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); }
public void buildObstaclesCache() { TileMap tilemap = (TileMap)GetNode("Navigation2D/Ground"); foreach (Node node in GetNode("Obstacles").GetChildren()) { Obstacle obstacle = (Obstacle)node; Vector2 tileMapPosition = tilemap.WorldToMap(obstacle.Position); float xIndex = tileMapPosition.x; float yIndex = tileMapPosition.y; // Align to the cell deployment (2 x 2 index size) if (xIndex % 2 != 0) { xIndex = xIndex - 1; } if (yIndex % 2 != 0) { yIndex = yIndex - 1; } if (!obstacle.IsConnected("ObstacleDestroy", this, nameof(_onObstacleDestroy))) { obstacle.Connect("ObstacleDestroy", this, nameof(_onObstacleDestroy)); } obstacles.Add("obstacle_" + xIndex + "_" + yIndex, obstacle.Position); } }
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 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); } }
public void ClosePort(RoadConnectorSide side_from, RoadConnectorSide side_to) { if (!connectedPorts.ContainsKey(side_from.GetPath())) { connectedPorts.Add(side_from.GetPath(), side_to.GetPath()); } }
public void _addTraversableTiles(Godot.Collections.Array tiles) { foreach (Vector2 tile in tiles) { int id = getPointID((int)tile.x, (int)tile.y); if (!_aStar.HasPoint(id)) { _aStar.AddPoint(id, tile, 1); _tilestoWorld.Add(id, _tileMap.MapToWorld(tile) + _halfCellSize); ColorRect colorRect = new ColorRect(); _grid.AddChild(colorRect); colorRect.Color = _enableColor; colorRect.Modulate = new Color(1, 1, 1, 0.5f); _gridRects.Add(id, colorRect); colorRect.MouseFilter = Control.MouseFilterEnum.Ignore; colorRect.SetSize(_tileMap.CellSize); // Color Rect's x calculation is lightly different, so need to add 1.5f to position correctly colorRect.RectPosition = new Vector2(_tileMap.MapToWorld(tile).x + (_tileMap.CellSize.x * 1.5f), _tileMap.MapToWorld(tile).y); } } }
static SignaledPeer() { var stunServerArr = new Godot.Collections.Array(new String [] { "stun:stun.l.google.com:19302" }); var stunServerDict = new Godot.Collections.Dictionary(); stunServerDict.Add("urls", stunServerArr); RTCInitializer.Add("iceServers", stunServerDict); }
public static void Subscribe(string name, Signal s) { if (events.ContainsKey(name) == false) { events.Add(name, new EventsHandler()); } events[name].Signal += s; }
public void AddStation(String stationName, String stationURL) { Godot.Collections.Dictionary newStation = new Godot.Collections.Dictionary(); newStation.Add("strong", stationName); newStation.Add("code", stationURL); stationList.Add(newStation); File file = new File(); file.Open(stationsFilePath, File.ModeFlags.ReadWrite); String content = file.GetAsText().TrimStart('[').TrimEnd(']'); content += "[" + JSON.Print(newStation) + "::]"; file.StoreString(content); file.Close(); EmitSignal(nameof(AddNewStation), newStation); }
// Equip weapon at given index public void EquipItem(int itemIndex, Weapon.WeaponOrder weaponOrder, int weaponIndex) { if (IsItemIndexInUsed(itemIndex)) { return; } // Unequip weapon first UnequipItem(weaponOrder, weaponIndex); String wepaonKey = (int)weaponOrder + "_" + weaponIndex; _equipmentIndex.Add(wepaonKey, itemIndex); _usedIndex.Add(itemIndex); _agent.EquipWeapon(_items[itemIndex].ReferencePackedScene, weaponOrder, weaponIndex); EmitSignal(nameof(WeaponChangeSignal), weaponOrder, weaponIndex); EmitSignal(nameof(InventoryChangeSignal)); }
//*-------------------------------------------------------------------------*// #region SIGNAL CALLBACKS public void _onHook_HookedOntoTarget(Vector2 pTargetGlobalPosition, float power) { Vector2 to_target = pTargetGlobalPosition - Hook.GlobalPosition; // Check if the player is on the floor and the target bellow the character if (Utils.StateMachine_Player.RootNode.IsOnFloor() && to_target.y > 0.0f) { return; } // Change the state Godot.Collections.Dictionary <string, object> param = new Godot.Collections.Dictionary <string, object>(); param.Add("target_global_position", pTargetGlobalPosition); param.Add("velocity", Velocity); param.Add("velocity_multiplier", power); Hook.Arrow.HookPosition = pTargetGlobalPosition; Utils.StateMachine_Player.TransitionTo("Hook", param); }
/// <summary> /// Make the player jump /// </summary> private void _Movement_Jump(InputEvent @event) { if (Utils.StateMachine_Node.RootNode.IsOnFloor() && @event.IsActionPressed("button_A")) { Godot.Collections.Dictionary <string, object> param = new Godot.Collections.Dictionary <string, object>(); param.Add("impulse", true); Utils.StateMachine_Node.TransitionTo("Move/Air", param); } }
protected void setSkinGroups() { foreach (UMASkinGroup sg in Enum.GetValues(typeof(UMASkinGroup))) { var key = sg.ToString(); if (!skinGroup.ContainsKey(key)) { if (key.ToLower() != "none") { _skinGroup.Add(key, new Color(1, 1, 1, 1)); } } } }
public void Save() { var saveFile = new File(); saveFile.Open("user://DefendersData.save", File.ModeFlags.Write); var saveData = new Godot.Collections.Dictionary <string, object>(); foreach (var valuePair in _defenderLevels) { saveData.Add($"{_defenderNames[valuePair.Key]}_Level", valuePair.Value); } saveFile.StoreLine(JSON.Print(saveData)); saveFile.Close(); }
private Godot.Object MakeGDListDefinition(Ink.Runtime.ListDefinition listDefinition) { var items = new Godot.Collections.Dictionary <Godot.Object, int>(); foreach (KeyValuePair <Ink.Runtime.InkListItem, int> kv in listDefinition.items) { var inkListItem = MakeGDInkListItem(kv.Key); items.Add(inkListItem, kv.Value); } var definitionParams = new object[] { listDefinition.name, items }; var inkListDefinition = (Godot.Object)InkListDefinition.New(definitionParams); return(inkListDefinition); }
private void SaveSkills() { Godot.Collections.Dictionary jsonDictionary = this.GetParent().GetParent().Call("ReadData", "System") as Godot.Collections.Dictionary; Godot.Collections.Dictionary skillsData = new Godot.Collections.Dictionary(); int skillSize = GetNode <ItemList>("SkillTypesLabel/SkillTypeContainer/VBoxContainer/SkillTypeList").GetItemCount(); for (int i = 0; i < skillSize; i++) { String text = GetNode <ItemList>("SkillTypesLabel/SkillTypeContainer/VBoxContainer/SkillTypeList").GetItemText(i); skillsData.Add(i.ToString(), text); } jsonDictionary["skills"] = skillsData; this.GetParent().GetParent().Call("StoreData", "System", jsonDictionary); }
private void SaveElements() { Godot.Collections.Dictionary jsonDictionary = this.GetParent().GetParent().Call("ReadData", "System") as Godot.Collections.Dictionary; Godot.Collections.Dictionary elementsData = new Godot.Collections.Dictionary(); int elementSize = GetNode <ItemList>("ElementLabel/ElementContainer/EleBoxContainer/ElementList").GetItemCount(); for (int i = 0; i < elementSize; i++) { String text = GetNode <ItemList>("ElementLabel/ElementContainer/EleBoxContainer/ElementList").GetItemText(i); elementsData.Add(i.ToString(), text); } jsonDictionary["elements"] = elementsData; this.GetParent().GetParent().Call("StoreData", "System", jsonDictionary); }
private void SaveArmors() { Godot.Collections.Dictionary jsonDictionary = this.GetParent().GetParent().Call("ReadData", "System") as Godot.Collections.Dictionary; Godot.Collections.Dictionary armorsData = new Godot.Collections.Dictionary(); int armorSize = GetNode <ItemList>("ArmorTypesLabel/ArmorTypesContainer/ArBoxContainer/ArmorList").GetItemCount(); for (int i = 0; i < armorSize; i++) { String text = GetNode <ItemList>("ArmorTypesLabel/ArmorTypesContainer/ArBoxContainer/ArmorList").GetItemText(i); armorsData.Add(i.ToString(), text); } jsonDictionary["armors"] = armorsData; this.GetParent().GetParent().Call("StoreData", "System", jsonDictionary); }
private void SaveWeapons() { Godot.Collections.Dictionary jsonDictionary = this.GetParent().GetParent().Call("ReadData", "System") as Godot.Collections.Dictionary; Godot.Collections.Dictionary weaponsData = new Godot.Collections.Dictionary(); int weaponSize = GetNode <ItemList>("WeaponTypesLabel/WeaponTypesContainer/WpBoxContainer/WeaponList").GetItemCount(); for (int i = 0; i < weaponSize; i++) { String text = GetNode <ItemList>("WeaponTypesLabel/WeaponTypesContainer/WpBoxContainer/WeaponList").GetItemText(i); weaponsData.Add(i.ToString(), text); } jsonDictionary["weapons"] = weaponsData; this.GetParent().GetParent().Call("StoreData", "System", jsonDictionary); }
// Called when the node enters the scene tree for the first time. public override void _Ready() { gameStates = (GameStates)GetNode("/root/GAMESTATES"); network = (Network)GetNode("/root/NETWORK"); _remoteTransform2D = (RemoteTransform2D)GetNode("CameraRemoteTransform"); Particles2D smoke = (Particles2D)GetNode("Smoke"); smoke.Emitting = false; CurrentInventory = (Inventory)GetNode("Inventory"); DamageEffectTimer = (Timer)GetNode("DamageEffectTimer"); Body = (Sprite)GetNode("Body"); _health = MaxHealth; _energy = MaxEnergy; CurrentWeaponIndex.Add(Weapon.WeaponOrder.Left, 0); CurrentWeaponIndex.Add(Weapon.WeaponOrder.Right, 0); EmitSignal(nameof(HealthChangedSignal), _health * 100 / MaxHealth); EmitSignal(nameof(EnergyChangedSignal), _health * 100 / MaxHealth); }
public GContainers.Dictionary getStatBlocks() { GContainers.Dictionary dict = new GContainers.Dictionary(); for (int i = 0; i < 5; i++) { GContainers.Array sb = new GContainers.Array(); for (int j = 0; j < 6; j++) { int stat = Dice.Roll("3d6"); sb.Add((object)stat); } string key = i.ToString(); dict.Add((object)key, (object)sb); } return(dict); }
public void Iniitialize(CapaturableBaseManager capaturableBaseManager) { _capaturableBaseManager = capaturableBaseManager; foreach (CapturableBase capturableBase in capaturableBaseManager.GetBases()) { Sprite baseMarker = (Sprite)_baseMarker.Duplicate(); baseMarker.Name = capturableBase.Name + "_marker"; baseMarker.SelfModulate = Team.TeamColor[(int)capturableBase.GetCaptureBaseTeam()]; baseMarker.Show(); _grid.AddChild(baseMarker); // Add marker to dictionary _baseMarkers.Add(capturableBase.Name, baseMarker); } }
public void AddAgent(Agent agent) { if (!_agents.ContainsKey(agent.GetUnitName())) { Sprite agentMarker = (Sprite)_agentMarker.Duplicate(); agentMarker.Name = agent.GetUnitName() + "_marker"; agentMarker.Modulate = Team.TeamColor[(int)agent.GetCurrentTeam()]; _grid.AddChild(agentMarker); // Add agent to dictonary _agents.Add(agent.GetUnitName(), agent); // Add marker to dictionary _agentMarkers.Add(agent.GetUnitName(), agentMarker); } }
public void Input_State(InputEvent @event) { _moveNode.Input_State(@event); if (_jumpCount < Jump_Max_Count && @event.IsActionPressed("button_A")) { _Movement_Jump(); } // For the Dash state if (_moveNode.DashCount == 0 && @event.IsActionPressed("dash")) { _moveNode.DashCount++; Godot.Collections.Dictionary <string, object> param = new Godot.Collections.Dictionary <string, object>(); param.Add("direction", _moveNode.Hook.Raycast.CastTo.Normalized()); Utils.StateMachine_Player.TransitionTo("Move/Dash", param); } }
public void CoolerApiEvent(Godot.Collections.Dictionary @event) { @event.Add("timestamp", time); // For each system, decorate the event. // foreach (CrawlerSystem system in GetNode("Systems").GetChildren()) // { // system.ProcessEvent(this, @event); // } // Send the event to the view, if the player('s team) sees it. this.EmitSignal("NewEvent", @event); // For each system, react to the event. // (Skill procs, or something? could be fun) foreach (CrawlerSystem system in GetNode("Systems").GetChildren()) { system.ProcessEvent(this, @event); } }