Trailer Stuff & More
Changed title font to Montserrat Added trailer-specific camera transitions Added key to hide UI Fixed input listening while console is open Added animated zone reveal effect in galaxy map Added Ping action for sensors Added debug console commands (e.g. give command to get any item in legendary+ quality) Temporarily disabled wwise Fixed infinite loop in weapon penetration code Guided missiles now predict target position Fixed hitscan weapons Fixed invisible enemies bug Fixed various loadout generator issues (can now generate turrets!) Fixed wormhole crash when enemy is targeted Saving/loading current zone time when exiting game (planets keep their positions) Created slime simulation in test scene - WIP
This commit is contained in:
parent
64a8589b7f
commit
11a9365f91
108 changed files with 10049 additions and 856 deletions
|
|
@ -201,6 +201,14 @@ public class @AetheriaInput : IInputActionCollection, IDisposable
|
|||
""expectedControlType"": ""Button"",
|
||||
""processors"": """",
|
||||
""interactions"": """"
|
||||
},
|
||||
{
|
||||
""name"": ""Hide UI"",
|
||||
""type"": ""Button"",
|
||||
""id"": ""1cdb2515-91e1-4895-879d-8a7347e60b21"",
|
||||
""expectedControlType"": ""Button"",
|
||||
""processors"": """",
|
||||
""interactions"": """"
|
||||
}
|
||||
],
|
||||
""bindings"": [
|
||||
|
|
@ -643,6 +651,17 @@ public class @AetheriaInput : IInputActionCollection, IDisposable
|
|||
""action"": ""Ping"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": """",
|
||||
""id"": ""3f898572-d165-4e29-93c3-95c3efce5df9"",
|
||||
""path"": ""<Keyboard>/f2"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": ""Keyboard&Mouse"",
|
||||
""action"": ""Hide UI"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": false
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
@ -1232,6 +1251,7 @@ public class @AetheriaInput : IInputActionCollection, IDisposable
|
|||
m_Player_ToggleShield = m_Player.FindAction("Toggle Shield", throwIfNotFound: true);
|
||||
m_Player_OverrideShutdown = m_Player.FindAction("Override Shutdown", throwIfNotFound: true);
|
||||
m_Player_Ping = m_Player.FindAction("Ping", throwIfNotFound: true);
|
||||
m_Player_HideUI = m_Player.FindAction("Hide UI", throwIfNotFound: true);
|
||||
// UI
|
||||
m_UI = asset.FindActionMap("UI", throwIfNotFound: true);
|
||||
m_UI_Navigate = m_UI.FindAction("Navigate", throwIfNotFound: true);
|
||||
|
|
@ -1320,6 +1340,7 @@ public class @AetheriaInput : IInputActionCollection, IDisposable
|
|||
private readonly InputAction m_Player_ToggleShield;
|
||||
private readonly InputAction m_Player_OverrideShutdown;
|
||||
private readonly InputAction m_Player_Ping;
|
||||
private readonly InputAction m_Player_HideUI;
|
||||
public struct PlayerActions
|
||||
{
|
||||
private @AetheriaInput m_Wrapper;
|
||||
|
|
@ -1347,6 +1368,7 @@ public class @AetheriaInput : IInputActionCollection, IDisposable
|
|||
public InputAction @ToggleShield => m_Wrapper.m_Player_ToggleShield;
|
||||
public InputAction @OverrideShutdown => m_Wrapper.m_Player_OverrideShutdown;
|
||||
public InputAction @Ping => m_Wrapper.m_Player_Ping;
|
||||
public InputAction @HideUI => m_Wrapper.m_Player_HideUI;
|
||||
public InputActionMap Get() { return m_Wrapper.m_Player; }
|
||||
public void Enable() { Get().Enable(); }
|
||||
public void Disable() { Get().Disable(); }
|
||||
|
|
@ -1425,6 +1447,9 @@ public class @AetheriaInput : IInputActionCollection, IDisposable
|
|||
@Ping.started -= m_Wrapper.m_PlayerActionsCallbackInterface.OnPing;
|
||||
@Ping.performed -= m_Wrapper.m_PlayerActionsCallbackInterface.OnPing;
|
||||
@Ping.canceled -= m_Wrapper.m_PlayerActionsCallbackInterface.OnPing;
|
||||
@HideUI.started -= m_Wrapper.m_PlayerActionsCallbackInterface.OnHideUI;
|
||||
@HideUI.performed -= m_Wrapper.m_PlayerActionsCallbackInterface.OnHideUI;
|
||||
@HideUI.canceled -= m_Wrapper.m_PlayerActionsCallbackInterface.OnHideUI;
|
||||
}
|
||||
m_Wrapper.m_PlayerActionsCallbackInterface = instance;
|
||||
if (instance != null)
|
||||
|
|
@ -1498,6 +1523,9 @@ public class @AetheriaInput : IInputActionCollection, IDisposable
|
|||
@Ping.started += instance.OnPing;
|
||||
@Ping.performed += instance.OnPing;
|
||||
@Ping.canceled += instance.OnPing;
|
||||
@HideUI.started += instance.OnHideUI;
|
||||
@HideUI.performed += instance.OnHideUI;
|
||||
@HideUI.canceled += instance.OnHideUI;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1700,6 +1728,7 @@ public class @AetheriaInput : IInputActionCollection, IDisposable
|
|||
void OnToggleShield(InputAction.CallbackContext context);
|
||||
void OnOverrideShutdown(InputAction.CallbackContext context);
|
||||
void OnPing(InputAction.CallbackContext context);
|
||||
void OnHideUI(InputAction.CallbackContext context);
|
||||
}
|
||||
public interface IUIActions
|
||||
{
|
||||
|
|
|
|||
|
|
@ -68,12 +68,6 @@ public class ActionGameManager : MonoBehaviour
|
|||
public float TargetSpottedBlinkFrequency = 20;
|
||||
public float TargetSpottedBlinkOffset = -.25f;
|
||||
|
||||
[Header("Name Generation")]
|
||||
public TextAsset NameFile;
|
||||
public int NameGeneratorMinLength = 5;
|
||||
public int NameGeneratorMaxLength = 10;
|
||||
public int NameGeneratorOrder = 4;
|
||||
|
||||
[Header("Postprocessing")]
|
||||
public float DeathPPTransitionTime;
|
||||
public PostProcessVolume DeathPP;
|
||||
|
|
@ -81,6 +75,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
public PostProcessVolume SevereHeatstrokePP;
|
||||
|
||||
[Header("Scene Links")]
|
||||
public Transform EffectManagerParent;
|
||||
public TradeMenu TradeMenu;
|
||||
public Prototype HostileTargetIndicator;
|
||||
public PlaceUIElementWorldspace ViewDot;
|
||||
|
|
@ -91,7 +86,8 @@ public class ActionGameManager : MonoBehaviour
|
|||
[FormerlySerializedAs("SectorRenderer")] public ZoneRenderer ZoneRenderer;
|
||||
public CinemachineVirtualCamera DockCamera;
|
||||
public CinemachineVirtualCamera FollowCamera;
|
||||
public GameObject GameplayUI;
|
||||
public CinemachineVirtualCamera WormholeCamera;
|
||||
public CanvasGroup GameplayUI;
|
||||
public MenuPanel Menu;
|
||||
public MapRenderer MenuMap;
|
||||
//public SectorRenderer SectorRenderer;
|
||||
|
|
@ -101,7 +97,9 @@ public class ActionGameManager : MonoBehaviour
|
|||
public InventoryMenu Inventory;
|
||||
public InventoryPanel ShipPanel;
|
||||
public InventoryPanel TargetShipPanel;
|
||||
[FormerlySerializedAs("ConfirmationDialog")] public ConfirmationDialog Dialog;
|
||||
public ConfirmationDialog Dialog;
|
||||
|
||||
public float IntroDuration;
|
||||
|
||||
//public PlayerInput Input;
|
||||
|
||||
|
|
@ -111,7 +109,6 @@ public class ActionGameManager : MonoBehaviour
|
|||
private DirectoryInfo _loadoutPath;
|
||||
private bool _editMode;
|
||||
private float _time;
|
||||
private AetheriaInput _input;
|
||||
private int _zoomLevelIndex;
|
||||
private Entity _currentEntity;
|
||||
|
||||
|
|
@ -123,7 +120,9 @@ public class ActionGameManager : MonoBehaviour
|
|||
private Dictionary<Entity, VisibleHostileIndicator> _visibleHostileIndicators = new Dictionary<Entity, VisibleHostileIndicator>();
|
||||
private List<IDisposable> _shipSubscriptions = new List<IDisposable>();
|
||||
private float _severeHeatstrokePhase;
|
||||
private bool _uiHidden;
|
||||
|
||||
public AetheriaInput Input { get; private set; }
|
||||
public EquippedDockingBay DockingBay { get; private set; }
|
||||
public Entity DockedEntity { get; private set; }
|
||||
|
||||
|
|
@ -164,12 +163,13 @@ public class ActionGameManager : MonoBehaviour
|
|||
|
||||
public void SaveState()
|
||||
{
|
||||
PlayerSettings.CurrentRun = new SavedGame(CurrentSector, Zone, CurrentEntity);
|
||||
PlayerSettings.CurrentRun = new SavedGame(CurrentSector, Zone, DockedEntity??CurrentEntity);
|
||||
SavePlayerSettings();
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
EntityInstance.EffectManagerParent = EffectManagerParent;
|
||||
AkSoundEngine.RegisterGameObj(gameObject);
|
||||
ConsoleController.MessageReceiver = this;
|
||||
|
||||
|
|
@ -182,18 +182,18 @@ public class ActionGameManager : MonoBehaviour
|
|||
|
||||
#region Input Handling
|
||||
|
||||
_input = new AetheriaInput();
|
||||
_input.Global.Enable();
|
||||
_input.UI.Enable();
|
||||
Input = new AetheriaInput();
|
||||
Input.Global.Enable();
|
||||
Input.UI.Enable();
|
||||
|
||||
_zoomLevelIndex = Settings.DefaultMinimapZoom;
|
||||
_input.Player.MinimapZoom.performed += context =>
|
||||
Input.Player.MinimapZoom.performed += context =>
|
||||
{
|
||||
_zoomLevelIndex = (_zoomLevelIndex + 1) % Settings.MinimapZoomLevels.Length;
|
||||
ZoneRenderer.MinimapDistance = Settings.MinimapZoomLevels[_zoomLevelIndex];
|
||||
};
|
||||
|
||||
_input.Global.MapToggle.performed += context =>
|
||||
Input.Global.MapToggle.performed += context =>
|
||||
{
|
||||
if (Menu.gameObject.activeSelf && Menu.CurrentTab == MenuTab.Map)
|
||||
{
|
||||
|
|
@ -201,8 +201,8 @@ public class ActionGameManager : MonoBehaviour
|
|||
Menu.gameObject.SetActive(false);
|
||||
if (CurrentEntity != null && CurrentEntity.Parent == null)
|
||||
{
|
||||
_input.Player.Enable();
|
||||
GameplayUI.SetActive(true);
|
||||
Input.Player.Enable();
|
||||
GameplayUI.gameObject.SetActive(true);
|
||||
|
||||
SchematicDisplay.ShowShip(CurrentEntity);
|
||||
ShipPanel.Display(CurrentEntity, true);
|
||||
|
|
@ -212,13 +212,13 @@ public class ActionGameManager : MonoBehaviour
|
|||
}
|
||||
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
_input.Player.Disable();
|
||||
GameplayUI.SetActive(false);
|
||||
Input.Player.Disable();
|
||||
GameplayUI.gameObject.SetActive(false);
|
||||
Menu.ShowTab(MenuTab.Map);
|
||||
MenuMap.Position = CurrentEntity.Position.xz;
|
||||
};
|
||||
|
||||
_input.Global.Inventory.performed += context =>
|
||||
Input.Global.Inventory.performed += context =>
|
||||
{
|
||||
if (Menu.gameObject.activeSelf && Menu.CurrentTab == MenuTab.Inventory)
|
||||
{
|
||||
|
|
@ -226,8 +226,8 @@ public class ActionGameManager : MonoBehaviour
|
|||
Menu.gameObject.SetActive(false);
|
||||
if (CurrentEntity != null && CurrentEntity.Parent == null)
|
||||
{
|
||||
_input.Player.Enable();
|
||||
GameplayUI.SetActive(true);
|
||||
Input.Player.Enable();
|
||||
GameplayUI.gameObject.SetActive(true);
|
||||
|
||||
SchematicDisplay.ShowShip(CurrentEntity);
|
||||
ShipPanel.Display(CurrentEntity, true);
|
||||
|
|
@ -236,12 +236,12 @@ public class ActionGameManager : MonoBehaviour
|
|||
}
|
||||
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
_input.Player.Disable();
|
||||
Input.Player.Disable();
|
||||
Menu.ShowTab(MenuTab.Inventory);
|
||||
GameplayUI.SetActive(false);
|
||||
GameplayUI.gameObject.SetActive(false);
|
||||
};
|
||||
|
||||
_input.Global.Dock.performed += context =>
|
||||
Input.Global.Dock.performed += context =>
|
||||
{
|
||||
if (CurrentEntity == null)
|
||||
{
|
||||
|
|
@ -255,7 +255,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
else Undock();
|
||||
};
|
||||
|
||||
_input.Player.EnterWormhole.performed += context =>
|
||||
Input.Player.EnterWormhole.performed += context =>
|
||||
{
|
||||
if(CurrentEntity is Ship ship)
|
||||
{
|
||||
|
|
@ -264,10 +264,17 @@ public class ActionGameManager : MonoBehaviour
|
|||
if (length(wormhole.Position - CurrentEntity.Position.xz) < Settings.GameplaySettings.WormholeExitRadius)
|
||||
{
|
||||
var oldZone = Zone;
|
||||
// var wormholeCameraFollow = new GameObject("Wormhole Camera Follow").transform;
|
||||
// wormholeCameraFollow.position = new Vector3(wormhole.Position.x, -50, wormhole.Position.y);
|
||||
// wormholeCameraFollow.rotation = Quaternion.LookRotation(Vector3.down, ship.LookDirection);
|
||||
// WormholeCamera.enabled = true;
|
||||
// WormholeCamera.Follow = wormholeCameraFollow;
|
||||
// FollowCamera.enabled = false;
|
||||
ship.EnterWormhole(wormhole.Position);
|
||||
ship.OnEnteredWormhole += () =>
|
||||
{
|
||||
GenerateLevel(wormhole.Target);
|
||||
PopulateLevel(wormhole.Target);
|
||||
SectorMap.QueueZoneReveal(wormhole.Target.AdjacentZones);
|
||||
ship.ExitWormhole(ZoneRenderer.WormholeInstances.Keys.First(w=>w.Target==oldZone.SectorZone).Position,
|
||||
Settings.GameplaySettings.WormholeExitVelocity * ItemManager.Random.NextFloat2Direction());
|
||||
CurrentEntity.Zone = Zone;
|
||||
|
|
@ -278,23 +285,29 @@ public class ActionGameManager : MonoBehaviour
|
|||
}
|
||||
};
|
||||
|
||||
_input.Player.OverrideShutdown.performed += context =>
|
||||
Input.Player.HideUI.performed += context =>
|
||||
{
|
||||
_uiHidden = !_uiHidden;
|
||||
GameplayUI.alpha = _uiHidden ? 0 : 1;
|
||||
};
|
||||
|
||||
Input.Player.OverrideShutdown.performed += context =>
|
||||
{
|
||||
CurrentEntity.OverrideShutdown = !CurrentEntity.OverrideShutdown;
|
||||
};
|
||||
|
||||
_input.Player.Ping.performed += context =>
|
||||
Input.Player.Ping.performed += context =>
|
||||
{
|
||||
CurrentEntity.Sensor?.Ping();
|
||||
};
|
||||
|
||||
_input.Player.ToggleHeatsinks.performed += context =>
|
||||
Input.Player.ToggleHeatsinks.performed += context =>
|
||||
{
|
||||
CurrentEntity.HeatsinksEnabled = !CurrentEntity.HeatsinksEnabled;
|
||||
AkSoundEngine.PostEvent(CurrentEntity.HeatsinksEnabled ? "UI_Success" : "UI_Fail", gameObject);
|
||||
};
|
||||
|
||||
_input.Player.ToggleShield.performed += context =>
|
||||
Input.Player.ToggleShield.performed += context =>
|
||||
{
|
||||
if (CurrentEntity.Shield != null)
|
||||
{
|
||||
|
|
@ -305,27 +318,27 @@ public class ActionGameManager : MonoBehaviour
|
|||
|
||||
#region Targeting
|
||||
|
||||
_input.Player.TargetReticle.performed += context =>
|
||||
Input.Player.TargetReticle.performed += context =>
|
||||
{
|
||||
var underReticle = Zone.Entities.Where(x => x != CurrentEntity)
|
||||
.MaxBy(x => dot(normalize(x.Position - CurrentEntity.Position), CurrentEntity.LookDirection));
|
||||
CurrentEntity.Target.Value = CurrentEntity.Target.Value == underReticle ? null : underReticle;
|
||||
};
|
||||
|
||||
_input.Player.TargetNearest.performed += context =>
|
||||
Input.Player.TargetNearest.performed += context =>
|
||||
{
|
||||
CurrentEntity.Target.Value = Zone.Entities.Where(x=>x!=CurrentEntity)
|
||||
.MaxBy(x => length(x.Position - CurrentEntity.Position));
|
||||
};
|
||||
|
||||
_input.Player.TargetNext.performed += context =>
|
||||
Input.Player.TargetNext.performed += context =>
|
||||
{
|
||||
var targets = Zone.Entities.Where(x => x != CurrentEntity).OrderBy(x => length(x.Position - CurrentEntity.Position)).ToArray();
|
||||
var currentTargetIndex = Array.IndexOf(targets, CurrentEntity.Target.Value);
|
||||
CurrentEntity.Target.Value = targets[(currentTargetIndex + 1) % targets.Length];
|
||||
};
|
||||
|
||||
_input.Player.TargetPrevious.performed += context =>
|
||||
Input.Player.TargetPrevious.performed += context =>
|
||||
{
|
||||
var targets = Zone.Entities.Where(x => x != CurrentEntity).OrderBy(x => length(x.Position - CurrentEntity.Position)).ToArray();
|
||||
var currentTargetIndex = Array.IndexOf(targets, CurrentEntity.Target.Value);
|
||||
|
|
@ -337,31 +350,31 @@ public class ActionGameManager : MonoBehaviour
|
|||
|
||||
#region Trigger Groups
|
||||
|
||||
_input.Player.PreviousWeaponGroup.performed += context =>
|
||||
Input.Player.PreviousWeaponGroup.performed += context =>
|
||||
{
|
||||
if (CurrentEntity.Parent != null) return;
|
||||
SchematicDisplay.SelectedGroupIndex--;
|
||||
};
|
||||
|
||||
_input.Player.NextWeaponGroup.performed += context =>
|
||||
Input.Player.NextWeaponGroup.performed += context =>
|
||||
{
|
||||
if (CurrentEntity.Parent != null) return;
|
||||
SchematicDisplay.SelectedGroupIndex++;
|
||||
};
|
||||
|
||||
_input.Player.PreviousWeapon.performed += context =>
|
||||
Input.Player.PreviousWeapon.performed += context =>
|
||||
{
|
||||
if (CurrentEntity.Parent != null) return;
|
||||
SchematicDisplay.SelectedItemIndex--;
|
||||
};
|
||||
|
||||
_input.Player.NextWeapon.performed += context =>
|
||||
Input.Player.NextWeapon.performed += context =>
|
||||
{
|
||||
if (CurrentEntity.Parent != null) return;
|
||||
SchematicDisplay.SelectedItemIndex++;
|
||||
};
|
||||
|
||||
_input.Player.ToggleWeaponGroup.performed += context =>
|
||||
Input.Player.ToggleWeaponGroup.performed += context =>
|
||||
{
|
||||
if (CurrentEntity.Parent != null) return;
|
||||
var item = SchematicDisplay.SchematicItems[SchematicDisplay.SelectedItemIndex];
|
||||
|
|
@ -381,73 +394,73 @@ public class ActionGameManager : MonoBehaviour
|
|||
SchematicDisplay.UpdateTriggerGroups();
|
||||
};
|
||||
|
||||
_input.Player.FireGroup1.started += context =>
|
||||
Input.Player.FireGroup1.started += context =>
|
||||
{
|
||||
if (CurrentEntity.Parent != null) return;
|
||||
foreach (var s in CurrentEntity.TriggerGroups[0].weapons) s.Activate();
|
||||
};
|
||||
|
||||
_input.Player.FireGroup1.canceled += context =>
|
||||
Input.Player.FireGroup1.canceled += context =>
|
||||
{
|
||||
if (CurrentEntity.Parent != null) return;
|
||||
foreach (var s in CurrentEntity.TriggerGroups[0].weapons) s.Deactivate();
|
||||
};
|
||||
|
||||
_input.Player.FireGroup2.started += context =>
|
||||
Input.Player.FireGroup2.started += context =>
|
||||
{
|
||||
if (CurrentEntity.Parent != null) return;
|
||||
foreach (var s in CurrentEntity.TriggerGroups[1].weapons) s.Activate();
|
||||
};
|
||||
|
||||
_input.Player.FireGroup2.canceled += context =>
|
||||
Input.Player.FireGroup2.canceled += context =>
|
||||
{
|
||||
if (CurrentEntity.Parent != null) return;
|
||||
foreach (var s in CurrentEntity.TriggerGroups[1].weapons) s.Deactivate();
|
||||
};
|
||||
|
||||
_input.Player.FireGroup3.started += context =>
|
||||
Input.Player.FireGroup3.started += context =>
|
||||
{
|
||||
if (CurrentEntity.Parent != null) return;
|
||||
foreach (var s in CurrentEntity.TriggerGroups[2].weapons) s.Activate();
|
||||
};
|
||||
|
||||
_input.Player.FireGroup3.canceled += context =>
|
||||
Input.Player.FireGroup3.canceled += context =>
|
||||
{
|
||||
if (CurrentEntity.Parent != null) return;
|
||||
foreach (var s in CurrentEntity.TriggerGroups[2].weapons) s.Deactivate();
|
||||
};
|
||||
|
||||
_input.Player.FireGroup4.started += context =>
|
||||
Input.Player.FireGroup4.started += context =>
|
||||
{
|
||||
if (CurrentEntity.Parent != null) return;
|
||||
foreach (var s in CurrentEntity.TriggerGroups[3].weapons) s.Activate();
|
||||
};
|
||||
|
||||
_input.Player.FireGroup4.canceled += context =>
|
||||
Input.Player.FireGroup4.canceled += context =>
|
||||
{
|
||||
if (CurrentEntity.Parent != null) return;
|
||||
foreach (var s in CurrentEntity.TriggerGroups[3].weapons) s.Deactivate();
|
||||
};
|
||||
|
||||
_input.Player.FireGroup5.started += context =>
|
||||
Input.Player.FireGroup5.started += context =>
|
||||
{
|
||||
if (CurrentEntity.Parent != null) return;
|
||||
foreach (var s in CurrentEntity.TriggerGroups[4].weapons) s.Activate();
|
||||
};
|
||||
|
||||
_input.Player.FireGroup5.canceled += context =>
|
||||
Input.Player.FireGroup5.canceled += context =>
|
||||
{
|
||||
if (CurrentEntity.Parent != null) return;
|
||||
foreach (var s in CurrentEntity.TriggerGroups[4].weapons) s.Deactivate();
|
||||
};
|
||||
|
||||
_input.Player.FireGroup6.started += context =>
|
||||
Input.Player.FireGroup6.started += context =>
|
||||
{
|
||||
if (CurrentEntity.Parent != null) return;
|
||||
foreach (var s in CurrentEntity.TriggerGroups[5].weapons) s.Activate();
|
||||
};
|
||||
|
||||
_input.Player.FireGroup6.canceled += context =>
|
||||
Input.Player.FireGroup6.canceled += context =>
|
||||
{
|
||||
if (CurrentEntity.Parent != null) return;
|
||||
foreach (var s in CurrentEntity.TriggerGroups[5].weapons) s.Deactivate();
|
||||
|
|
@ -458,9 +471,81 @@ public class ActionGameManager : MonoBehaviour
|
|||
#endregion
|
||||
|
||||
StartGame();
|
||||
|
||||
ConsoleController.AddCommand("give",
|
||||
args =>
|
||||
{
|
||||
var itemName = string.Join(" ", args);
|
||||
var item = ItemManager.ItemData.GetAll<EquippableItemData>()
|
||||
.FirstOrDefault(itemData => string.Equals(itemData.Name, itemName, StringComparison.InvariantCultureIgnoreCase));
|
||||
if (item != null)
|
||||
{
|
||||
_currentEntity.CargoBays.First().TryStore(ItemManager.CreateInstance(item, .95f));
|
||||
}
|
||||
});
|
||||
|
||||
ConsoleController.AddCommand("trackmissile",
|
||||
_ =>
|
||||
{
|
||||
foreach (var missileManager in FindObjectsOfType<GuidedProjectileManager>())
|
||||
{
|
||||
missileManager.OnFireGuided.Where(x => x.source == _currentEntity).Take(1).Subscribe(x =>
|
||||
{
|
||||
FollowCamera.Follow = x.missile.transform;
|
||||
FollowCamera.LookAt = x.target;
|
||||
x.missile.OnKill += () =>
|
||||
{
|
||||
FollowCamera.LookAt = ZoneRenderer.EntityInstances[CurrentEntity].LookAtPoint;
|
||||
FollowCamera.Follow = ZoneRenderer.EntityInstances[CurrentEntity].transform;
|
||||
};
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
ConsoleController.AddCommand("pingscene",
|
||||
_ =>
|
||||
{
|
||||
var startTime = Time.time;
|
||||
Observable.EveryUpdate().TakeWhile(_ => Time.time - startTime < 5).Subscribe(
|
||||
_ => Debug.Log($"{(int) (Time.time - startTime)}"),
|
||||
() =>
|
||||
{
|
||||
var nearestFaction = CurrentSector.Factions.MinBy(f => CurrentSector.HomeZones[f].Distance[Zone.SectorZone]);
|
||||
var nearestFactionHomeZone = CurrentSector.HomeZones[nearestFaction];
|
||||
var factionPresence = nearestFaction.InfluenceDistance - nearestFactionHomeZone.Distance[Zone.SectorZone] + 1;
|
||||
|
||||
var loadoutGenerator = new LoadoutGenerator(
|
||||
ref ItemManager.Random,
|
||||
ItemManager,
|
||||
CurrentSector,
|
||||
Zone.SectorZone,
|
||||
nearestFaction,
|
||||
.5f);
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
var ship = EntitySerializer.Unpack(ItemManager, Zone, loadoutGenerator.GenerateShipLoadout(), true);
|
||||
ship.Position.xz = _currentEntity.Position.xz +
|
||||
ItemManager.Random.NextFloat2Direction() * ItemManager.Random.NextFloat(50, 500);
|
||||
ship.Zone = Zone;
|
||||
Zone.Entities.Add(ship);
|
||||
ship.Activate();
|
||||
}
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
var turret = EntitySerializer.Unpack(ItemManager, Zone, loadoutGenerator.GenerateTurretLoadout(), true);
|
||||
turret.Position.xz = _currentEntity.Position.xz +
|
||||
ItemManager.Random.NextFloat2Direction() * ItemManager.Random.NextFloat(50, 500);
|
||||
turret.Zone = Zone;
|
||||
Zone.Entities.Add(turret);
|
||||
turret.Activate();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public void GenerateLevel(SectorZone sectorZone)
|
||||
public void PopulateLevel(SectorZone sectorZone)
|
||||
{
|
||||
if (sectorZone == null) throw new ArgumentNullException(nameof(sectorZone));
|
||||
|
||||
|
|
@ -502,7 +587,8 @@ public class ActionGameManager : MonoBehaviour
|
|||
{
|
||||
if (PlayerSettings.CurrentRun == null)
|
||||
{
|
||||
GenerateLevel(CurrentSector.Entrance);
|
||||
SectorMap.QueueZoneReveal(CurrentSector.Entrance.AdjacentZones.Prepend(CurrentSector.Entrance));
|
||||
PopulateLevel(CurrentSector.Entrance);
|
||||
var loadoutGenerator = new LoadoutGenerator(ref ItemManager.Random, ItemManager, CurrentSector, Zone.SectorZone, null, 2);
|
||||
var ship = EntitySerializer.Unpack(ItemManager, Zone, loadoutGenerator.GenerateShipLoadout(), true);
|
||||
// EntitySerializer.Unpack(ItemManager, Zone, Loadouts.First(x => x.Name == StarterShipTemplate), true);
|
||||
|
|
@ -515,16 +601,48 @@ public class ActionGameManager : MonoBehaviour
|
|||
}
|
||||
else
|
||||
{
|
||||
GenerateLevel(CurrentSector.Zones[PlayerSettings.CurrentRun.CurrentZone]);
|
||||
PopulateLevel(CurrentSector.Zones[PlayerSettings.CurrentRun.CurrentZone]);
|
||||
var targetEntity = Zone.Entities[PlayerSettings.CurrentRun.CurrentZoneEntity];
|
||||
if (targetEntity is OrbitalEntity orbitalEntity)
|
||||
DoDock(orbitalEntity, orbitalEntity.DockingBays.First());
|
||||
else
|
||||
{
|
||||
//StartCoroutine(IntroCutscene(targetEntity as Ship));
|
||||
BindToEntity(targetEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator IntroCutscene(Ship ship)
|
||||
{
|
||||
ZoneRenderer.PerspectiveEntity = ship;
|
||||
var entityPosition = ship.Position.xz;
|
||||
var followOrbit = Zone.Orbits.Keys.MinBy(o => lengthsq(Zone.GetOrbitPosition(o) - entityPosition));
|
||||
var followPlanet = ZoneRenderer.Planets[Zone.Planets.FirstOrDefault(p => p.Value.Orbit == followOrbit).Key];
|
||||
DockCamera.Follow = followPlanet.Body.transform;
|
||||
var rootOrbit = followOrbit;
|
||||
while (Zone.Orbits[rootOrbit].Data.Parent != Guid.Empty)
|
||||
rootOrbit = Zone.Orbits[rootOrbit].Data.Parent;
|
||||
var rootPlanet = ZoneRenderer.Planets[Zone.Planets.FirstOrDefault(p => p.Value.Orbit == rootOrbit).Key];
|
||||
DockCamera.LookAt = rootPlanet.Body.transform;
|
||||
|
||||
var shipVelocity = ship.GetBehavior<VelocityLimit>().Limit;
|
||||
var followOrbitPosition = Zone.GetOrbitPosition(followOrbit);
|
||||
var shipDirection = normalize(Zone.GetOrbitPosition(rootOrbit) - followOrbitPosition);
|
||||
ship.Position.xz = followOrbitPosition - shipDirection * shipVelocity * IntroDuration;
|
||||
|
||||
var startTime = Time.time;
|
||||
while (Time.time - startTime < IntroDuration)
|
||||
{
|
||||
ship.Direction = shipDirection;
|
||||
ship.Velocity = shipDirection * shipVelocity;
|
||||
yield return null;
|
||||
}
|
||||
|
||||
BindToEntity(ship);
|
||||
}
|
||||
|
||||
public void Dock()
|
||||
{
|
||||
if (CurrentEntity.Parent != null) return;
|
||||
|
|
@ -560,8 +678,10 @@ public class ActionGameManager : MonoBehaviour
|
|||
var orbital = (OrbitalEntity) entity;
|
||||
DockCamera.Follow = ZoneRenderer.EntityInstances[orbital].transform;
|
||||
var parentOrbit = Zone.Orbits[orbital.OrbitData].Data.Parent;
|
||||
var parentPlanet = ZoneRenderer.Planets[Zone.Planets.FirstOrDefault(p => p.Value.Orbit == parentOrbit).Key];
|
||||
DockCamera.LookAt = parentPlanet.Body.transform;
|
||||
var parentOrbitPlanet = Zone.Planets.FirstOrDefault(p => p.Value.Orbit == parentOrbit).Key;
|
||||
if (ZoneRenderer.Planets.ContainsKey(parentOrbitPlanet))
|
||||
DockCamera.LookAt = ZoneRenderer.Planets[parentOrbitPlanet].Body.transform;
|
||||
else DockCamera.LookAt = ZoneRenderer.ZoneRoot;
|
||||
Menu.ShowTab(MenuTab.Inventory);
|
||||
}
|
||||
|
||||
|
|
@ -619,9 +739,9 @@ public class ActionGameManager : MonoBehaviour
|
|||
_visibleHostileIndicators.Clear();
|
||||
if(_lockingIndicators!=null) foreach(var (_, indicator, _) in _lockingIndicators)
|
||||
indicator.GetComponent<Prototype>().ReturnToPool();
|
||||
_input.Player.Disable();
|
||||
Input.Player.Disable();
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
GameplayUI.SetActive(false);
|
||||
GameplayUI.gameObject.SetActive(false);
|
||||
|
||||
foreach(var subscription in _shipSubscriptions) subscription.Dispose();
|
||||
_shipSubscriptions.Clear();
|
||||
|
|
@ -649,8 +769,8 @@ public class ActionGameManager : MonoBehaviour
|
|||
_viewDirection = float3(CurrentEntity.Direction.x,0,CurrentEntity.Direction.y);
|
||||
|
||||
Cursor.lockState = CursorLockMode.Locked;
|
||||
GameplayUI.SetActive(true);
|
||||
_input.Player.Enable();
|
||||
Input.Player.Enable();
|
||||
GameplayUI.gameObject.SetActive(true);
|
||||
ShipPanel.Display(CurrentEntity, true);
|
||||
SchematicDisplay.ShowShip(CurrentEntity);
|
||||
|
||||
|
|
@ -706,24 +826,25 @@ public class ActionGameManager : MonoBehaviour
|
|||
var deathTime = Time.time;
|
||||
UnbindEntity();
|
||||
CurrentEntity = null;
|
||||
Dialog.Clear();
|
||||
Dialog.Title.text = "You have died!";
|
||||
Dialog.Show(() =>
|
||||
{
|
||||
PlayerSettings.CurrentRun = null;
|
||||
StartGame();
|
||||
}, null, "Try again!");
|
||||
Dialog.transform.position = new Vector3(Screen.width / 2, Screen.height / 2);
|
||||
// Dialog.Clear();
|
||||
// Dialog.Title.text = "You have died!";
|
||||
// Dialog.Show(() =>
|
||||
// {
|
||||
// PlayerSettings.CurrentRun = null;
|
||||
// StartGame();
|
||||
// }, null, "Try again!");
|
||||
// Dialog.transform.position = new Vector3(Screen.width / 2, Screen.height / 2);
|
||||
//Dialog.MoveToCursor();
|
||||
Observable.EveryUpdate()
|
||||
.Select(_ => (Time.time - deathTime) / DeathPPTransitionTime)
|
||||
.Where(t => t < 1)
|
||||
.Subscribe(t =>
|
||||
.Where(_ => Time.time - deathTime < DeathPPTransitionTime)
|
||||
.Subscribe(_ =>
|
||||
{
|
||||
var t = (Time.time - deathTime) / DeathPPTransitionTime;
|
||||
HeatstrokePP.weight = 1 - t;
|
||||
SevereHeatstrokePP.weight = 1 - t;
|
||||
DeathPP.weight = t;
|
||||
}, () =>
|
||||
},
|
||||
() =>
|
||||
{
|
||||
HeatstrokePP.weight = 0;
|
||||
SevereHeatstrokePP.weight = 0;
|
||||
|
|
@ -789,7 +910,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
!(indicator.Key.EntityInfoGathered[CurrentEntity] > Settings.GameplaySettings.TargetDetectionInfoThreshold) ||
|
||||
sin(TargetSpottedBlinkFrequency * Time.time) + TargetSpottedBlinkOffset > 0;
|
||||
}
|
||||
var look = _input.Player.Look.ReadValue<Vector2>();
|
||||
var look = Input.Player.Look.ReadValue<Vector2>();
|
||||
_entityYawPitch = float2(_entityYawPitch.x + look.x * Sensitivity.x, clamp(_entityYawPitch.y + look.y * Sensitivity.y, -.45f * PI, .45f * PI));
|
||||
_viewDirection = mul(float3(0, 0, 1), Unity.Mathematics.float3x3.Euler(float3(_entityYawPitch.yx, 0), RotationOrder.YXZ));
|
||||
CurrentEntity.LookDirection = _viewDirection;
|
||||
|
|
@ -801,12 +922,11 @@ public class ActionGameManager : MonoBehaviour
|
|||
|
||||
if(CurrentEntity is Ship ship)
|
||||
{
|
||||
ship.MovementDirection = _input.Player.Move.ReadValue<Vector2>();
|
||||
ship.MovementDirection = Input.Player.Move.ReadValue<Vector2>();
|
||||
}
|
||||
}
|
||||
}
|
||||
Zone.Update(_time, Time.deltaTime);
|
||||
ZoneRenderer.GameTime = _time;
|
||||
Zone.Update(Time.deltaTime);
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
|
|
|
|||
|
|
@ -236,20 +236,20 @@ public class EntityInstance : MonoBehaviour
|
|||
}
|
||||
}
|
||||
}
|
||||
if(hp.Type == HardpointType.Reactor)
|
||||
{
|
||||
var reactorHardpoint = EquipmentHardpoints.FirstOrDefault(x => x.name == hp.Transform);
|
||||
if (reactorHardpoint)
|
||||
{
|
||||
var reactor = item.GetBehavior<Reactor>();
|
||||
if( reactor != null && !string.IsNullOrEmpty(item.Data.SoundEffectTrigger) )
|
||||
{
|
||||
AkSoundEngine.RegisterGameObj(reactorHardpoint.gameObject);
|
||||
AkSoundEngine.PostEvent(item.Data.SoundEffectTrigger, reactorHardpoint.gameObject);
|
||||
_reactor = (reactor, reactorHardpoint.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
// if(hp.Type == HardpointType.Reactor)
|
||||
// {
|
||||
// var reactorHardpoint = EquipmentHardpoints.FirstOrDefault(x => x.name == hp.Transform);
|
||||
// if (reactorHardpoint)
|
||||
// {
|
||||
// var reactor = item.GetBehavior<Reactor>();
|
||||
// if( reactor != null && !string.IsNullOrEmpty(item.Data.SoundEffectTrigger) )
|
||||
// {
|
||||
// AkSoundEngine.RegisterGameObj(reactorHardpoint.gameObject);
|
||||
// AkSoundEngine.PostEvent(item.Data.SoundEffectTrigger, reactorHardpoint.gameObject);
|
||||
// _reactor = (reactor, reactorHardpoint.gameObject);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
RadiatorMeshes = new Dictionary<Radiator, MeshRenderer>();
|
||||
|
|
@ -356,6 +356,7 @@ public class EntityInstance : MonoBehaviour
|
|||
{
|
||||
distance = cellDist;
|
||||
hitCell = v;
|
||||
hitPos = v + float2(.5f);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -383,14 +384,15 @@ public class EntityInstance : MonoBehaviour
|
|||
// Find the local 2D vector corresponding to the direction of the incoming hit
|
||||
var localHitDirection = transform.InverseTransformDirection(hit.Direction);
|
||||
var penetrationVector = normalize(float2(localHitDirection.x, localHitDirection.z));
|
||||
|
||||
// TODO: Bresenham's line algorithm
|
||||
// March a ray through the ship from the hit position
|
||||
var penetrationPoint = hitPos;
|
||||
var penetrationDistance = 0;
|
||||
while (penetrationDistance < hit.Penetration)
|
||||
var penetrationDistance = 0f;
|
||||
while (penetrationDistance < hit.Penetration && hullData.Shape[int2(penetrationPoint)])
|
||||
{
|
||||
penetrationPoint += penetrationVector * .5f;
|
||||
penetrationDistance += .5f;
|
||||
hitShape[int2(penetrationPoint)] = true;
|
||||
penetrationPoint += penetrationVector * .5f;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -496,15 +498,15 @@ public class EntityInstance : MonoBehaviour
|
|||
AkSoundEngine.SetRTPCValue("performance_quality", r.Key.Item.EquippableItem.Quality, r.Value);
|
||||
}
|
||||
|
||||
if (_reactor.reactor != null)
|
||||
{
|
||||
_reactor.sfxSource.SetActive(_reactor.reactor.Item.Online.Value);
|
||||
AkSoundEngine.SetObjectPosition(_reactor.sfxSource, _reactor.sfxSource.transform);
|
||||
AkSoundEngine.SetRTPCValue("reactor_load", _reactor.reactor.CurrentLoadRatio, _reactor.sfxSource);
|
||||
AkSoundEngine.SetRTPCValue("performance_durability", _reactor.reactor.Item.DurabilityPerformance, _reactor.sfxSource);
|
||||
AkSoundEngine.SetRTPCValue("performance_thermal", _reactor.reactor.Item.ThermalPerformance, _reactor.sfxSource);
|
||||
AkSoundEngine.SetRTPCValue("performance_quality", _reactor.reactor.Item.EquippableItem.Quality, _reactor.sfxSource);
|
||||
}
|
||||
// if (_reactor.reactor != null)
|
||||
// {
|
||||
// _reactor.sfxSource.SetActive(_reactor.reactor.Item.Online.Value);
|
||||
// AkSoundEngine.SetObjectPosition(_reactor.sfxSource, _reactor.sfxSource.transform);
|
||||
// AkSoundEngine.SetRTPCValue("reactor_load", _reactor.reactor.CurrentLoadRatio, _reactor.sfxSource);
|
||||
// AkSoundEngine.SetRTPCValue("performance_durability", _reactor.reactor.Item.DurabilityPerformance, _reactor.sfxSource);
|
||||
// AkSoundEngine.SetRTPCValue("performance_thermal", _reactor.reactor.Item.ThermalPerformance, _reactor.sfxSource);
|
||||
// AkSoundEngine.SetRTPCValue("performance_quality", _reactor.reactor.Item.EquippableItem.Quality, _reactor.sfxSource);
|
||||
// }
|
||||
|
||||
foreach (var x in RadiatorMeshes)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -35,11 +35,11 @@ public class ShipInstance : EntityInstance
|
|||
var thrusterHardpoint = ThrusterHardpoints
|
||||
.FirstOrDefault(t => t.name == thruster.Entity.Hardpoints[thruster.Item.Position.x, thruster.Item.Position.y].Transform);
|
||||
particlesShape.meshRenderer = thrusterHardpoint?.Emitter;
|
||||
if (!string.IsNullOrEmpty(thruster.Item.Data.SoundEffectTrigger) && thrusterHardpoint != null)
|
||||
{
|
||||
AkSoundEngine.RegisterGameObj(thrusterHardpoint.gameObject);
|
||||
AkSoundEngine.PostEvent(thruster.Item.Data.SoundEffectTrigger, thrusterHardpoint.gameObject);
|
||||
}
|
||||
// if (!string.IsNullOrEmpty(thruster.Item.Data.SoundEffectTrigger) && thrusterHardpoint != null)
|
||||
// {
|
||||
// AkSoundEngine.RegisterGameObj(thrusterHardpoint.gameObject);
|
||||
// AkSoundEngine.PostEvent(thruster.Item.Data.SoundEffectTrigger, thrusterHardpoint.gameObject);
|
||||
// }
|
||||
|
||||
return new ThrusterInstance
|
||||
{
|
||||
|
|
@ -87,17 +87,17 @@ public class ShipInstance : EntityInstance
|
|||
var data = Entity.ItemManager.GetData(item);
|
||||
thrusterInstance.MaxParticleCount = thrusterInstance.System.particleCount;
|
||||
emissionModule.rateOverTimeMultiplier = thrusterInstance.BaseEmission * thrusterInstance.Thruster.Axis * (item.Durability / data.Durability);
|
||||
if (thrusterInstance.SfxSource)
|
||||
{
|
||||
var throttle = 0f;
|
||||
if (thrusterInstance.System.particleCount > 0)
|
||||
throttle = (float) thrusterInstance.System.particleCount / thrusterInstance.MaxParticleCount;
|
||||
AkSoundEngine.SetObjectPosition(thrusterInstance.SfxSource, thrusterInstance.SfxSource.transform);
|
||||
AkSoundEngine.SetRTPCValue("thruster_throttle", throttle, thrusterInstance.SfxSource);
|
||||
AkSoundEngine.SetRTPCValue("performance_durability", thrusterInstance.Thruster.Item.DurabilityPerformance, thrusterInstance.SfxSource);
|
||||
AkSoundEngine.SetRTPCValue("performance_thermal", thrusterInstance.Thruster.Item.ThermalPerformance, thrusterInstance.SfxSource);
|
||||
AkSoundEngine.SetRTPCValue("performance_quality", thrusterInstance.Thruster.Item.EquippableItem.Quality, thrusterInstance.SfxSource);
|
||||
}
|
||||
// if (thrusterInstance.SfxSource)
|
||||
// {
|
||||
// var throttle = 0f;
|
||||
// if (thrusterInstance.System.particleCount > 0)
|
||||
// throttle = (float) thrusterInstance.System.particleCount / thrusterInstance.MaxParticleCount;
|
||||
// AkSoundEngine.SetObjectPosition(thrusterInstance.SfxSource, thrusterInstance.SfxSource.transform);
|
||||
// AkSoundEngine.SetRTPCValue("thruster_throttle", throttle, thrusterInstance.SfxSource);
|
||||
// AkSoundEngine.SetRTPCValue("performance_durability", thrusterInstance.Thruster.Item.DurabilityPerformance, thrusterInstance.SfxSource);
|
||||
// AkSoundEngine.SetRTPCValue("performance_thermal", thrusterInstance.Thruster.Item.ThermalPerformance, thrusterInstance.SfxSource);
|
||||
// AkSoundEngine.SetRTPCValue("performance_quality", thrusterInstance.Thruster.Item.EquippableItem.Quality, thrusterInstance.SfxSource);
|
||||
// }
|
||||
}
|
||||
|
||||
transform.rotation = Ship.Rotation;
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ using static Unity.Mathematics.math;
|
|||
using static Unity.Mathematics.noise;
|
||||
using Random = UnityEngine.Random;
|
||||
using static Noise1D;
|
||||
using float3 = Unity.Mathematics.float3;
|
||||
|
||||
public class GuidedProjectile : MonoBehaviour
|
||||
{
|
||||
|
|
@ -31,6 +32,8 @@ public class GuidedProjectile : MonoBehaviour
|
|||
private float _prevDist;
|
||||
private bool _active;
|
||||
private bool _alive;
|
||||
private Vector3 _targetVelocity;
|
||||
private Vector3 _previousTargetPosition;
|
||||
|
||||
public Transform Target { get; set; }
|
||||
public float3 StartPosition { get; set; }
|
||||
|
|
@ -42,6 +45,8 @@ public class GuidedProjectile : MonoBehaviour
|
|||
public DamageType DamageType { get; set; }
|
||||
public Entity SourceEntity { get; set; }
|
||||
|
||||
public event Action OnKill;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
_active = _alive = true;
|
||||
|
|
@ -67,12 +72,15 @@ public class GuidedProjectile : MonoBehaviour
|
|||
StartCoroutine(FadeOut());
|
||||
return;
|
||||
}
|
||||
var position = (float3) t.position;
|
||||
|
||||
var targetPosition = TargetPosition?.Invoke() ?? Target.position;
|
||||
_targetVelocity = lerp(_targetVelocity, targetPosition - _previousTargetPosition, saturate(Time.deltaTime * 5));
|
||||
_previousTargetPosition = targetPosition;
|
||||
targetPosition = AetheriaMath.FirstOrderIntercept(position,float3.zero, TopSpeed, targetPosition, _targetVelocity);
|
||||
|
||||
var diff = targetPosition - transform.position;
|
||||
var targetDist = diff.magnitude;
|
||||
var position = (float3) t.position;
|
||||
var sourceDist = length(StartPosition.xz - position.xz);
|
||||
|
||||
if (sourceDist > Range || dot(diff,Velocity) < 0)
|
||||
|
|
@ -212,6 +220,7 @@ public class GuidedProjectile : MonoBehaviour
|
|||
{
|
||||
yield return null;
|
||||
}
|
||||
OnKill?.Invoke();
|
||||
GetComponent<Prototype>().ReturnToPool();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
using System.Collections;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UniRx;
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine;
|
||||
using static Unity.Mathematics.math;
|
||||
|
|
@ -8,6 +10,8 @@ public class GuidedProjectileManager : InstantWeaponEffectManager
|
|||
{
|
||||
public Prototype ProjectilePrototype;
|
||||
|
||||
public Subject<(Entity source, Transform target, GuidedProjectile missile)> OnFireGuided = new Subject<(Entity source, Transform target, GuidedProjectile missile)>();
|
||||
|
||||
public override void Fire(InstantWeapon weapon, EquippedItem item, EntityInstance source, EntityInstance target)
|
||||
{
|
||||
if(weapon.Data is LauncherData launcher)
|
||||
|
|
@ -32,6 +36,7 @@ public class GuidedProjectileManager : InstantWeaponEffectManager
|
|||
p.Velocity = barrel.forward * weapon.Velocity;
|
||||
p.Thrust = item.Evaluate(launcher.Thrust);
|
||||
p.TopSpeed = item.Evaluate(launcher.MissileVelocity);
|
||||
OnFireGuided.OnNext((source.Entity, target.transform, p));
|
||||
}
|
||||
else if(weapon.Data is GuidedWeaponData guidance)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class HitscanManager : InstantWeaponEffectManager
|
||||
{
|
||||
public Prototype Prototype;
|
||||
|
|
@ -8,8 +10,12 @@ public class HitscanManager : InstantWeaponEffectManager
|
|||
var hp = source.Entity.Hardpoints[item.Position.x, item.Position.y];
|
||||
var barrel = source.GetBarrel(hp);
|
||||
var t = p.transform;
|
||||
t.position = barrel.position;
|
||||
t.forward = barrel.forward;
|
||||
t.SetParent(barrel, false);
|
||||
t.localRotation = Quaternion.identity;
|
||||
t.localPosition = Vector3.zero;
|
||||
// t.position = barrel.position;
|
||||
// t.forward = barrel.forward;
|
||||
p.Range = weapon.Range;
|
||||
p.Damage = weapon.Damage;
|
||||
p.Penetration = weapon.Penetration;
|
||||
p.Spread = weapon.DamageSpread;
|
||||
|
|
|
|||
|
|
@ -178,8 +178,8 @@ public class InstantWeapon : Weapon, IProgressBehavior, IEventBehavior
|
|||
|
||||
public override void Activate()
|
||||
{
|
||||
if(CanFire)
|
||||
Trigger();
|
||||
base.Activate();
|
||||
// if(CanFire)
|
||||
// Trigger();
|
||||
// base.Activate();
|
||||
}
|
||||
}
|
||||
|
|
@ -38,6 +38,7 @@ public class VelocityLimit : IBehavior
|
|||
_data = data;
|
||||
Entity = entity;
|
||||
Item = item;
|
||||
Limit = Item.Evaluate(_data.TopSpeed);
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
|
|
|
|||
|
|
@ -135,8 +135,8 @@ public abstract class Entity
|
|||
if(behavior is IInitializableBehavior initializableBehavior)
|
||||
initializableBehavior.Initialize();
|
||||
}
|
||||
//foreach(var entity in Zone.Entities) EntityInfoGathered.Add(entity, 0);
|
||||
_subscriptions.Add(Zone.Entities.ObserveAdd().Subscribe(add => EntityInfoGathered.Add(add.Value, 0)));
|
||||
foreach(var entity in Zone.Entities) EntityInfoGathered[entity] = 0;
|
||||
_subscriptions.Add(Zone.Entities.ObserveAdd().Subscribe(add => EntityInfoGathered[add.Value] = 0));
|
||||
_subscriptions.Add(Zone.Entities.ObserveRemove().Subscribe(remove =>
|
||||
{
|
||||
if (Target.Value == remove.Value) Target.Value = null;
|
||||
|
|
|
|||
|
|
@ -166,7 +166,8 @@ public class ItemManager
|
|||
pow(item.Quality, GameplaySettings.DurabilityQualityExponent));
|
||||
var durability = pow(item.Durability / data.Durability, durabilityExponent * stat.DurabilityExponentMultiplier);
|
||||
var result = lerp(stat.Min, stat.Max, quality * durability);
|
||||
if (float.IsNaN(result)) throw new InvalidOperationException("Performance Stat evaluating as NaN: input data is invalid!");
|
||||
if (float.IsNaN(result))
|
||||
throw new InvalidOperationException($"Performance Stat on {data.Name} evaluating as NaN: input data is invalid! Durability: {item.Durability} / {data.Durability}");
|
||||
return result;
|
||||
|
||||
}
|
||||
|
|
@ -211,6 +212,27 @@ public class ItemManager
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public CraftedItemInstance CreateInstance(CraftedItemData item, float quality)
|
||||
{
|
||||
if (item is EquippableItemData equippableItemData)
|
||||
{
|
||||
var newGear = new EquippableItem
|
||||
{
|
||||
Data = item.ID,
|
||||
Quality = quality
|
||||
};
|
||||
newGear.Durability = equippableItemData.Durability;
|
||||
return newGear;
|
||||
}
|
||||
|
||||
var newCommodity = new CompoundCommodity
|
||||
{
|
||||
Data = item.ID,
|
||||
Quality = quality
|
||||
};
|
||||
return newCommodity;
|
||||
}
|
||||
|
||||
public CraftedItemInstance CreateInstance(CraftedItemData item)
|
||||
{
|
||||
|
|
@ -227,24 +249,8 @@ public class ItemManager
|
|||
if (t.Rarity > quality)
|
||||
tier = t;
|
||||
}
|
||||
|
||||
if (item is EquippableItemData equippableItemData)
|
||||
{
|
||||
var newGear = new EquippableItem
|
||||
{
|
||||
Data = item.ID,
|
||||
Quality = tier.Quality
|
||||
};
|
||||
newGear.Durability = equippableItemData.Durability;
|
||||
return newGear;
|
||||
}
|
||||
|
||||
var newCommodity = new CompoundCommodity
|
||||
{
|
||||
Data = item.ID,
|
||||
Quality = tier.Quality
|
||||
};
|
||||
return newCommodity;
|
||||
return CreateInstance(item, tier.Quality);
|
||||
}
|
||||
|
||||
public (RarityTier tier, int upgrades) GetTier(CraftedItemInstance item)
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ public class LoadoutGenerator
|
|||
{
|
||||
return ItemManager.ItemData.GetAll<T>()
|
||||
.Where(item => Sector.ContainsFaction(item.Manufacturer) &&
|
||||
(Faction == null || item.Manufacturer == Faction.ID || Faction.Allegiance.ContainsKey(item.Manufacturer)) &&
|
||||
(Faction == null || Faction.Allegiance.ContainsKey(item.Manufacturer)) &&
|
||||
(filter?.Invoke(item) ?? true))
|
||||
.WeightedRandomElements(ref Random, item =>
|
||||
(Faction == null || item.Manufacturer == Faction.ID ? 1 : Faction.Allegiance[item.Manufacturer]) * // Prioritize items from allied manufacturers
|
||||
|
|
@ -133,7 +133,8 @@ public class LoadoutGenerator
|
|||
{
|
||||
var controllerData = RandomItem<GearData>(hardpoint, 2,
|
||||
item => item.Behaviors.Any(b => entity is Ship && b is CockpitData || entity is OrbitalEntity && b is TurretControllerData));
|
||||
if (controllerData == null) throw new InvalidLoadoutException("No compatible controller found for entity!");
|
||||
if (controllerData == null)
|
||||
throw new InvalidLoadoutException("No compatible controller found for entity!");
|
||||
var controller = ItemManager.CreateInstance(controllerData) as EquippableItem;
|
||||
if (!entity.TryEquip(controller))
|
||||
{
|
||||
|
|
@ -145,12 +146,16 @@ public class LoadoutGenerator
|
|||
// If a previously selected item fits, use that one (this is why we must process larger hardpoints first)
|
||||
var itemData = previousItems
|
||||
.FirstOrDefault(i => i.HardpointType == hardpoint.Type && i.Shape.FitsWithin(hardpoint.Shape, hardpoint.Rotation, out _));
|
||||
var previousItem = entity.Equipment.FirstOrDefault(item => item.Data == itemData);
|
||||
itemData ??= RandomItem<GearData>(hardpoint, 2);
|
||||
if (itemData == null) ItemManager.Log($"No compatible item found for entity {Enum.GetName(typeof(HardpointType), hardpoint.Type)} hardpoint!");
|
||||
else
|
||||
{
|
||||
//throw new InvalidLoadoutException($"No compatible item found for entity {Enum.GetName(typeof(HardpointType), hardpoint.Type)} hardpoint!");
|
||||
var item = ItemManager.CreateInstance(itemData) as EquippableItem;
|
||||
EquippableItem item;
|
||||
if(previousItem!=null)
|
||||
item = ItemManager.CreateInstance(itemData, previousItem.EquippableItem.Quality) as EquippableItem;
|
||||
else item = ItemManager.CreateInstance(itemData) as EquippableItem;
|
||||
if (!entity.TryEquip(item))
|
||||
{
|
||||
throw new InvalidLoadoutException($"Failed to equip selected {Enum.GetName(typeof(HardpointType), hardpoint.Type)}!");
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ public class Ship : Entity
|
|||
|
||||
public void EnterWormhole(float2 wormholePosition)
|
||||
{
|
||||
Target.Value = null;
|
||||
_wormholeAnimationProgress = 0;
|
||||
_enteringWormhole = true;
|
||||
_wormholeEntryPosition = Position.xz;
|
||||
|
|
|
|||
|
|
@ -30,17 +30,22 @@ public class Zone
|
|||
private HashSet<Guid> _updatedOrbits = new HashSet<Guid>();
|
||||
|
||||
private ItemManager _itemManager;
|
||||
private float _time;
|
||||
private double _time;
|
||||
private Random _random;
|
||||
public List<Agent> Agents = new List<Agent>();
|
||||
|
||||
private List<Task> BeltUpdates = new List<Task>();
|
||||
|
||||
public float Time
|
||||
{
|
||||
get => (float) _time;
|
||||
}
|
||||
public ZonePack Pack { get; }
|
||||
public SectorZone SectorZone { get; }
|
||||
|
||||
public Zone(ItemManager itemManager, PlanetSettings settings, ZonePack pack, SectorZone sectorZone)
|
||||
{
|
||||
_time = pack.Time;
|
||||
SectorZone = sectorZone;
|
||||
Pack = pack;
|
||||
_itemManager = itemManager;
|
||||
|
|
@ -102,7 +107,8 @@ public class Zone
|
|||
Mass = Pack.Mass,
|
||||
Entities = Entities.Select(EntitySerializer.Pack).ToList(),
|
||||
Orbits = Orbits.Values.Select(o=>o.Data).ToList(),
|
||||
Planets = Planets.Values.ToList()
|
||||
Planets = Planets.Values.ToList(),
|
||||
Time = _time
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -111,9 +117,9 @@ public class Zone
|
|||
Orbits.Add(orbit.ID, new Orbit(Settings, orbit));
|
||||
}
|
||||
|
||||
public void Update(float time, float deltaTime)
|
||||
public void Update(float deltaTime)
|
||||
{
|
||||
_time = time;
|
||||
_time += deltaTime;
|
||||
_updatedOrbits.Clear();
|
||||
foreach (var t in BeltUpdates)
|
||||
t.Wait();
|
||||
|
|
@ -228,10 +234,10 @@ public class Zone
|
|||
}
|
||||
else size = Settings.AsteroidSize.Evaluate(beltData.Asteroids[i].Size);
|
||||
|
||||
belt.NewRotations[i] = _time * beltData.Asteroids[i].RotationSpeed % (PI * 2);
|
||||
belt.NewRotations[i] = (float) (_time * beltData.Asteroids[i].RotationSpeed % (PI * 2));
|
||||
belt.NewScales[i] = size;
|
||||
var pos = OrbitData.Evaluate(frac(_time / Settings.OrbitPeriod.Evaluate(beltData.Asteroids[i].Distance) +
|
||||
beltData.Asteroids[i].Phase)) * beltData.Asteroids[i].Distance + orbitPosition;
|
||||
var pos = OrbitData.Evaluate((float) frac(_time / Settings.OrbitPeriod.Evaluate(beltData.Asteroids[i].Distance) +
|
||||
beltData.Asteroids[i].Phase)) * beltData.Asteroids[i].Distance + orbitPosition;
|
||||
belt.NewVelocities[i] = pos - belt.Positions[i].xz;
|
||||
belt.NewPositions[i] = float3(pos.x, GetHeight(pos), pos.y);
|
||||
}
|
||||
|
|
@ -319,7 +325,7 @@ public class Zone
|
|||
var depth = gas.GravityWavesDepth.Value;
|
||||
var frequency = Settings.WaveFrequency.Evaluate(body.BodyData.Mass.Value);
|
||||
var speed = gas.GravityWavesSpeed.Value;
|
||||
result -= RadialWaves(sqrt(distSqr) / waveRadius, 8, 1.25f, frequency, _time * speed) * depth;
|
||||
result -= RadialWaves(sqrt(distSqr) / waveRadius, 8, 1.25f, frequency, (float) (_time * speed)) * depth;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,9 @@ public class ZonePack
|
|||
|
||||
[JsonProperty("mass"), Key(4)]
|
||||
public float Mass = 10000;
|
||||
|
||||
[JsonProperty("time"), Key(5)]
|
||||
public double Time;
|
||||
}
|
||||
|
||||
// [RethinkTable("Galaxy"), MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
|
|
|
|||
|
|
@ -223,9 +223,9 @@ public static class ZoneGenerator
|
|||
|
||||
var nearestFaction = sector.Factions.MinBy(f => sector.HomeZones[f].Distance[sectorZone]);
|
||||
var nearestFactionHomeZone = sector.HomeZones[nearestFaction];
|
||||
var factionPresence = nearestFaction.InfluenceDistance - nearestFactionHomeZone.Distance[sectorZone];
|
||||
var factionPresence = nearestFaction.InfluenceDistance - nearestFactionHomeZone.Distance[sectorZone] + 1;
|
||||
|
||||
var loadoutGenerator = new LoadoutGenerator(ref random, itemManager, sector, sectorZone, nearestFaction, 1);
|
||||
var loadoutGenerator = new LoadoutGenerator(ref random, itemManager, sector, sectorZone, nearestFaction, .5f);
|
||||
for (int i = 0; i < factionPresence; i++)
|
||||
{
|
||||
pack.Entities.Add(loadoutGenerator.GenerateShipLoadout());
|
||||
|
|
|
|||
|
|
@ -13,12 +13,14 @@ using UnityEngine.InputSystem;
|
|||
public class ConsoleView : MonoBehaviour {
|
||||
bool _didShow = false;
|
||||
|
||||
public ActionGameManager GameManager;
|
||||
public GameObject ViewContainer; //Container for console view, should be a child of this GameObject
|
||||
public TextMeshProUGUI LogTextArea;
|
||||
public TextMeshProUGUI InputArea;
|
||||
public ScrollRect Scroll;
|
||||
|
||||
private string _inputString = "";
|
||||
private CursorLockMode _previousCursorLockMode;
|
||||
|
||||
public string InputString
|
||||
{
|
||||
|
|
@ -110,7 +112,20 @@ public class ConsoleView : MonoBehaviour {
|
|||
ViewContainer.SetActive(visible);
|
||||
Visible = visible;
|
||||
if(visible)
|
||||
{
|
||||
GameManager.Input.Global.Disable();
|
||||
GameManager.Input.Player.Disable();
|
||||
GameManager.Input.UI.Disable();
|
||||
_previousCursorLockMode = Cursor.lockState;
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
}
|
||||
else
|
||||
{
|
||||
GameManager.Input.Global.Enable();
|
||||
GameManager.Input.Player.Enable();
|
||||
GameManager.Input.UI.Enable();
|
||||
Cursor.lockState = _previousCursorLockMode;
|
||||
}
|
||||
}
|
||||
|
||||
void OnVisibilityChanged(bool visible) {
|
||||
|
|
|
|||
24
Assets/Scripts/UI/ItemFilter.cs
Normal file
24
Assets/Scripts/UI/ItemFilter.cs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ItemFilter : MonoBehaviour
|
||||
{
|
||||
public TextMeshProUGUI Label;
|
||||
public Button DisableButton;
|
||||
|
||||
public event Action OnDisable;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
DisableButton.onClick.AddListener(() =>
|
||||
{
|
||||
GetComponent<Prototype>().ReturnToPool();
|
||||
OnDisable?.Invoke();
|
||||
OnDisable = null;
|
||||
});
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/ItemFilter.cs.meta
Normal file
11
Assets/Scripts/UI/ItemFilter.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 84b08c807fa72e340b5b57841640ec13
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -377,28 +377,35 @@ public class PropertiesPanel : MonoBehaviour
|
|||
AddProperty("Thermal Mass", () => Context.GetThermalMass(item).SignificantDigits(Context.GameplaySettings.SignificantDigits));
|
||||
if (item is EquippableItem gear)
|
||||
{
|
||||
var tier = entity.ItemManager.GetTier(gear);
|
||||
var (tier, upgrades) = entity.ItemManager.GetTier(gear);
|
||||
Title.text =
|
||||
$"<color=#{ColorUtility.ToHtmlStringRGB(tier.tier.Color.ToColor())}>{data.Name}</color><smallcaps><size=60%> ({tier.tier.Name}{new string('+', tier.upgrades)})";
|
||||
var gearData = Context.GetData(gear);
|
||||
AddProperty("Durability", () =>
|
||||
$"{gear.Durability.SignificantDigits(Context.GameplaySettings.SignificantDigits)}/{gearData.Durability.SignificantDigits(Context.GameplaySettings.SignificantDigits)}");
|
||||
foreach (var behavior in gearData.Behaviors)
|
||||
$"<color=#{ColorUtility.ToHtmlStringRGB(tier.Color.ToColor())}>{data.Name}</color><smallcaps><size=60%> ({tier.Name}{new string('+', upgrades)})";
|
||||
if (gear.Durability < .01f)
|
||||
{
|
||||
var type = behavior.GetType();
|
||||
if (type.GetCustomAttribute(typeof(RuntimeInspectable)) != null)
|
||||
AddProperty("Item destroyed!");
|
||||
}
|
||||
else
|
||||
{
|
||||
var gearData = Context.GetData(gear);
|
||||
AddProperty("Durability", () =>
|
||||
$"{gear.Durability.SignificantDigits(Context.GameplaySettings.SignificantDigits)}/{gearData.Durability.SignificantDigits(Context.GameplaySettings.SignificantDigits)}");
|
||||
foreach (var behavior in gearData.Behaviors)
|
||||
{
|
||||
foreach (var field in type.GetFields().Where(f => f.GetCustomAttribute<RuntimeInspectable>() != null))
|
||||
var type = behavior.GetType();
|
||||
if (type.GetCustomAttribute(typeof(RuntimeInspectable)) != null)
|
||||
{
|
||||
var fieldType = field.FieldType;
|
||||
if (fieldType == typeof(float))
|
||||
AddProperty(field.Name, () => $"{((float) field.GetValue(behavior)).SignificantDigits(Context.GameplaySettings.SignificantDigits)}");
|
||||
else if (fieldType == typeof(int))
|
||||
AddProperty(field.Name, () => $"{(int) field.GetValue(behavior)}");
|
||||
else if (fieldType == typeof(PerformanceStat))
|
||||
foreach (var field in type.GetFields().Where(f => f.GetCustomAttribute<RuntimeInspectable>() != null))
|
||||
{
|
||||
var stat = (PerformanceStat) field.GetValue(behavior);
|
||||
AddProperty(field.Name, () => $"{Context.Evaluate(stat, gear).SignificantDigits(Context.GameplaySettings.SignificantDigits)}");
|
||||
var fieldType = field.FieldType;
|
||||
if (fieldType == typeof(float))
|
||||
AddProperty(field.Name, () => $"{((float) field.GetValue(behavior)).SignificantDigits(Context.GameplaySettings.SignificantDigits)}");
|
||||
else if (fieldType == typeof(int))
|
||||
AddProperty(field.Name, () => $"{(int) field.GetValue(behavior)}");
|
||||
else if (fieldType == typeof(PerformanceStat))
|
||||
{
|
||||
var stat = (PerformanceStat) field.GetValue(behavior);
|
||||
AddProperty(field.Name, () => $"{Context.Evaluate(stat, gear).SignificantDigits(Context.GameplaySettings.SignificantDigits)}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,9 +35,205 @@ public class SectorMap : MonoBehaviour
|
|||
public float IconDistance = 1;
|
||||
public float IconBackgroundSize = 3;
|
||||
public float LabelDistance = .4f;
|
||||
public float LinkWidth;
|
||||
public float CriticalLinkWidth;
|
||||
public AnimationCurve IconScaleAnimation;
|
||||
|
||||
private Dictionary<Faction, (RenderTexture influence, Material primaryMaterial, Material secondaryMaterial, Material linkMaterial)> _factionMaterials =
|
||||
new Dictionary<Faction, (RenderTexture influence, Material primaryMaterial, Material secondaryMaterial, Material linkMaterial)>();
|
||||
private HashSet<SectorZone> _revealedZones = new HashSet<SectorZone>();
|
||||
private HashSet<(SectorZone, SectorZone)> _revealedLinks = new HashSet<(SectorZone, SectorZone)>();
|
||||
|
||||
private Dictionary<Faction, (MeshRenderer influenceRenderer, RenderTexture influence, Material primaryMaterial, Material secondaryMaterial, Material linkMaterial)> _factionMaterials =
|
||||
new Dictionary<Faction, (MeshRenderer influenceRenderer, RenderTexture influence, Material primaryMaterial, Material secondaryMaterial, Material linkMaterial)>();
|
||||
|
||||
private Dictionary<SectorZone, SectorZoneUI> _zoneInstances = new Dictionary<SectorZone, SectorZoneUI>();
|
||||
private Queue<IEnumerable<SectorZone>> _queuedZoneReveals = new Queue<IEnumerable<SectorZone>>();
|
||||
|
||||
public void QueueZoneReveal(IEnumerable<SectorZone> zones)
|
||||
{
|
||||
_queuedZoneReveals.Enqueue(zones);
|
||||
}
|
||||
|
||||
public void StartReveal(float linkDuration, float iconDuration)
|
||||
{
|
||||
if (_queuedZoneReveals.Count > 0)
|
||||
{
|
||||
StartCoroutine(RevealZone(_queuedZoneReveals.Dequeue(), linkDuration, iconDuration));
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerator RevealZone(IEnumerable<SectorZone> zones, float linkDuration, float iconDuration)
|
||||
{
|
||||
var linksToReveal = new List<(float2 start, float2 end, Transform linkInstance, bool critical)>();
|
||||
var zoneTransforms = new List<Transform>();
|
||||
var zoneInstanceScale = ZonePrototype.transform.localScale;
|
||||
|
||||
foreach (var zone in zones)
|
||||
{
|
||||
if (!_revealedZones.Contains(zone))
|
||||
{
|
||||
var zoneInstance = ZonePrototype.Instantiate<SectorZoneUI>();
|
||||
_zoneInstances[zone] = zoneInstance;
|
||||
var zoneInstanceTransform = zoneInstance.transform;
|
||||
zoneTransforms.Add(zoneInstanceTransform);
|
||||
zoneInstanceTransform.localPosition = new Vector3(zone.Position.x, zone.Position.y);
|
||||
if(zone.Owner != null)
|
||||
{
|
||||
zoneInstance.Primary.sharedMaterial = _factionMaterials[zone.Owner].primaryMaterial;
|
||||
zoneInstance.Secondary.sharedMaterial = _factionMaterials[zone.Owner].secondaryMaterial;
|
||||
if(zone == ActionGameManager.CurrentSector.HomeZones[zone.Owner])
|
||||
zoneInstance.Secondary.transform.localScale = Vector3.one * 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
zoneInstance.Secondary.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
var isOnCriticalPath = ActionGameManager.CurrentSector.ExitPath.Contains(zone);
|
||||
foreach (var adjacentZone in zone.AdjacentZones)
|
||||
{
|
||||
// If the adjacent zone is in the set already revealed, then show the link
|
||||
if (_revealedZones.Contains(adjacentZone) &&
|
||||
!(_revealedLinks.Contains((zone, adjacentZone)) ||
|
||||
_revealedLinks.Contains((adjacentZone, zone))))
|
||||
{
|
||||
var link = LinkPrototype.Instantiate<Transform>();
|
||||
var critical = isOnCriticalPath && ActionGameManager.CurrentSector.ExitPath.Contains(adjacentZone);
|
||||
linksToReveal.Add((zone.Position, adjacentZone.Position, link, critical));
|
||||
if (zone.Owner != null && zone.Owner == adjacentZone.Owner)
|
||||
link.GetComponent<MeshRenderer>().sharedMaterial = _factionMaterials[zone.Owner].linkMaterial;
|
||||
|
||||
var dir = normalize(zone.Position - adjacentZone.Position);
|
||||
link.rotation = Quaternion.Euler(0,0,atan2(dir.y,dir.x) * Mathf.Rad2Deg);
|
||||
|
||||
placeLink(zone.Position, adjacentZone.Position, link, 0, critical);
|
||||
}
|
||||
}
|
||||
_revealedZones.Add(zone);
|
||||
|
||||
// Determine center of mass for adjacent zone links, used for placement of label and icons
|
||||
var linkDirection = normalize(zone.AdjacentZones
|
||||
.Aggregate(float2.zero, (v, adjacentZone) => v + normalize(adjacentZone.Position - zone.Position)));
|
||||
|
||||
var zoneText = zoneInstance.Label;
|
||||
zoneText.text = zone.Name;
|
||||
var zoneTextTransform = zoneText.GetComponent<RectTransform>();
|
||||
zoneTextTransform.pivot = new Vector2(sign(linkDirection.x)/2+.5f,sign(linkDirection.y)/2+.5f);
|
||||
zoneTextTransform.localPosition = new Vector3(-linkDirection.x * LabelDistance, -linkDirection.y * LabelDistance, -1);
|
||||
|
||||
if (zone == ActionGameManager.CurrentSector.Entrance)
|
||||
{
|
||||
var iconInstance = IconPrototype.Instantiate<MeshRenderer>();
|
||||
iconInstance.material.mainTexture = EntranceIcon;
|
||||
var iconTransform = iconInstance.transform;
|
||||
iconTransform.SetParent(zoneInstanceTransform);
|
||||
iconTransform.localScale = Vector3.one;
|
||||
iconTransform.localPosition = new Vector3(-linkDirection.x * IconDistance, -linkDirection.y * IconDistance);
|
||||
}
|
||||
|
||||
if (zone == ActionGameManager.CurrentSector.Exit)
|
||||
{
|
||||
var iconInstance = IconPrototype.Instantiate<MeshRenderer>();
|
||||
iconInstance.material.mainTexture = ExitIcon;
|
||||
var iconTransform = iconInstance.transform;
|
||||
iconTransform.SetParent(zoneInstanceTransform);
|
||||
iconTransform.localScale = Vector3.one;
|
||||
iconTransform.localPosition = new Vector3(-linkDirection.x * IconDistance, -linkDirection.y * IconDistance);
|
||||
}
|
||||
|
||||
var homeMega = ActionGameManager.CurrentSector.HomeZones.Keys
|
||||
.FirstOrDefault(m => ActionGameManager.CurrentSector.HomeZones[m] == zone);
|
||||
if (homeMega != null)
|
||||
{
|
||||
var backgroundInstance = IconBackgroundPrototype.Instantiate<MeshRenderer>();
|
||||
var iconInstance = IconPrototype.Instantiate<MeshRenderer>();
|
||||
|
||||
backgroundInstance.material.SetColor("_Color", homeMega.SecondaryColor.ToColor());
|
||||
iconInstance.material.mainTexture = HomeIcon;
|
||||
iconInstance.material.SetColor("_Color", homeMega.PrimaryColor.ToColor());
|
||||
|
||||
var backgroundTransform = backgroundInstance.transform;
|
||||
var iconTransform = iconInstance.transform;
|
||||
|
||||
backgroundTransform.SetParent(zoneInstanceTransform);
|
||||
iconTransform.SetParent(zoneInstanceTransform);
|
||||
|
||||
backgroundTransform.localScale = Vector3.one * IconBackgroundSize;
|
||||
iconTransform.localScale = Vector3.one;
|
||||
|
||||
backgroundTransform.localPosition = new Vector3(-linkDirection.x * IconDistance, -linkDirection.y * IconDistance, .5f);
|
||||
iconTransform.localPosition = new Vector3(-linkDirection.x * IconDistance, -linkDirection.y * IconDistance);
|
||||
}
|
||||
|
||||
var bossMega = ActionGameManager.CurrentSector.BossZones.Keys
|
||||
.FirstOrDefault(m => ActionGameManager.CurrentSector.BossZones[m] == zone);
|
||||
if (bossMega != null)
|
||||
{
|
||||
var backgroundInstance = IconBackgroundPrototype.Instantiate<MeshRenderer>();
|
||||
var iconInstance = IconPrototype.Instantiate<MeshRenderer>();
|
||||
|
||||
backgroundInstance.material.SetColor("_Color", bossMega.SecondaryColor.ToColor());
|
||||
iconInstance.material.mainTexture = BossIcon;
|
||||
iconInstance.material.SetColor("_Color", bossMega.PrimaryColor.ToColor());
|
||||
|
||||
var backgroundTransform = backgroundInstance.transform;
|
||||
var iconTransform = iconInstance.transform;
|
||||
|
||||
backgroundTransform.SetParent(zoneInstanceTransform);
|
||||
iconTransform.SetParent(zoneInstanceTransform);
|
||||
|
||||
backgroundTransform.localScale = Vector3.one * IconBackgroundSize;
|
||||
iconTransform.localScale = Vector3.one;
|
||||
|
||||
if (homeMega != null)
|
||||
{
|
||||
backgroundTransform.localPosition = new Vector3(linkDirection.x * IconDistance, linkDirection.y * IconDistance, .5f);
|
||||
iconTransform.localPosition = new Vector3(linkDirection.x * IconDistance, linkDirection.y * IconDistance);
|
||||
}
|
||||
else
|
||||
{
|
||||
backgroundTransform.localPosition = new Vector3(-linkDirection.x * IconDistance, -linkDirection.y * IconDistance, .5f);
|
||||
iconTransform.localPosition = new Vector3(-linkDirection.x * IconDistance, -linkDirection.y * IconDistance);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (var tr in zoneTransforms) tr.gameObject.SetActive(false);
|
||||
|
||||
// Local function for animating the placement of a link
|
||||
void placeLink(float2 start, float2 end, Transform link, float t, bool critical)
|
||||
{
|
||||
var pos = lerp(start, end, t / 2);
|
||||
link.localPosition = new Vector3(pos.x, pos.y);
|
||||
|
||||
var localScale = link.localScale;
|
||||
localScale = new Vector3(length(start - end)*t, critical ? CriticalLinkWidth : LinkWidth, 1);
|
||||
link.localScale = localScale;
|
||||
}
|
||||
|
||||
var startTime = Time.time;
|
||||
while (Time.time - startTime < linkDuration)
|
||||
{
|
||||
var t = (Time.time - startTime) / linkDuration;
|
||||
foreach (var (start, end, link, critical) in linksToReveal) placeLink(end, start, link, t, critical);
|
||||
|
||||
yield return null;
|
||||
}
|
||||
foreach (var (start, end, link, critical) in linksToReveal) placeLink(start, end, link, 1, critical);
|
||||
|
||||
foreach (var tr in zoneTransforms) tr.gameObject.SetActive(true);
|
||||
startTime = Time.time;
|
||||
while (Time.time - startTime < iconDuration)
|
||||
{
|
||||
var t = (Time.time - startTime) / iconDuration;
|
||||
foreach (var tr in zoneTransforms) tr.localScale = zoneInstanceScale * IconScaleAnimation.Evaluate(t);
|
||||
RenderInfluence();
|
||||
|
||||
yield return null;
|
||||
}
|
||||
foreach (var tr in zoneTransforms) tr.localScale = zoneInstanceScale;
|
||||
|
||||
StartReveal(linkDuration, iconDuration);
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
|
|
@ -48,171 +244,31 @@ public class SectorMap : MonoBehaviour
|
|||
}
|
||||
foreach (var mega in ActionGameManager.CurrentSector.Factions)
|
||||
{
|
||||
var influenceTexture = new RenderTexture(1024, 1024, 0, RenderTextureFormat.RHalf);
|
||||
var influenceRenderer = InfluenceRendererPrototype.Instantiate<MeshRenderer>();
|
||||
|
||||
influenceRenderer.material.mainTexture = influenceTexture;
|
||||
influenceRenderer.material.SetColor("_Color1", mega.PrimaryColor.ToColor());
|
||||
influenceRenderer.material.SetColor("_Color2", mega.SecondaryColor.ToColor());
|
||||
influenceRenderer.material.SetFloat("_FillTilt", Random.value * PI);
|
||||
|
||||
var primary = Instantiate(ZonePrimaryMaterial);
|
||||
primary.SetColor("_Color", (mega.PrimaryColor * MegaPrimaryBoost).ToColor());
|
||||
|
||||
var secondary = Instantiate(ZoneSecondaryMaterial);
|
||||
secondary.SetColor("_Color", (mega.SecondaryColor * MegaSecondaryBoost).ToColor());
|
||||
|
||||
var link = Instantiate(ZoneLinkMaterial);
|
||||
link.SetColor("_Color", (mega.PrimaryColor * MegaLinkBoost).ToColor());
|
||||
_factionMaterials.Add(mega, (new RenderTexture(1024, 1024, 0, RenderTextureFormat.RHalf), primary, secondary, link));
|
||||
|
||||
_factionMaterials.Add(mega, (influenceRenderer, influenceTexture, primary, secondary, link));
|
||||
|
||||
var legendElement = LegendPrototype.Instantiate<LegendElement>();
|
||||
legendElement.Primary.color = mega.PrimaryColor.ToColor();
|
||||
legendElement.Secondary.color = mega.SecondaryColor.ToColor();
|
||||
legendElement.Label.text = mega.ShortName;
|
||||
}
|
||||
|
||||
var visitedZones = new HashSet<SectorZone>();
|
||||
//Debug.Log($"Found {sector.Zones.Count(z=>!z.AdjacentZones.Any())} orphaned zones!");
|
||||
|
||||
var zoneInstances = new Dictionary<SectorZone, SectorZoneUI>();
|
||||
foreach (var zone in ActionGameManager.CurrentSector.Zones)
|
||||
{
|
||||
var zoneInstance = ZonePrototype.Instantiate<SectorZoneUI>();
|
||||
zoneInstances[zone] = zoneInstance;
|
||||
var zoneInstanceTransform = zoneInstance.transform;
|
||||
zoneInstanceTransform.localPosition = new Vector3(zone.Position.x, zone.Position.y);
|
||||
if(zone.Owner != null)
|
||||
{
|
||||
zoneInstance.Primary.sharedMaterial = _factionMaterials[zone.Owner].primaryMaterial;
|
||||
zoneInstance.Secondary.sharedMaterial = _factionMaterials[zone.Owner].secondaryMaterial;
|
||||
}
|
||||
//zoneInstance.Background.transform.localScale = Vector3.one * (sector.HomeZones.Values.Any(os=>os==zone) ? 4 : 2);
|
||||
var linkDirection = float2.zero;
|
||||
foreach (var link in zone.AdjacentZones)
|
||||
{
|
||||
linkDirection += normalize(link.Position - zone.Position);
|
||||
if (!visitedZones.Contains(link))
|
||||
{
|
||||
var linkInstance = LinkPrototype.Instantiate<Transform>();
|
||||
var pos = (zone.Position + link.Position) / 2;
|
||||
linkInstance.localPosition = new Vector3(pos.x, pos.y);
|
||||
if (zone.Owner != null && zone.Owner == link.Owner)
|
||||
linkInstance.GetComponent<MeshRenderer>().sharedMaterial = _factionMaterials[zone.Owner].linkMaterial;
|
||||
|
||||
var localScale = linkInstance.localScale;
|
||||
localScale = new Vector3(length(zone.Position - link.Position), localScale.y, localScale.z);
|
||||
linkInstance.localScale = localScale;
|
||||
|
||||
var dir = normalize(zone.Position - link.Position);
|
||||
linkInstance.rotation = Quaternion.Euler(0,0,atan2(dir.y,dir.x) * Mathf.Rad2Deg);
|
||||
}
|
||||
}
|
||||
|
||||
linkDirection = normalize(linkDirection);
|
||||
var zoneText = zoneInstance.Label;
|
||||
zoneText.text = zone.Name;
|
||||
var zoneTextTransform = zoneText.GetComponent<RectTransform>();
|
||||
zoneTextTransform.pivot = new Vector2(sign(linkDirection.x)/2+.5f,sign(linkDirection.y)/2+.5f);
|
||||
zoneTextTransform.localPosition = new Vector3(-linkDirection.x * LabelDistance, -linkDirection.y * LabelDistance, -1);
|
||||
visitedZones.Add(zone);
|
||||
|
||||
if (zone == ActionGameManager.CurrentSector.Entrance)
|
||||
{
|
||||
var iconInstance = IconPrototype.Instantiate<MeshRenderer>();
|
||||
iconInstance.material.mainTexture = EntranceIcon;
|
||||
var iconTransform = iconInstance.transform;
|
||||
iconTransform.SetParent(zoneInstanceTransform);
|
||||
iconTransform.localScale = Vector3.one;
|
||||
iconTransform.localPosition = new Vector3(-linkDirection.x * IconDistance, -linkDirection.y * IconDistance);
|
||||
}
|
||||
|
||||
if (zone == ActionGameManager.CurrentSector.Exit)
|
||||
{
|
||||
var iconInstance = IconPrototype.Instantiate<MeshRenderer>();
|
||||
iconInstance.material.mainTexture = ExitIcon;
|
||||
var iconTransform = iconInstance.transform;
|
||||
iconTransform.SetParent(zoneInstanceTransform);
|
||||
iconTransform.localScale = Vector3.one;
|
||||
iconTransform.localPosition = new Vector3(-linkDirection.x * IconDistance, -linkDirection.y * IconDistance);
|
||||
}
|
||||
|
||||
var homeMega = ActionGameManager.CurrentSector.HomeZones.Keys
|
||||
.FirstOrDefault(m => ActionGameManager.CurrentSector.HomeZones[m] == zone);
|
||||
if (homeMega != null)
|
||||
{
|
||||
var backgroundInstance = IconBackgroundPrototype.Instantiate<MeshRenderer>();
|
||||
var iconInstance = IconPrototype.Instantiate<MeshRenderer>();
|
||||
|
||||
backgroundInstance.material.SetColor("_Color", homeMega.SecondaryColor.ToColor());
|
||||
iconInstance.material.mainTexture = HomeIcon;
|
||||
iconInstance.material.SetColor("_Color", homeMega.PrimaryColor.ToColor());
|
||||
|
||||
var backgroundTransform = backgroundInstance.transform;
|
||||
var iconTransform = iconInstance.transform;
|
||||
|
||||
backgroundTransform.SetParent(zoneInstanceTransform);
|
||||
iconTransform.SetParent(zoneInstanceTransform);
|
||||
|
||||
backgroundTransform.localScale = Vector3.one * IconBackgroundSize;
|
||||
iconTransform.localScale = Vector3.one;
|
||||
|
||||
backgroundTransform.localPosition = new Vector3(-linkDirection.x * IconDistance, -linkDirection.y * IconDistance, .5f);
|
||||
iconTransform.localPosition = new Vector3(-linkDirection.x * IconDistance, -linkDirection.y * IconDistance);
|
||||
}
|
||||
|
||||
var bossMega = ActionGameManager.CurrentSector.BossZones.Keys
|
||||
.FirstOrDefault(m => ActionGameManager.CurrentSector.BossZones[m] == zone);
|
||||
if (bossMega != null)
|
||||
{
|
||||
var backgroundInstance = IconBackgroundPrototype.Instantiate<MeshRenderer>();
|
||||
var iconInstance = IconPrototype.Instantiate<MeshRenderer>();
|
||||
|
||||
backgroundInstance.material.SetColor("_Color", bossMega.SecondaryColor.ToColor());
|
||||
iconInstance.material.mainTexture = BossIcon;
|
||||
iconInstance.material.SetColor("_Color", bossMega.PrimaryColor.ToColor());
|
||||
|
||||
var backgroundTransform = backgroundInstance.transform;
|
||||
var iconTransform = iconInstance.transform;
|
||||
|
||||
backgroundTransform.SetParent(zoneInstanceTransform);
|
||||
iconTransform.SetParent(zoneInstanceTransform);
|
||||
|
||||
backgroundTransform.localScale = Vector3.one * IconBackgroundSize;
|
||||
iconTransform.localScale = Vector3.one;
|
||||
|
||||
if (homeMega != null)
|
||||
{
|
||||
backgroundTransform.localPosition = new Vector3(linkDirection.x * IconDistance, linkDirection.y * IconDistance, .5f);
|
||||
iconTransform.localPosition = new Vector3(linkDirection.x * IconDistance, linkDirection.y * IconDistance);
|
||||
}
|
||||
else
|
||||
{
|
||||
backgroundTransform.localPosition = new Vector3(-linkDirection.x * IconDistance, -linkDirection.y * IconDistance, .5f);
|
||||
iconTransform.localPosition = new Vector3(-linkDirection.x * IconDistance, -linkDirection.y * IconDistance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Render Influence Textures
|
||||
foreach (var mega in ActionGameManager.CurrentSector.Factions)
|
||||
{
|
||||
var influenceRenderer = InfluenceRendererPrototype.Instantiate<MeshRenderer>();
|
||||
foreach (var zone in ActionGameManager.CurrentSector.Zones)
|
||||
{
|
||||
var instance = zoneInstances[zone];
|
||||
var influence = 0f;
|
||||
if (zone.Factions.Length > 0)
|
||||
{
|
||||
if (zone.Factions.Contains(mega))
|
||||
{
|
||||
influence = 10;
|
||||
if (zone.Owner != mega)
|
||||
influence *= .5f;
|
||||
}
|
||||
else influence = -10;
|
||||
}
|
||||
instance.Influence.material.SetFloat("_Depth", influence);
|
||||
}
|
||||
|
||||
InfluenceCamera.targetTexture = _factionMaterials[mega].influence;
|
||||
InfluenceCamera.Render();
|
||||
|
||||
influenceRenderer.material.mainTexture = _factionMaterials[mega].influence;
|
||||
influenceRenderer.material.SetColor("_Color1", mega.PrimaryColor.ToColor());
|
||||
influenceRenderer.material.SetColor("_Color2", mega.SecondaryColor.ToColor());
|
||||
influenceRenderer.material.SetFloat("_FillTilt", Random.value * PI);
|
||||
}
|
||||
|
||||
SectorRenderer.material.SetFloat("CloudAmplitude", ActionGameManager.CurrentSector.Settings.CloudAmplitude);
|
||||
SectorRenderer.material.SetFloat("CloudExponent", ActionGameManager.CurrentSector.Settings.CloudExponent);
|
||||
SectorRenderer.material.SetFloat("NoisePosition", ActionGameManager.CurrentSector.Settings.NoisePosition);
|
||||
|
|
@ -222,4 +278,35 @@ public class SectorMap : MonoBehaviour
|
|||
SectorRenderer.material.SetFloat("NoiseLacunarity", ActionGameManager.CurrentSector.Settings.NoiseLacunarity);
|
||||
SectorRenderer.material.SetFloat("NoiseFrequency", ActionGameManager.CurrentSector.Settings.NoiseFrequency);
|
||||
}
|
||||
|
||||
private void RenderInfluence()
|
||||
{
|
||||
// Render Influence Textures
|
||||
foreach (var mega in ActionGameManager.CurrentSector.Factions)
|
||||
{
|
||||
foreach (var zone in ActionGameManager.CurrentSector.Zones)
|
||||
{
|
||||
if(_zoneInstances.ContainsKey(zone))
|
||||
{
|
||||
var instance = _zoneInstances[zone];
|
||||
var influence = 0f;
|
||||
if (zone.Factions.Length > 0)
|
||||
{
|
||||
if (zone.Factions.Contains(mega))
|
||||
{
|
||||
influence = 10;
|
||||
if (zone.Owner != mega)
|
||||
influence *= .5f;
|
||||
}
|
||||
else influence = -10;
|
||||
}
|
||||
|
||||
instance.Influence.material.SetFloat("_Depth", influence);
|
||||
}
|
||||
}
|
||||
|
||||
InfluenceCamera.targetTexture = _factionMaterials[mega].influence;
|
||||
InfluenceCamera.Render();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
168
Assets/Scripts/UI/SectorRenderer.cs
Normal file
168
Assets/Scripts/UI/SectorRenderer.cs
Normal file
|
|
@ -0,0 +1,168 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
using Unity.Mathematics;
|
||||
using static Unity.Mathematics.math;
|
||||
using float2 = Unity.Mathematics.float2;
|
||||
|
||||
public class SectorRenderer : MonoBehaviour, IBeginDragHandler, IDragHandler, IScrollHandler
|
||||
{
|
||||
public Canvas Canvas;
|
||||
public SectorMap Map;
|
||||
public ActionGameManager GameManager;
|
||||
public Camera MainCamera;
|
||||
public Camera SectorCamera;
|
||||
public MeshRenderer SectorBackgroundRenderer;
|
||||
public float ZoomSpeed;
|
||||
public float MinViewSize = .1f;
|
||||
public float MaxViewSize = 2;
|
||||
public Button PathAnimationButton;
|
||||
public float PathAnimationDamping;
|
||||
public float PathAnimationDuration;
|
||||
public float PathAnimationDurationPadding = 1.1f;
|
||||
public GameObject LegendPanel;
|
||||
public float LinkAnimationDuration;
|
||||
public float IconAnimationDuration;
|
||||
|
||||
private float2 _startMousePosition;
|
||||
private float2 _startMapPosition;
|
||||
|
||||
private Transform _sectorBackgroundTransform;
|
||||
private Transform _sectorCameraTransform;
|
||||
private Image _outputImage;
|
||||
private RenderTexture _outputTexture;
|
||||
private Vector3[] _imageCorners = new Vector3[4];
|
||||
private int2 _size;
|
||||
private bool _init;
|
||||
private float _aspectRatio;
|
||||
private float _sectorBackgroundDepth;
|
||||
private float _sectorCameraDepth;
|
||||
|
||||
private float2 _position = float2(0.5f);
|
||||
private float _viewSize = .5f;
|
||||
|
||||
void Start()
|
||||
{
|
||||
_outputImage = GetComponent<Image>();
|
||||
_sectorBackgroundTransform = SectorBackgroundRenderer.transform;
|
||||
_sectorBackgroundDepth = _sectorBackgroundTransform.position.z;
|
||||
_sectorCameraTransform = SectorCamera.transform;
|
||||
_sectorCameraDepth = _sectorCameraTransform.position.z;
|
||||
PathAnimationButton.onClick.AddListener(() =>
|
||||
{
|
||||
Map.StartCoroutine(AnimatePath());
|
||||
});
|
||||
}
|
||||
|
||||
private IEnumerator AnimatePath()
|
||||
{
|
||||
var pathZones = ActionGameManager.CurrentSector.ExitPath;
|
||||
LegendPanel.SetActive(false);
|
||||
PathAnimationButton.gameObject.SetActive(false);
|
||||
foreach (var zones in ActionGameManager.CurrentSector.Zones
|
||||
.GroupBy(z=>z.Distance[ActionGameManager.CurrentSector.Entrance])
|
||||
.OrderBy(g=>g.Key))
|
||||
{
|
||||
Map.QueueZoneReveal(zones);
|
||||
}
|
||||
|
||||
var revealCount = ActionGameManager.CurrentSector.Entrance.Distance[ActionGameManager.CurrentSector.Exit];
|
||||
Map.StartReveal(
|
||||
PathAnimationDuration / revealCount * (LinkAnimationDuration / (IconAnimationDuration + LinkAnimationDuration)),
|
||||
PathAnimationDuration / revealCount * (IconAnimationDuration / (IconAnimationDuration + LinkAnimationDuration)));
|
||||
MainCamera.enabled = false;
|
||||
SectorCamera.targetTexture = null;
|
||||
Canvas.gameObject.SetActive(false);
|
||||
SectorCamera.gameObject.SetActive(true);
|
||||
|
||||
var pathAnimationLerp = 0f;
|
||||
while (pathAnimationLerp < 1)
|
||||
{
|
||||
var currentTargetZone = pathZones[(int) (pathZones.Length * pathAnimationLerp)];
|
||||
_position = lerp(_position, currentTargetZone.Position, PathAnimationDamping);
|
||||
pathAnimationLerp += Time.deltaTime / (PathAnimationDuration * PathAnimationDurationPadding);
|
||||
UpdateCamera();
|
||||
yield return null;
|
||||
}
|
||||
|
||||
LegendPanel.SetActive(true);
|
||||
PathAnimationButton.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
_init = true;
|
||||
SectorCamera.gameObject.SetActive(true);
|
||||
_position = GameManager.Zone.SectorZone.Position;
|
||||
_viewSize = .25f;
|
||||
|
||||
Map.StartReveal(LinkAnimationDuration, IconAnimationDuration);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
if (_outputTexture != null)
|
||||
{
|
||||
_outputTexture.Release();
|
||||
_outputTexture = null;
|
||||
}
|
||||
SectorCamera.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
void LateUpdate()
|
||||
{
|
||||
var size = int2(Screen.width, Screen.height);
|
||||
if (_init || size.x != _size.x || size.y != _size.y)
|
||||
{
|
||||
_aspectRatio = (float) size.x / size.y;
|
||||
_size = size;
|
||||
if (_outputTexture != null)
|
||||
{
|
||||
_outputTexture.Release();
|
||||
}
|
||||
_outputTexture = new RenderTexture(_size.x, _size.y, 0, RenderTextureFormat.Default);
|
||||
SectorCamera.targetTexture = _outputTexture;
|
||||
_outputImage.material.SetTexture("_DetailTex", _outputTexture);
|
||||
}
|
||||
|
||||
UpdateCamera();
|
||||
}
|
||||
|
||||
void UpdateCamera()
|
||||
{
|
||||
var halfSize = _viewSize / 2;
|
||||
var bounds = float4(
|
||||
_position.x - _aspectRatio * halfSize,
|
||||
_position.y - halfSize,
|
||||
_position.x + _aspectRatio * halfSize,
|
||||
_position.y + halfSize);
|
||||
_sectorBackgroundTransform.position = new Vector3(_position.x, _position.y, _sectorBackgroundDepth);
|
||||
_sectorBackgroundTransform.localScale = new Vector3(_aspectRatio * _viewSize, _viewSize);
|
||||
_sectorCameraTransform.position = new Vector3(_position.x, _position.y, _sectorCameraDepth);
|
||||
SectorCamera.orthographicSize = halfSize;
|
||||
SectorBackgroundRenderer.material.SetVector("Extents", bounds);
|
||||
}
|
||||
|
||||
public void OnBeginDrag(PointerEventData eventData)
|
||||
{
|
||||
_startMousePosition = eventData.position;
|
||||
_startMapPosition = _position;
|
||||
}
|
||||
|
||||
public void OnDrag(PointerEventData eventData)
|
||||
{
|
||||
_position = _startMapPosition - ((float2)eventData.position - _startMousePosition) / _size.y * _viewSize;
|
||||
}
|
||||
|
||||
public void OnScroll(PointerEventData eventData)
|
||||
{
|
||||
var mapCenter = float2((float)Screen.width / 2, (float)Screen.height / 2);
|
||||
var oldPointerPosition = _position + ((float2)eventData.position - mapCenter) / Screen.height * _viewSize;
|
||||
_viewSize = clamp(_viewSize * (1 - eventData.scrollDelta.y * ZoomSpeed), MinViewSize, MaxViewSize);
|
||||
var pointerPosition = _position + ((float2)eventData.position - mapCenter) / Screen.height * _viewSize;
|
||||
_position += oldPointerPosition - pointerPosition;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/SectorRenderer.cs.meta
Normal file
11
Assets/Scripts/UI/SectorRenderer.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 59b26802254e34b4bb26f48d0d8b51bf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -34,6 +34,7 @@ public class TradeMenu : MonoBehaviour
|
|||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (GameManager.DockedEntity == null) return;
|
||||
_targetCargo = GameManager.DockingBay;
|
||||
TargetCargoLabel.text = "Docking Bay";
|
||||
Properties.Context = GameManager.ItemManager;
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public class VolumeSampling : MonoBehaviour
|
|||
|
||||
// Shader needs to know the position and scale of cameras used to render input textures
|
||||
if(GridTransform != null)
|
||||
_volMaterial.SetVector("_GridTransform", new Vector4(GridTransform.position.x,GridTransform.position.z,GridTransform.localScale.x*4));
|
||||
_volMaterial.SetVector("_GridTransform", new Vector4(GridTransform.position.x,GridTransform.position.z,GridTransform.localScale.x));
|
||||
|
||||
Graphics.Blit( source, destination, _volMaterial, 0 );
|
||||
}
|
||||
|
|
@ -20,7 +20,6 @@ public class ZoneRenderer : MonoBehaviour
|
|||
{
|
||||
public Transform WormholePrefab;
|
||||
public float EntityFadeTime;
|
||||
public Transform EffectManagerParent;
|
||||
public Transform FogCameraParent;
|
||||
public GameSettings Settings;
|
||||
public Transform ZoneRoot;
|
||||
|
|
@ -36,6 +35,8 @@ public class ZoneRenderer : MonoBehaviour
|
|||
public int AsteroidSpritesheetWidth = 4;
|
||||
public int AsteroidSpritesheetHeight = 4;
|
||||
public LODHandler LODHandler;
|
||||
public Slime SlimeRenderer;
|
||||
public Camera SlimeGravityCamera;
|
||||
|
||||
[Header("Tour")]
|
||||
public bool Tour;
|
||||
|
|
@ -88,6 +89,7 @@ public class ZoneRenderer : MonoBehaviour
|
|||
get => _perspectiveEntity;
|
||||
set
|
||||
{
|
||||
//if (_perspectiveEntity == value) return;
|
||||
_perspectiveEntity = value;
|
||||
_perspectiveSubscriptions[0]?.Dispose();
|
||||
_perspectiveSubscriptions[1]?.Dispose();
|
||||
|
|
@ -112,8 +114,6 @@ public class ZoneRenderer : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
public float GameTime { get; set; }
|
||||
|
||||
public float ViewDistance
|
||||
{
|
||||
set
|
||||
|
|
@ -139,7 +139,6 @@ public class ZoneRenderer : MonoBehaviour
|
|||
|
||||
void Start()
|
||||
{
|
||||
EntityInstance.EffectManagerParent = EffectManagerParent;
|
||||
ViewDistance = Settings.DefaultViewDistance;
|
||||
MinimapDistance = Settings.MinimapZoomLevels[Settings.DefaultMinimapZoom];
|
||||
|
||||
|
|
@ -153,6 +152,8 @@ public class ZoneRenderer : MonoBehaviour
|
|||
_maxDepth = 0;
|
||||
Zone = zone;
|
||||
SectorBrushes.localScale = zone.Pack.Radius * 2 * Vector3.one;
|
||||
SlimeGravityCamera.orthographicSize = zone.Pack.Radius;
|
||||
SlimeRenderer.ZoneRadius = zone.Pack.Radius;
|
||||
foreach(var p in zone.Planets.Values)
|
||||
LoadPlanet(p);
|
||||
|
||||
|
|
@ -440,7 +441,7 @@ public class ZoneRenderer : MonoBehaviour
|
|||
planet.Value.Body.transform.localPosition = new Vector3(0, Zone.GetHeight(p) + planetInstance.BodyRadius.Value * 2, 0);
|
||||
if(planet.Value is GasGiantObject gasGiantObject)
|
||||
{
|
||||
gasGiantObject.GravityWaves.material.SetFloat("_Phase", GameTime * ((GasGiant) Zone.PlanetInstances[planet.Key]).GravityWavesSpeed.Value);
|
||||
gasGiantObject.GravityWaves.material.SetFloat("_Phase", Zone.Time * ((GasGiant) Zone.PlanetInstances[planet.Key]).GravityWavesSpeed.Value);
|
||||
if(!(planet.Value is SunObject))
|
||||
{
|
||||
var toParent = normalize(Zone.GetOrbitPosition(Zone.Orbits[planetInstance.BodyData.Orbit].Data.Parent) - p);
|
||||
Loading…
Reference in a new issue