Пример #1
0
    void HitVirusBehaviour(Collider2D coll)
    {
        if (HasControlStatus(coll.transform))
        {
            // the colliding object must have control status
            ControlStatus targetCS = coll.transform.GetComponent <ControlStatus> ();

            // verify that the enemy is not controlled by anything else
            if (NotControlled(coll.transform) == false)
            {
                // if the enemy is controlled by something else,
                // paralyze the target
                VirusActions va = coll.transform.GetComponent <VirusActions> ();
                if (va)
                {
                    va.Paralyze(paralyzeTime);
                }
                // bullet will destroy by itself
                return;
            }

            // if the enemy is not connected to anything right now...
            // the target is now acquired by the HACKER!
            targetCS.controller = Controller.Hacker;

            // modify layer so it wont collide
            coll.gameObject.layer = LayerMask.NameToLayer(friendlyVirusLayerName);
        }
    }
Пример #2
0
    void OnCollisionEnter2D(Collision2D coll)
    {
        Transform      target = coll.collider.transform;
        ObjectIdentity oi     = target.GetComponent <ObjectIdentity> ();

        if (oi && paralyzeTargets.Contains(oi.objType))
        {
            // paralyze the target
            switch (oi.objType)
            {
            case ObjectType.Virus:
            {
                ControlStatus cs = target.GetComponent <ControlStatus> ();
                if (cs && cs.controller != Controller.None)
                {
                    VirusActions va = coll.transform.GetComponent <VirusActions> ();
                    if (va)
                    {
                        va.Paralyze(paralyzeTime);
                    }
                }
                break;
            }
            }
        }
    }
Пример #3
0
    void HitVirusBehaviour(Collision2D coll)
    {
        if (HasControlStatus(coll.transform))
        {
            // the colliding object must have control status
            ControlStatus targetCS = coll.transform.GetComponent <ControlStatus> ();

            // verify that the enemy is not controlled by anything else
            if (NotControlled(coll.transform) == false)
            {
                // if the enemy is controlled by something else,
                // paralyze the target
                VirusActions va = coll.transform.GetComponent <VirusActions> ();
                if (va)
                {
                    va.Paralyze(paralyzeTime);
                }
                // bullet will destroy by itself
                return;
            }

            // if the enemy is not connected to anything right now...
            if (!reproduced)
            {
                // the target is now acquired by the HACKER!
                targetCS.controller = Controller.Hacker;

                // modify layer so it wont collide
                coll.gameObject.layer = this.gameObject.layer;
                // stop the enemy from chasing the player
                // reproduce the bullets
                reproduced = true;

                ReproduceBullets();
                Destroy(gameObject);
            }
        }
    }