Beispiel #1
0
    void SpawnMissile()
    {
        missile.transform.position = startPosition.position;
        missile.transform.rotation = startPosition.rotation;

        // Lifetime cannot exceed cooldown time or time to cross ability cast range
        missileLifetime = Mathf.Min(gameRules.ABLY_statusMissileMaxLifetime, 1 / cooldownDelta);

        missile.SetEffectActive(true);
        missileActive = true;

        // Rotate at a speed to just barely reach the correct orientation above the target position
        //RS = Mathf.Min(2 * (90 - initAngle) / ((targetPosition - targetUnit.transform.position).magnitude / MS), maxRS);
        RS = maxRS;
    }
Beispiel #2
0
    void SetActive(bool newActive)
    {
        if (newActive)         // About to become active
        {
            // If we are not already borrowing and there are no resources to borrow, don't activate this ability
            if (!isBorrowing && !command.TakeResources(gameRules.ABLY_healFieldResCost))
            {
                ResetCooldown();
                return;
            }

            isBorrowing = true;
            DisplayBorrowing(isBorrowing);

            if (giveResourcesCoroutine != null)
            {
                StopCoroutine(giveResourcesCoroutine);
            }
        }
        else
        {
            if (isBorrowing)
            {
                giveResourcesCoroutine = StartCoroutine(GiveResourcesCoroutine(gameRules.ABLY_healFieldResTime));
            }
        }

        isActive = newActive;

        pointEffect.SetEffectActive(isActive);
        audioLoop.SetEffectActive(isActive);
    }
Beispiel #3
0
    void SetActive(bool newActive)
    {
        isActive = newActive;

        pointEffect.SetEffectActive(isActive);
        audioLoop.SetEffectActive(isActive);
    }
Beispiel #4
0
    // Use this for initialization
    new void Start()
    {
        base.Start();

        pointEffect = Instantiate(pointEffectPrefab, transform.position, Quaternion.identity);
        pointEffect.SetEffectActive(isActive, isActive);
    }
Beispiel #5
0
    new void Update()
    {
        base.Update();

        pointEffect.transform.position = transform.position;         // Move effect to center of user

        if (isActive)
        {
            if (energy > 0)             // Needs energy to run
            {
                // Consume energy according to active duration
                energy -= deltaDurations.y * Time.deltaTime;
                Display(1 - energy);

                // Deal damage over time
                parentUnit.DamageSimple(gameRules.ABLY_selfDestructDPSSelf * Time.deltaTime, 0, false);
                parentUnit.AddFragileHealth(gameRules.ABLY_selfDestructDPSSelf * Time.deltaTime);

                // Getting closer to detonation
                if (energy < 0.5f)
                {
                    pointEffect.SetEffectActive(true, true);
                }
                else
                {
                    pointEffect.SetEffectActive(true, false);
                }
            }
            else
            {
                // Explode
                Explode();
            }
        }
        else         // Inactive
        {
            if (energy < 1)
            {
                // Restore energy according to reset duration
                energy += deltaDurations.z * Time.deltaTime;
                Display(1 - energy);
            }
        }
    }
Beispiel #6
0
    new void Update()
    {
        base.Update();

        pointEffect.transform.position = transform.position;         // Move effect to center of user
        pointEffect.transform.rotation = transform.rotation;         // Move effect to center of user

        if (isActive)
        {
            if (energy > 0)             // Needs energy to run
            {
                // Consume energy according to active duration (unless we are self destructing)
                if (!selfDestruct.GetIsActive())
                {
                    pointEffect.SetEffectActive(isActive, isActive);
                    //mainModule.simulationSpeed = 1f;

                    energy -= deltaDurations.y * Time.deltaTime;
                }
                else
                {
                    pointEffect.SetEffectActive(isActive, isActive);
                    //mainModule.simulationSpeed = 0.1f;
                }
                Display(1 - energy);
            }
            else
            {
                Toggle();                 // Toggle to inactive and put on cooldown
                StartCooldown();
            }
        }
        else         // Inactive
        {
            if (energy < 1)
            {
                // Restore energy according to reset duration
                energy += deltaDurations.z * Time.deltaTime;
                Display(1 - energy);
            }
        }
    }
Beispiel #7
0
    // Use this for initialization
    new void Start()
    {
        base.Start();

        turrets      = parentUnit.GetTurrets();
        selfDestruct = parentUnit.GetComponent <Ability_SelfDestruct>();

        pointEffect = Instantiate(pointEffectPrefab, transform.position, Quaternion.identity);
        pointEffect.SetEffectActive(isActive, isActive);
        //mainModule = pointEffect.GetMainPS().main;
    }
