Beispiel #1
0
 void OnParticleCollision(GameObject TargetedParticle)
 {
     print("PARTCOL: " + TargetedParticle.tag);
     if (TargetedParticle.tag == "Player")
     {
         if (GameManager.instance.playerProtected)
         {
             //print(Inventory.GetCurrentItemType().ToString());
             if (Inventory.GetCurrentItemType() == Inventory.InventoryItems.TAMPA)
             {
                 tampa.DecreaseLife();
             }
             else if (Inventory.GetCurrentItemType() == Inventory.InventoryItems.ESCUDO)
             {
                 escudo.DecreaseLife();
             }
         }
         else
         {
             GameManager.instance.scenerySounds.StopSound();
             GameManager.instance.scenerySounds2.StopSound();
             GameManager.instance.GameOver();
         }
     }
 }
Beispiel #2
0
        protected new void Update()
        {
            // Ao patrulhar
            if (!followingPlayer)
            {
                // Se estiver correndo, aumenta a ára de busca
                if (playerScript.isRunning)
                {
                    circleCollider.radius = 0.8f;
                }
                else
                {
                    circleCollider.radius = 0.6f;
                }
            }
            else
            {
                // Condição quando está escondido
                if (!playerRenderer.enabled && playerRB.bodyType == RigidbodyType2D.Kinematic)
                {
                    FollowPlayer(false);
                }
            }

            if (attackFlashlight)
            {
                healthLight--;
            }
            else if (attackFaca && faca.active && timeLeftAttack <= 0)
            {
                timeLeftAttack = AttackObject.timeAttack;
                healthMelee   -= decrementFaca;
            }
            else if (attackBastao && bastao.active && timeLeftAttack <= 0)
            {
                timeLeftAttack = AttackObject.timeAttack;
                healthMelee   -= decrementBastao;
            }

            // Ao colidir
            if (onCollision && !GameManager.instance.blocked)
            {
                if (timePower > 0)
                {
                    timePower -= Time.deltaTime;
                }
                else
                {
                    // animaçãozinha de poderzinho atacando (pode ser uma luz)
                    if (GameManager.instance.playerProtected)
                    {
                        print("PROT");
                        if (Inventory.GetCurrentItemType() == Inventory.InventoryItems.TAMPA)
                        {
                            tampa.DecreaseLife();
                        }
                        else if (Inventory.GetCurrentItemType() == Inventory.InventoryItems.ESCUDO)
                        {
                            escudo.DecreaseLife();
                        }
                    }
                    else
                    {
                        timePower = timeMaxPower;
                        ActivatePower();
                    }
                }
            }

            // Mudança de velocidade do player
            if (changeVelocity)
            {
                if (timeChangeVelocity > 0)
                {
                    timeChangeVelocity -= Time.deltaTime;
                }
                else
                {
                    playerScript.movespeed = playerScript.movespeed * factorDivideSpeed;
                    changeVelocity         = false;
                }
            }

            if (timeLeftAttack > 0)
            {
                timeLeftAttack -= Time.deltaTime;
            }

            if (healthLight <= 0)
            {
                GameManager.instance.pathCat += addPath;
                if (emmitter)
                {
                    emmitter.currentMinions--;
                }
                Destroy(gameObject);
                // animação + som
            }
            else if (healthMelee <= 0)
            {
                GameManager.instance.pathBird += addPath;
                if (emmitter)
                {
                    emmitter.currentMinions--;
                }
                Destroy(gameObject);
                // animação + som
            }

            base.Update();
        }