public override void _Draw() { /// TODO separate the mechanics out of the drawing if (isMouseDragging) { dragRectBounds.Position = mousePressOrigin; dragRectBounds.Size = GetLocalMousePosition() - mousePressOrigin; DrawRect(dragRectBounds, DragRectColor, true); } else { query = new Physics2DShapeQueryParameters(); dragRectSelect.Extents = (GetGlobalMousePosition() - mousePressOrigin) / 2; query.SetShape(dragRectSelect); query.Transform = new Transform2D(0, (GetGlobalMousePosition() + mousePressOrigin) / 2); var results = worldSpace.IntersectShape(query); List <PlayerCharacter> players = new List <PlayerCharacter>(); foreach (Godot.Collections.Dictionary item in results) { if (item.Contains("collider")) { object collider = item["collider"]; if (collider.GetType() == typeof(PlayerCharacter)) { players.Add((PlayerCharacter)collider); } } } LocalCharacterManager.SelectAllInRect(players, !Input.IsActionPressed("modify")); } }
/* CHARACTER PORTRAITS AND SELECTION */ //Modify Override -- used by group to ensure drag keeps working public static void SelectPartyMember(int partyMember, bool modifyOverride = false) { //TODO At some point, players will have friendly spells to hit eachother with //They should be able to target eachother by clicking portraits InputManager.InterruptTargetedAbility(); //if SHIFT held, add to selection //if regular mouse, set to active if (Input.IsActionPressed("modify") || modifyOverride) { //Right-click first //This allows the 'else' to handle left clicks AND keyboard shortcuts /* REMOVING FROM SELECTED */ if (Input.IsMouseButtonPressed(2)) { var success = LocalCharacterManager.DeselectPartyMember(partyMember); if (success != null) { _partyIcons.SetPortraitSelected(partyMember, false); } } else { /* ADDING TO SELECTED */ var selectedCharacter = LocalCharacterManager.AddPartyMemberToSelected(partyMember); if (selectedCharacter != null) { _partyIcons.SetPortraitSelected(partyMember, true); if (_cameraControls != null) { FocusOn(selectedCharacter); } } } } else { /* SELECT ONE */ var selectedCharacter = LocalCharacterManager.SelectPartyMember(partyMember); if (selectedCharacter != null) { //Active party member, individual _partyIcons.SetPortraitSelected(partyMember, true, true); if (_cameraControls != null) { FocusOn(selectedCharacter); } } } UpdateAbilityToolbar(); }
public override void _Ready() { if (_lcm == null) { _lcm = this; } else { QueueFree(); } }
public static void UpdateAbilityToolbar() { if (_abilityToolbar != null) { if (LocalCharacterManager.GetSelectedCount() == 1) { _abilityToolbar.UpdateFor(LocalCharacterManager.GetSingleSelected()); } else { _abilityToolbar.UpdateFor(LocalCharacterManager.GetAllSelected()); } } }
/// <summary> /// /// </summary> /// <param name="mapName"></param> public static bool LoadMap(string mapKey, Vector2?triggeredFrom = null) { //Check distance is OK for all characters if (triggeredFrom != null) { var partyPositions = LocalCharacterManager.GetPartyPositions(); foreach (Vector2 pcp in partyPositions) { if (pcp.Dot((Vector2)triggeredFrom) > maxPlayerMapTransitionDistance) { return(false); } } } //Test map can actually be found and loaded if (!(zones.ContainsKey(mapKey) && ResourceLoader.Exists(zones[mapKey]))) { return(false); } GUIManager.SetLoadables(false); GUIManager.WipePartyElements(); LocalCharacterManager.ResetAll(); //We'll need another class to persist characters and recreate on the next map //Run a screen transition and wipe the current map //Reload the new map //Setup MCM, Party Icons as needed var loaded = ResourceLoader.Load(zones[mapKey]) as PackedScene; if (_ml.CurrentMap != null) { _ml.CurrentMap.QueueFree(); } _ml.GetTree().ChangeSceneTo(loaded); //Map will attempt to set itself as current map GUIManager.SetLoadables(true); return(true); }
public override void _Ready() { LocalCharacterManager.RegisterPresent(this); RegularAttack = GetNodeOrNull <RegularAttack>("RegularAttack"); Animator = GetNodeOrNull <CharacterAnimator>("Animator"); //Check for an overrideStatblock -- this lets us set custom stats for pre-placed encounters Stats = GetNodeOrNull <Statblock>("OverrideStatblock"); if (Stats == null) { Stats = GetNode <Statblock>("Statblock"); //Use default statblock if no custom one found. } else { GetNode <Statblock>("Statblock").QueueFree(); //Remove the regular one, we'll use the override! } _fsm = ((FSMachine)GetNode("FSMachine")); onDeath = (EventCreateObject)GetNodeOrNull("OnDeath"); _fsm.Activate(); //Setup once stats set }
public void ClickAction(ClickInfo info, Vector2 location) { //TODO Use location to determine which side of enemy to stand on (if needed) LocalCharacterManager.EnemyClicked(this); }
public void ClickAction(ClickInfo info, Vector2 location) { LocalCharacterManager.SelectPartyMember(this, !info.ModifyHeld); GUIManager.SelectPartyMember(PartyMemberOrder); }
public void ClickAction(ClickInfo info, Vector2 location) { LocalCharacterManager.MapClick(ToLocal(location), nav); }