Beispiel #8
0
    // Use this for initialization
    new void Start()
    {
        base.Start();

        startPosition.localRotation = Quaternion.Euler(-initAngle, 0, 0);

        missile = Instantiate(missilePrefab);
        missile.SetEffectActive(false);

        explosion = Instantiate(explosionPrefab);
        explosion.SetEffectActive(false);
    }
Beispiel #9
0
    // Use this for initialization
    new void Start()
    {
        base.Start();

        command = gameManager.GetCommander(team);

        pointEffect = Instantiate(pointEffectPrefab, spinner.transform.position, Quaternion.identity);
        pointEffect.SetEffectActive(isActive);

        audioLoop = Instantiate(audioLoopPrefab, transform.position, Quaternion.identity);
        audioLoop.SetEffectActive(isActive);
    }
Beispiel #10
0
    void Explode(bool intentional)
    {
        missile.SetEffectActive(false);
        missileActive = false;

        Ability_StatusMissile_Cloud cloud = Instantiate(damageCloud, missile.transform.position, Quaternion.identity);

        cloud.SetParentUnit(parentUnit);

        explosion.transform.position = missile.transform.position;
        explosion.SetEffectActive(true);

        ClearTarget();
    }
Beispiel #11
0
    void Explode(bool intentional, RaycastHit hit)
    {
        missile.SetEffectActive(false);
        missileActive = false;

        //Ability_ionMissile_Cloud cloud = Instantiate(damageCloud, missile.transform.position, Quaternion.identity);
        //cloud.SetParentUnit(parentUnit);

        explosion.transform.position = missile.transform.position;
        explosion.transform.rotation = hit.collider ? Quaternion.LookRotation((missile.transform.forward + hit.normal * -1) / 2) : missile.transform.rotation;
        explosion.SetEffectActive(true);

        Reset();
    }
Beispiel #12
0
    void SpawnMissile()
    {
        state = 2;         // Missile in the air state

        missile.transform.position = startPosition[startIndexCur].position;
        missile.transform.rotation = startPosition[startIndexCur].rotation;

        // Lifetime cannot exceed cooldown time or time to cross ability cast range
        missileLifetime = Mathf.Min(gameRules.ABLY_ionMissileMaxLifetime, 1 / cooldownDelta);

        missile.SetEffectActive(true);
        missileActive = true;

        // Rotate at a speed to just barely reach the correct orientation above the target position
        //RS = Mathf.Min(2 * (90 - initAngle) / ((targetPosition - targetUnit.transform.position).magnitude / MS), maxRS);
        RS = maxRS;

        // Change firing position
        startIndexCur++;
        if (startIndexCur > startPosition.Length - 1)
        {
            startIndexCur = 0;
        }
    }
Beispiel #13
0
    // Use this for initialization
    new void Start()
    {
        base.Start();

        shieldMod  = new ShieldMod(parentUnit, 1, ShieldModType.ShieldProject);
        abilityBar = parentUnit.hpBar.GetComponent <UI_AbilBar_ShieldProject>();
        abilityBar.SetShield(shieldMod.shieldPercent, shieldMod.shieldPercent < 0);

        lineEffect = Instantiate(lineEffectPrefab, transform.position, Quaternion.identity);
        lineEffect.SetEffectActive(0);

        pointEffect = Instantiate(pointEffectPrefab, transform.position, Quaternion.identity);
        pointEffect.SetEffectActive(false);

        audioLoop = Instantiate(audioLoopPrefab, transform.position, Quaternion.identity);
        audioLoop.SetEffectActive(false);
    }
Beispiel #14
0
    // Use this for initialization
    new void Start()
    {
        base.Start();

        foreach (Ability a in parentUnit.abilities)
        {
            if (a.GetAbilityType() == AbilityType.Superlaser)
            {
                hasSuperlaser = true;
            }
        }

        pointEffect = Instantiate(pointEffectPrefab, transform.position, Quaternion.identity);
        pointEffect.SetEffectActive(isActive);

        audioLoop = Instantiate(audioLoopPrefab, transform.position, Quaternion.identity);
        audioLoop.SetEffectActive(isActive);
    }
