Exemplo 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;
        }
    }
Exemplo n.º 2
0
 private void SetupTargeting()
 {
     towerTargeting = ElementUtility.TowerTargetingForBaseElement(elements.Peek());
     if (towerTargeting == TowerTargeting.Ground)
     {
         GenerateTargetObject();
     }
 }
Exemplo n.º 3
0
 private void DispatchDisplayParabolaRequestEvent()
 {
     CodeControl.Message.Send(new DisplayParabolaRequestEvent(
                                  projectileOrigin,
                                  ElementUtility.ProjectileSpeed(elements.ToArray()),
                                  projectileOrigin.position.y, 0,
                                  ElementUtility.Bounces(elements.ToArray()),
                                  targetController.transform));
 }
Exemplo n.º 4
0
 public void Initialize(float buildTime, Element initialElement, bool canFire)
 {
     this.canFire = canFire;
     Build(buildTime, initialElement);
     fireRate      = ElementUtility.BaseElementFireRate(initialElement);
     fireCountdown = fireRate;
     fireRange     = ElementUtility.BaseTowerRange(initialElement);
     SetupTargeting();
 }
Exemplo n.º 5
0
 /// <summary>
 /// Sets up the model and transform.
 /// Call from the 'Before' method in subclasses.
 /// </summary>
 public AbstractGeneratorTest()
 {
     if (model != null)
     {
         return; // things are already set up
     }
     model          = new RendererModel();
     elementUtil    = new ElementUtility();
     sceneGenerator = new BasicSceneGenerator();
 }
Exemplo n.º 6
0
    private void OnEnemyDamageRequested(EnemyDamageRequestEvent obj)
    {
        obj.enemy.Damage(obj.damageAmount);
        float slowAmount = ElementUtility.Slow(obj.elements.ToArray());

        if (slowAmount > 0)
        {
            obj.enemy.SlowEnemy(1f - slowAmount, 5);
        }
    }
 internal void Initialize(Projectile projectile)
 {
     this.projectile      = projectile;
     elements             = projectile.elements.ToArray();
     damage               = ElementUtility.ProjectileDamage(elements);
     damageBaseTimer      = ElementUtility.GroundHazardDuration(elements);
     damageCountdownTimer = damageBaseTimer;
     damageDealer         = new AOEDamageDealer(0.35f, transform, projectile.elements);
     duration             = ElementUtility.GroundHazardDuration(elements);
     Destroy(gameObject, duration);
 }
Exemplo n.º 8
0
 private void SetupTexts()
 {
     mainElement.text    = tower.elements.Peek().ToString();
     fireRate.text       = string.Format("{0}/s", ElementUtility.FireRate(elementsArray).ToString());
     fireRange.text      = ElementUtility.TowerRange(elementsArray).ToString();
     bounces.text        = ElementUtility.Bounces(elementsArray).ToString();
     chain.text          = ElementUtility.ChainLength(elementsArray).ToString();
     slow.text           = ElementUtility.Slow(elementsArray).ToString();
     aoe.text            = ElementUtility.AoE(elementsArray).ToString();
     damage.text         = ElementUtility.ProjectileDamage(elementsArray).ToString();
     sellButtonText.text = string.Format("Sell for: {0}", ElementUtility.SaleValue(elementsArray).ToString());
     ClearUpgradeTexts();
 }
Exemplo n.º 9
0
 private void CheckBouncesLeft()
 {
     if (bouncesLeft <= 0)
     {
         Destroy(gameObject);
     }
     else
     {
         Vector3 bounceTargetPosition = transform.position + transform.forward * 2f;
         bounceTargetPosition.y  = 0;
         bounceTargetPosition.x += 0.1f;
         Parabola[] parabolas = ParabolaCalculator.CalculateFullTrajectory(transform.position, bounceTargetPosition,
                                                                           ElementUtility.ProjectileSpeed(projectile.elements.ToArray()), transform.position.y + 1f, 0, bouncesLeft);
         projectileMover.SetParabolas(parabolas);
         primaryMovementType = ProjectileMovementType.BounceOnGround;
     }
 }
Exemplo n.º 10
0
 private void CheckAttributes()
 {
     fireRate  = ElementUtility.FireRate(elements.ToArray());
     fireRange = ElementUtility.TowerRange(elements.ToArray());
 }
Exemplo n.º 11
0
 private void OnTowerSold(TowerSoldEvent obj)
 {
     ChangeResource(ElementUtility.SaleValue(obj.tower.elements.ToArray()));
 }
Exemplo n.º 12
0
 private void SetupUpgradeTexts(Element element)
 {
     if (ElementUtility.ElementDamage(element) == 0)
     {
         damageChange.text = string.Empty;
     }
     else
     {
         damageChange.text  = string.Format("{0}{1}", ElementUtility.ElementDamage(element) >= 0f ? "+" : "-", ElementUtility.ElementDamage(element).ToString());
         damageChange.color = ElementUtility.ElementDamage(element) >= 0f ? Color.green : Color.red;
     }
     if (ElementUtility.ElementRange(element) == 0)
     {
         fireRangeChange.text = string.Empty;
     }
     else
     {
         fireRangeChange.text  = string.Format("{0}{1}", ElementUtility.ElementRange(element) >= 0f ? "+" : "-", ElementUtility.ElementRange(element).ToString());
         fireRangeChange.color = ElementUtility.ElementDamage(element) >= 0f ? Color.green : Color.red;
     }
     if (ElementUtility.ElementFireRate(element) == 0)
     {
         fireRateChange.text = string.Empty;
     }
     else
     {
         fireRateChange.text  = string.Format("{0}{1}", ElementUtility.ElementFireRate(element) >= 0f ? "+" : "-", ElementUtility.ElementFireRate(element).ToString());
         fireRateChange.color = ElementUtility.ElementDamage(element) >= 0f ? Color.green : Color.red;
     }
     if (ElementUtility.ElementBounces(element) == 0)
     {
         bounces.text = string.Empty;
     }
     else
     {
         bouncesChange.text  = string.Format("{0}{1}", ElementUtility.ElementBounces(element) >= 0f ? "+" : "-", ElementUtility.ElementBounces(element).ToString());
         bouncesChange.color = ElementUtility.ElementDamage(element) >= 0f ? Color.green : Color.red;
     }
     if (ElementUtility.ElementChain(element) == 0)
     {
         chainChange.text = string.Empty;
     }
     else
     {
         chainChange.text  = string.Format("{0}{1}", ElementUtility.ElementChain(element) >= 0f ? "+" : "-", ElementUtility.ElementChain(element).ToString());
         chainChange.color = ElementUtility.ElementDamage(element) >= 0f ? Color.green : Color.red;
     }
     if (ElementUtility.ElementAoE(element) == 0)
     {
         aoeChange.text = string.Empty;
     }
     else
     {
         aoeChange.text  = string.Format("{0}{1}", ElementUtility.ElementAoE(element) >= 0f ? "+" : "-", ElementUtility.ElementAoE(element).ToString());
         aoeChange.color = ElementUtility.ElementDamage(element) >= 0f ? Color.green : Color.red;
     }
     if (ElementUtility.ElementSlow(element) == 0)
     {
         slowChange.text = string.Empty;
     }
     else
     {
         slowChange.text  = string.Format("{0}{1}%", ElementUtility.ElementSlow(element) >= 0f ? "+" : "-", ElementUtility.ElementSlow(element).ToString());
         slowChange.color = ElementUtility.ElementDamage(element) >= 0f ? Color.green : Color.red;
     }
 }