Ejemplo n.º 1
0
    internal void Initialize(Projectile projectile)
    {
        Element[] projectileElements = projectile.elements.ToArray();
        damage              = ElementUtility.ProjectileDamage(projectileElements);
        bouncesLeft         = ElementUtility.Bounces(projectileElements);
        chainLength         = ElementUtility.ChainLength(projectileElements);
        speed               = ElementUtility.ProjectileSpeed(projectileElements);
        AOEDamageDealer     = new AOEDamageDealer(ElementUtility.AoE(projectileElements) * projectile.areaOfEffectMultiplier, transform, projectile.elements);
        primaryMovementType = ElementUtility.Movement(projectile.elements.Peek());
        this.projectile     = projectile;
        switch (primaryMovementType)
        {
        case ProjectileMovementType.BounceOnGround:
            Parabola[] parabolas = ParabolaCalculator.CalculateFullTrajectory(transform.position, projectile.target.position,
                                                                              ElementUtility.ProjectileSpeed(projectileElements), transform.position.y, 0, bouncesLeft);
            projectileMover = new ProjectileMover(transform, parabolas, ElementUtility.ProjectileSpeed(projectile.elements.ToArray()) * projectile.speedMultiplier);
            break;

        case ProjectileMovementType.StraightChain:
            projectileMover = new ProjectileMover(transform, projectile.target, ElementUtility.ProjectileSpeed(projectile.elements.ToArray()) * projectile.speedMultiplier);
            break;

        case ProjectileMovementType.AOEAtTower:
            projectileMover = new ProjectileMover(projectile.speedMultiplier * speed, 0, transform);
            OnAOEAtTowerActivation();
            break;
        }
    }