private void OnPlayerHoveredTileChanged(Tile hoveredTile) { if (_unitActionHandler.Action == UnitAction.Unassigned) { return; } var effectPreview = new EffectPreview(); if (hoveredTile != null) { if (_unitActionHandler.Action == UnitAction.PrimaryAttack) { var mechTile = Gameboard.World.Helper.GetTile(_selectedMech); if (mechTile == null || _selectedMech.PrimaryWeapon == null || _selectedMech.PrimaryWeapon.WeaponData == null) { return; } var spawnEffectParameters = new SpawnEffectParameters(mechTile, hoveredTile); effectPreview = Effect.GetPreview(_selectedMech.PrimaryWeapon.WeaponData.EffectPrototype, Gameboard.World.Helper, spawnEffectParameters); } else if (_unitActionHandler.Action == UnitAction.Move) { effectPreview = hoveredTile.Hazards.GetEffectPreviewOnEnter(_selectedMech); } } Events.SetHoveredTile(hoveredTile); Events.ShowEffectPreview(effectPreview); }
private EffectPreview GetPreview(Helper helper, SpawnEffectParameters parameters) { var effectResult = new EffectPreview(); _effects.ForEach(x => x.GetPreview(effectResult, helper, parameters)); return(effectResult); }
public void GetPreview(EffectPreview effectPreview, Helper gameboardHelper, SpawnEffectParameters spawnEffectParameters) { var applyEffectParameters = GetApplyEffectParameters(gameboardHelper, spawnEffectParameters); if (applyEffectParameters != null) { OnGetPreview(applyEffectParameters, effectPreview); } }
private void ShowMarkers(EffectPreview effectPreview) { ClearMarkers(); foreach (var item in effectPreview.Pushes) { var instance = SpawnPushMarker(item.Key, item.Value); _pushMarkers.Add(instance); } }
private void OnGameboardStateEffectPreviewChanged(EffectPreview effectPreview) { var healthChangeDelta = effectPreview.GetUnitHealthChangeDelta(_unit); // Set healthbars that will be removed so that they flash. for (int i = 0; i < _fillSegmentInstances.Count; i++) { if (i < _fillSegmentInstances.Count - Mathf.Abs(healthChangeDelta)) { _fillSegmentInstances[i].Flashing = false; } else { _fillSegmentInstances[i].Flashing = true; } } }
public static EffectPreview GetPreview(Effect prototype, Helper helper, SpawnEffectParameters spawnEffectParameters) { var effectPreview = new EffectPreview(); if (prototype == null) { DebugEx.LogWarning <Helper>("Cannot get effect preview as prototype is null."); return(effectPreview); } if (spawnEffectParameters.Source == null || spawnEffectParameters.Target == null) { DebugEx.LogWarning <Helper>("Cannot get effect result as source and/or target tile is null."); return(effectPreview); } var effectInstance = Spawn(prototype); effectPreview = effectInstance.GetPreview(helper, spawnEffectParameters); Destroy(effectInstance.gameObject); return(effectPreview); }
public void ShowEffectPreview(EffectPreview effectPreview) => EffectPreviewShow?.Invoke(effectPreview);
protected override void OnGetPreview(ApplyEffectParameters applyEffectParameters, EffectPreview effectResult) { effectResult.RegisterHealthChange(applyEffectParameters.Receiver, _amount); }
protected abstract void OnGetPreview(ApplyEffectParameters applyEffectParameters, EffectPreview effectResult);
protected override void OnGetPreview(ApplyEffectParameters applyEffectParameters, EffectPreview effectResult) { // Todo. }
protected override void OnGetPreview(ApplyEffectParameters applyEffectParameters, EffectPreview effectPreview) { var pushableComponent = applyEffectParameters.GetComponentFromOccupant <UnitPushableComponent>(); if (pushableComponent != null) { var vectorToDirection = GridHelper.VectorToDirection(applyEffectParameters.Direction); var collisionResults = applyEffectParameters.Helper.GetCollisions(pushableComponent.Unit, vectorToDirection); collisionResults.ForEach(result => { effectPreview.RegisterHealthChange(result, UnitPushableComponent.DamageOnCollision); effectPreview.RegisterCollision(result); }); effectPreview.RegisterPush(applyEffectParameters.Receiver, vectorToDirection); } }