Beispiel #15
0
    // TODO: CLEAN UP
    void ProjectShield(Unit target)
    {
        if (target != null)                                // Normal use case
        {
            if (target.GetType() != typeof(Unit_Flagship)) // Can't drain Flagships
            {
                // If we are targeting ourselves, clear everything
                if (target == parentUnit)
                {
                    if (targetUnit)
                    {
                        Instantiate(returnEffectPrefab, shieldStart.position, shieldStart.rotation);

                        ClearTarget();
                    }
                    else
                    {
                        ResetCooldown();
                    }
                }
                else if (target.Team == team)
                {
                    if (InRange(target.transform, gameRules.ABLY_shieldProjectRangeUse))                     // Make sure target is in casting range
                    {
                        // If we successfully added a shield,
                        if (target.AddShieldMod(shieldMod))
                        {
                            // forget about previous targetUnit
                            if (targetUnit)
                            {
                                ClearTarget();
                            }

                            // and set new targetUnit and update effects accordingly
                            targetUnit  = target;
                            checkIfDead = true;

                            targetUnit.recievingAbilities.Add(this);

                            Instantiate(targetProjectEffectPrefab, targetUnit.transform.position, targetUnit.transform.rotation);

                            pointEffect.SetEffectActive(true, false);
                            audioLoop.SetEffectActive(true);

                            UpdateActiveEffects();
                        }
                        else                         // Failed to cast, don't punish player with a cooldown
                        {
                            ResetCooldown();
                        }
                    }
                    else                     // Failed to cast, don't punish player with a cooldown
                    {
                        ResetCooldown();
                    }
                }
                else
                {
                    ResetCooldown();
                }
            }
            else
            {
                ResetCooldown();
            }
        }
        else         // Shield broken
        {
            if (targetUnit)
            {
                Instantiate(breakEffectPrefab, targetUnit.transform.position, targetUnit.transform.rotation);

                ClearTarget();
            }
        }
    }
Beispiel #16
0
    new void Update()
    {
        base.Update();

        pointEffect.transform.position = transform.position;       // Move effect to center of user
        audioLoop.transform.position   = transform.position;       // Move effect to center of user

        if (isActive)
        {
            if (energy > 0)             // Needs energy to run
            {
                // Consume energy according to active duration
                energy -= deltaDurations.y * Time.deltaTime;
                Display(1 - energy);

                Collider[]  cols  = Physics.OverlapSphere(transform.position, gameRules.ABLY_armorDrainRange, gameRules.entityLayerMask);
                List <Unit> units = new List <Unit>();
                for (int i = 0; i < cols.Length; i++)
                {
                    Unit unit = GetUnitFromCol(cols[i]);

                    if (!unit)                     // Only works on units
                    {
                        continue;
                    }

                    if (units.Contains(unit))                     // Ignore multiple colliders for one unit
                    {
                        continue;
                    }

                    if (unit == parentUnit)                     // Don't add ourselves
                    {
                        continue;
                    }

                    if (unit.Type == EntityType.Flagship)                     // Can't drain Flagships
                    {
                        continue;
                    }

                    if (unit.GetHP().z <= 0)                     // They must have some armor
                    {
                        continue;
                    }

                    bool hasDrain = false;                     // Can't drain another drain-capable unit
                    foreach (Ability a in unit.abilities)
                    {
                        if (a.GetAbilityType() == AbilityType.ArmorDrain)
                        {
                            hasDrain = true;
                        }
                    }
                    if (hasDrain)
                    {
                        continue;
                    }

                    units.Add(unit);
                }

                // TODO: Sort unit list to have allies first

                int allyCount  = 0;
                int enemyCount = 0;

                for (int i = 0; i < units.Count && i < gameRules.ABLY_armorDrainMaxVictims; i++) // For each unit, subtract armor
                {
                    if (units[i].Team == parentUnit.Team)                                        // Ally
                    {
                        if (parentUnit.GetHP().z < parentUnit.GetHP().w)                         // Only damage allies if we have missing armor
                        {
                            units[i].DamageSimple(0, gameRules.ABLY_armorDrainDPSAlly * Time.deltaTime, true);
                            allyCount++;
                        }
                    }
                    else                     // Enemy
                    {
                        units[i].DamageSimple(0, gameRules.ABLY_armorDrainDPSEnemy * Time.deltaTime, true);
                        if (hasSuperlaser)
                        {
                            Status markStatus = new Status(gameObject, StatusType.SuperlaserMark);                             // TODO: Optimize?
                            markStatus.SetTimeLeft(gameRules.ABLY_armorDrainDPSEnemy * Time.deltaTime);
                            units[i].AddStatus(markStatus);
                        }
                        enemyCount++;
                    }
                }

                // Add armor to us based on number of units
                parentUnit.DamageSimple(0, -(gameRules.ABLY_armorDrainGPSEnemy + gameRules.ABLY_armorDrainGPSBonusMult * enemyCount) * (enemyCount) * Time.deltaTime, true);
                parentUnit.DamageSimple(0, -gameRules.ABLY_armorDrainGPSAlly * (allyCount) * Time.deltaTime, true);

                if ((allyCount + enemyCount) == 0)
                {
                    pointEffect.SetEffectActive(true, false);
                }
                else
                {
                    pointEffect.SetEffectActive(true, true);
                }
            }
            else
            {
                Toggle();                 // Toggle to inactive and put on cooldown
                StartCooldown();
            }
        }
        else         // Inactive
        {
            if (energy < 1)
            {
                // Restore energy according to reset duration
                energy += deltaDurations.z * Time.deltaTime;
                Display(1 - energy);
            }
        }
    }