Example #1
0
    void OnTriggerEnter2D(Collider2D other)
    {
        //tenta pegar o componente do vírus
        virus = other.GetComponent <VirusProtectorMode>();

        //se não for nulo, ou seja, se for vírus
        if (virus != null)
        {
            //não funciona com HIV
            if (other.name != "virus_HIV(Clone)")
            {
                //destroi
                virus.DestroyVirus(false);
            }
        }
    }
Example #2
0
 public void InstantiateVirus(int qnt, bool isMoving)
 {
     for (int c = 0; c < qnt; c++)
     {
         tmpGO    = Instantiate(virusPrefab, startPos, Quaternion.identity) as GameObject;
         tmpVirus = tmpGO.GetComponent <VirusProtectorMode>();
         tmpVirus.transform.SetParent(transform);
         if (isMoving)
         {
             tmpVirus.StartMoving(startPos);
         }
         else
         {
             tmpVirus.StopMoving();
         }
         allVirus.Add(tmpVirus);
     }
 }
Example #3
0
    void OnTriggerEnter2D(Collider2D other)
    {
        //tenta pegar o component dos vírus
        virus = other.GetComponent <VirusProtectorMode>();

        //se não for nulo, quer dizer que tinha o componente vírus, ou seja, é um vírus
        if (virus != null)
        {
            //avisa ao vírus que a célula foi atingida
            virus.VirusEnteredTheCell();
            //diminui as vidas
            lifes--;

            //percorre todas as sprites da célula
            for (int c = 0; c < sprites.Length; c++)
            {
                //só vai ficar vermelho se ainda não estiver vermelho, evita bugar a cor da sprite
                if (!isRed[c])
                {
                    //faz o comando para tornar a sprite vermelha
                    sprites[c].DOColor(redColor, 0.3f).SetLoops(2, LoopType.Yoyo).OnComplete(CompleteColor);
                    //marca que ficou vermelho
                    isRed[c] = true;
                }
            }

            //verifica se a célula já morreu
            if (lifes <= 0)
            {
                //tira a animação que fica ligada desde o início
                if (tween != null)
                {
                    tween.Kill();
                }
                //celula destruida
                myTransform.DOScale(Vector3.zero, 1f);
                //chama o game over
                GameController.instance.interfaceScript.gameOverMenu.ShowGameOverMenu();
            }
        }
    }