Ejemplo n.º 1
0
    private EffectPreview GetPreview(Helper helper, SpawnEffectParameters parameters)
    {
        var effectResult = new EffectPreview();

        _effects.ForEach(x => x.GetPreview(effectResult, helper, parameters));
        return(effectResult);
    }
    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);
    }
Ejemplo n.º 3
0
    private ApplyEffectParameters GetApplyEffectParameters(Helper gameboardHelper, SpawnEffectParameters spawnEffectParameters)
    {
        Tile receivingTile = null;

        switch (_effectReceiver)
        {
        case EffectReceiver.Source: receivingTile = spawnEffectParameters.Source; break;

        case EffectReceiver.Target: receivingTile = spawnEffectParameters.Target; break;
        }

        var directionToTarget = GridHelper.DirectionBetween(spawnEffectParameters.Source.transform, spawnEffectParameters.Target.transform);
        var direction         = Vector2.zero;

        switch (_effectDirection)
        {
        case RelativeDirection.Forward: direction = directionToTarget; break;

        case RelativeDirection.Right: direction = -GridHelper.Cross(directionToTarget); break;

        case RelativeDirection.Back: direction = -directionToTarget; break;

        case RelativeDirection.Left: direction = GridHelper.Cross(directionToTarget); break;
        }

        receivingTile = gameboardHelper.GetTile(receivingTile.transform.GetGridPosition() + direction * _relativeOffset);

        if (receivingTile == null || OnlyAffectOccupiedTiles && receivingTile.Occupant == null || receivingTile == spawnEffectParameters.Source && !_affectUserTile)
        {
            return(null);
        }

        return(new ApplyEffectParameters(gameboardHelper, receivingTile, direction));
    }
Ejemplo n.º 4
0
    public void Apply(Helper gameboardHelper, SpawnEffectParameters spawnEffectParameters)
    {
        var applyEffectParameters = GetApplyEffectParameters(gameboardHelper, spawnEffectParameters);

        if (applyEffectParameters != null)
        {
            OnApply(applyEffectParameters);
        }
    }
Ejemplo n.º 5
0
    public void GetPreview(EffectPreview effectPreview, Helper gameboardHelper, SpawnEffectParameters spawnEffectParameters)
    {
        var applyEffectParameters = GetApplyEffectParameters(gameboardHelper, spawnEffectParameters);

        if (applyEffectParameters != null)
        {
            OnGetPreview(applyEffectParameters, effectPreview);
        }
    }
Ejemplo n.º 6
0
    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);
    }
Ejemplo n.º 7
0
 public void Apply(Helper gameboardHelper, SpawnEffectParameters spawnEffectParameters)
 {
     _effects.ForEach(x => x.Apply(gameboardHelper, spawnEffectParameters));
     Destroy(gameObject);
 }