Ejemplo n.º 1
0
    /// <summary>
    /// Immobilizes a nearby enemy
    /// </summary>
    protected override void Execute()
    {
        AudioManager.PlayClipByID("clip_activateability", transform.position);
        var   targeting = Core.GetTargetingSystem();
        float minDist   = rangeSquared;

        target = null;
        for (int i = 0; i < AIData.entities.Count; i++)
        {
            if (AIData.entities[i] is Craft && !AIData.entities[i].GetIsDead() && !FactionManager.IsAllied(AIData.entities[i].faction, Core.faction))
            {
                float d = (Core.transform.position - AIData.entities[i].transform.position).sqrMagnitude;
                if (d < minDist)
                {
                    minDist = d;
                    target  = AIData.entities[i] as Craft;
                }
            }
        }

        if (target != null)
        {
            target.AddPin();
        }
        base.Execute();
    }
Ejemplo n.º 2
0
    public override void Tick(int key)
    {
        base.Tick(key);
        if (isOnCD && Time.time > activationTime && GetActiveTimeRemaining() > 0 && !activated)
        {
            activated = true;
            AudioManager.PlayClipByID("clip_activateability", transform.position);
            var   targeting = Core.GetTargetingSystem();
            float minDist   = float.MaxValue;
            target = null;
            for (int i = 0; i < AIData.entities.Count; i++)
            {
                if (AIData.entities[i] is Craft && !AIData.entities[i].GetIsDead() && !FactionManager.IsAllied(AIData.entities[i].faction, Core.faction))
                {
                    float d = (Core.transform.position - AIData.entities[i].transform.position).sqrMagnitude;
                    if (d < minDist)
                    {
                        minDist = d;
                        target  = AIData.entities[i] as Craft;
                    }
                }
            }

            if (target != null)
            {
                target.AddPin();
            }
        }
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Immobilizes a nearby enemy
    /// </summary>
    protected override void Execute()
    {
        AudioManager.PlayClipByID("clip_activateability", transform.position);
        var   targeting = Core.GetTargetingSystem();
        float minDist   = rangeSquared;

        target = null;
        for (int i = 0; i < AIData.entities.Count; i++)
        {
            if (AIData.entities[i] is Craft && !AIData.entities[i].GetIsDead() && !FactionManager.IsAllied(AIData.entities[i].faction, Core.faction))
            {
                float d = (Core.transform.position - AIData.entities[i].transform.position).sqrMagnitude;
                if (d < minDist && !AIData.entities[i].IsInvisible)
                {
                    minDist = d;
                    target  = AIData.entities[i] as Craft;
                }
            }
        }

        if (target != null)
        {
            target.AddPin();


            var missileLinePrefab = new GameObject("Missile Line"); // create prefab and set to parent
            missileLinePrefab.transform.SetParent(transform, false);

            var missileColor = part && part.info.shiny ? FactionManager.GetFactionShinyColor(Core.faction) : new Color(0.8F, 1F, 1F, 0.9F);

            // I use this prefab as one of the active lines on the missile
            // because what's the point in not doing it this way

            LineRenderer lineRenderer = missileLinePrefab.AddComponent <LineRenderer>();             // add line renderer
            lineRenderer.material = ResourceManager.GetAsset <Material>("white_material");           // get material
            MissileAnimationScript comp = missileLinePrefab.AddComponent <MissileAnimationScript>(); // add the animation script
            foreach (var part in target.GetComponentsInChildren <ShellPart>())
            {
                var x = Instantiate(missileLinePrefab, part.transform); // instantiate
                x.GetComponent <MissileAnimationScript>().Initialize(); // initialize
                x.GetComponent <MissileAnimationScript>().lineColor = missileColor;
                Destroy(x, activeDuration);
            }
        }

        base.Execute();
    }