예제 #1
0
    /// <summary>
    /// Makes the craft visible again
    /// </summary>
    public override void Deactivate()
    {
        base.Deactivate();

        craft.stealths--;

        if (craft.stealths < 0)
        {
            Debug.LogError($"Stealth is bugged, complain to Ormanus [entity name: {craft.name}, faction: {craft.faction}, count: {craft.stealths}");
        }

        if (craft.stealths == 0)
        {
            SpriteRenderer[] renderers = craft.GetComponentsInChildren <SpriteRenderer>(true);
            for (int i = 0; i < renderers.Length; i++)
            {
                var c = renderers[i].color;
                c.a = 1f;
                renderers[i].color = c;
            }
            Collider2D[] colliders = craft.GetComponentsInChildren <Collider2D>(true);
            for (int i = 0; i < colliders.Length; i++)
            {
                colliders[i].enabled = true;
            }
        }
    }
예제 #2
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();
    }