public void killVirus(string ghostName)
    {
        GameObject virusGo = _virusesGOs[ghostName];

        if (virusGo == null)
        {
            return;
        }

        // kill virus
        VirusAI ai = virusGo.GetComponent <VirusAI>();

        if (ai.state == VirusAIState.Dead)
        {
            return;
        }

        ai.state = VirusAIState.Dead;

        // deactivate collisions
        Collider ghostCollider  = virusGo.GetComponent <Collider>();
        Collider pacmanCollider = _robertGO.GetComponent <Collider>();

        Physics.IgnoreCollision(ghostCollider, pacmanCollider, true);

        // give points to robert
        if (_robertGO.GetComponent <RobertAI>().powerTime <= 0f)
        {
            _virusScoreMultiplier = 1;
        }
        _robertData.score     += Score.Virus * _virusScoreMultiplier;
        _virusScoreMultiplier *= Score.VirusEatenMultiplierFactor;
    }
Beispiel #2
0
 public void OnCollisionEnter(Collision collision)
 {
     if (collision.transform.gameObject.tag == Tags.Ghost)
     {
         VirusAI virusAi = collision.transform.gameObject.GetComponent <VirusAI>();
         if (virusAi.state != VirusAIState.Dead)
         {
             explode();
         }
     }
 }
    public void Start()
    {
        GameObject ghostBody = transform.Find(Tags.GhostBody).gameObject;

        bodyRenderer       = ghostBody.GetComponent <Renderer>();
        chaseMaterial      = bodyRenderer.materials[0];
        frightenedMaterial = bodyRenderer.materials[1];
        materialIndex      = 0;
        ai        = GetComponent <VirusAI>();
        lastState = VirusAIState.Chase;
    }
    protected void FindClosestMalware()
    {
        if (ActiveSubroutines.MalwareList.Count == 0)
        {
            this.lockedMalware = null;
            this.lockedVirus = null;
            this._lockedTarget = null;
            return;
        }

        float range = 500;
        //comparing range squared vs magnitude squared is a performance enhancement
        //it eliminates the expensive square root calculation
        float closest = range * range;
        foreach (IMalware mal in ActiveSubroutines.MalwareList)
        {
            if (mal.IsLurking())
                continue;

            float dist = (mal.transform.position - this.transform.position).sqrMagnitude / mal.AttackPriority;
            //if this has a higher priority than now
            //and the distance is closer
            if (dist < closest)
            {
                if (!this.Function.OnlyTrackActiveViruses || (mal is VirusAI))
                {
                    _lockedTarget = mal.transform;
                    this.lockedMalware = mal;

                    if (mal is VirusAI)
                        this.lockedVirus = mal as VirusAI;

                    closest = dist;
                }
            }
        }
    }
 public override void awake()
 {
     gameManager.registerVirus(gameObject.name, gameObject);
     ai = GetComponent <VirusAI>();
 }