private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.CompareTag(enemyTag))
        {
            enemy = collision;
            barraDeAdrenalina.fillAmount += 0.08f;
            if (GetComponentInParent <SpriteRenderer>().flipX == false)
            {
                GameObject podeUsar = traces.GetPooledObject();
                if (podeUsar != null)
                {
                    podeUsar.transform.position = transform.position;
                    podeUsar.SetActive(true);
                }
                //Instantiate(enemyTraces, collision.transform.position, Quaternion.identity);
            }
            else
            {
                GameObject podeUsar = traces.GetPooledObject();
                if (podeUsar != null)
                {
                    podeUsar.transform.position = transform.position;
                    podeUsar.SetActive(true);
                }
                flipParticles.Invoke();
                //Instantiate(enemyTraces, collision.transform.position, Quaternion.identity);
            }
            collision.gameObject.GetComponent <Animator>().enabled = false;
            //collision.gameObject.GetComponent<Rigidbody2D>().isKinematic = true;
            //collision.gameObject.GetComponent<BoxCollider2D>().enabled = false;
            GameManager.Instance.SfxPlayer(killGuard);
            iTween.PunchScale(collision.gameObject, new Vector2(3, 4), 1);
            print(collision.gameObject.GetComponent <Renderer>().material.color);
            iTween.ColorTo(collision.gameObject, new Color(0, 0, 0, 0), .5f);
            iTween.PunchPosition(collision.gameObject, iTween.Hash(
                                     "amount", new Vector3(1, 2, 0),
                                     "time", .35f,
                                     "oncomplete", "DeactivateEnemy",
                                     "oncompletetarget", gameObject));

            //GameObject.FindWithTag(enemyTag).SetActive(false);

            //Invoke("Deactivate", .5f);
            //Destroy(collision.gameObject,.5f);
        }

        /*if (collision.gameObject.CompareTag(strongerEnemyTag))
         * {
         *  danoSET--;
         *  barraDeAdrenalina.fillAmount += 0.05f;
         *  Instantiate(enemyTraces, transform.position, Quaternion.identity);
         *  if(danoSET <= 0)
         *      Destroy(collision.gameObject);
         * }*/
    }
示例#2
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.CompareTag(enemyTag))
        {
            barraDeAdrenalina.fillAmount += 0.08f;
            if (GetComponentInParent <SpriteRenderer>().flipX == false)
            {
                GameObject podeUsar = traces.GetPooledObject();
                if (podeUsar != null)
                {
                    podeUsar.transform.position = transform.position;
                    podeUsar.SetActive(true);
                }
                //Instantiate(enemyTraces, collision.transform.position, Quaternion.identity);
            }
            else
            {
                GameObject podeUsar = traces.GetPooledObject();
                if (podeUsar != null)
                {
                    podeUsar.transform.position = transform.position;
                    podeUsar.SetActive(true);
                }
                //Instantiate(enemyTraces, collision.transform.position, Quaternion.identity);
                enemyTraces.velocityOverLifetime.x.Equals(-posicoesNegativadas);
            }
            collision.gameObject.GetComponent <Animator>().enabled = false;
            //collision.gameObject.GetComponent<Rigidbody2D>().isKinematic = true;
            collision.gameObject.GetComponent <BoxCollider2D>().enabled = false;
            GameManager.Instance.SfxPlayer(killGuard);
            iTween.PunchScale(collision.gameObject, new Vector2(3, 4), 1);
            iTween.PunchPosition(collision.gameObject, new Vector2(1, 2), 3);
            iTween.ColorTo(collision.gameObject, new Color(0, 0, 0, 0), .5f);


            //Invoke("Deactivate", .5f);
            Destroy(collision.gameObject, .5f);
        }

        /*if (collision.gameObject.CompareTag(strongerEnemyTag))
         * {
         *  danoSET--;
         *  barraDeAdrenalina.fillAmount += 0.05f;
         *  Instantiate(enemyTraces, transform.position, Quaternion.identity);
         *  if(danoSET <= 0)
         *      Destroy(collision.gameObject);
         * }*/
    }
 void DetectPropPlayer()
 {
     foreach (Transform hand in playerHands)
     {
         pickUp = Physics.OverlapSphere(hand.position, getRange, propPlayerLayer);
         foreach (Collider picks in pickUp)
         {
             print("Hitted:" + picks.transform.name);
             bool isAPlayer = picks.transform.CompareTag("PropPlayer");
             if (isAPlayer)
             {
                 picks.transform.gameObject.SetActive(false);
                 PropHuntManager.numeroDePlayersPegos += 1;
                 gameMasterScore.ThisPlayerScore      += 25;
                 //print("Player Detected. Adding up " + ScoreManager.Instance.pontuacaoGeral + "points to the GameMaster");
                 GameObject aux = effectPooling.GetPooledObject();
                 if (aux != null)
                 {
                     aux.transform.position = picks.transform.position;
                     aux.transform.rotation = picks.transform.rotation;
                     aux.SetActive(true);
                 }
             }
             else
             {
                 print("Not a Player");
                 // return;
             }
         }
     }
 }
 //selects tower with a button click
 public void SelectTower()
 {
     PlayerInteraction.instace.DisableDocks();
     if (GameManager.instance.Money >= tower.buyoutCost)
     {
         PlayerInteraction.instace.EnableHighlight(tower, towerToPool.GetPooledObject());
     }
 }
 private void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.gameObject.CompareTag("ColisionDeath"))
     {
         transform.position = GameManager.Instance.spawnPoint.position;
         //gameObject.SetActive(false);
         playerDies.SfxPlayer(death);
         GameObject podeUsar = enemies.GetPooledObject();
         if (podeUsar != null)
         {
             GameManager.Instance.enemySpawnPoint.position = podeUsar.transform.position;
             podeUsar.SetActive(true);
         }
     }
 }