Пример #1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (GameManager2Dplat.SI.currentGameState == GameState.InGame)
        {
            if (collision.name == "Point")
            {
                if (playerRB.velocity.y <= 0)
                {
                    collision.GetComponentInParent <NavScript>().die();
                    superJump(enemyJumpBounce);
                    SoundControllerPlatform.SI.playSound("EnemyJump");
                    Destroy(collision);
                    GameManager2Dplat.SI.addScore(5);
                }
            }
            else if (collision.gameObject.CompareTag("Respawn"))
            {
                Destroy(collision);
                LvlGenerator.SI.destroyLastLvl();
                LvlGenerator.SI.addLvl();
            }
            else if (collision.gameObject.CompareTag("Finish") && playerAnim.GetBool(IS_ALIVE))
            {
                GameManager2Dplat.SI.gameOver();
            }
            else if (collision.CompareTag("poti"))
            {
                potionScript poti = collision.GetComponent <potionScript>();
                switch (poti.getPotiType())
                {
                case potiType.energy:
                {
                    winEnergy(poti.getPotiValue());
                    break;
                }

                case potiType.health:
                {
                    winLife(poti.getPotiValue());
                    break;
                }
                }
                Destroy(collision.gameObject);
            }
        }
    }
Пример #2
0
    void OnTriggerEnter2D(Collider2D collision)
    {
        if (!string.IsNullOrEmpty(tagActionFilter) && !collision.CompareTag(tagActionFilter))
        {
            return;
        }

        var action = collision.GetComponent <PlayerAction>();

        if (action)
        {
            if (!mActInvokes.Exists(action))
            {
                mActInvokes.Add(action);
            }
        }
    }
 void OnTriggerExit2D(Collider2D coll)
 {
     if (coll.CompareTag("player"))
     {
         anim.GetComponent <Animator>().SetBool("SpecialAttack", false); //przekazanie arguemntu do animacji
         anim.GetComponent <Animator>().SetBool("EnemyIsInRange", true); //przekazanie arguemntu do animacji
         anim.GetComponent <Animator>().SetBool("MeleAtack", false);     //przekazanie arguemntu do animacji
         if (Parent.transform.localScale.x > 0)
         {
             mainScript.walkDir = walkDir; //ustwienei kierunek bosa
         }
         else
         {
             mainScript.walkDir = walkDir * -1; // ustwienei keirunku bosa
         }
     }
 }
Пример #4
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.CompareTag("Player"))
     {
         for (int i = 0; i < inventory.slots.Length; i++)
         {
             if (inventory.isFull[i] == false)
             {
                 //l'item se rajoute dans l'inventaire
                 inventory.isFull[i] = true;
                 Instantiate(itemButton, inventory.slots[i].transform, false);
                 Destroy(gameObject);
                 break;
             }
         }
     }
 }
Пример #5
0
    void OnTriggerStay2D(Collider2D other)
    {
        if (other.CompareTag("Projectile"))
        {
            Projectile projectile = other.GetComponent <Projectile>();

            if (projectile != null && projectile.origin != gameObject)
            {
                if (Time.time > timeBetweenHits)
                {
                    timeBetweenHits = Time.time + hitCooldown;
                    health         -= projectile.damage;
                    healWaitTime    = Time.time + outOfCombatCooldown;
                }
            }
        }
    }
Пример #6
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.CompareTag("Light"))
        {
            Debug.Log("Entered light");
            _inLight = true;

            if (_noLightFadeAudioTween != null)
            {
                _noLightFadeAudioTween.Restart();
            }
            else
            {
                _noLightFadeAudioTween = _noLightAudioPlayer.DOFade(0f, 0.25f).OnComplete(() => _noLightAudioPlayer.Stop()).SetAutoKill(false);
            }
        }
    }
Пример #7
0
 private void OnTriggerEnter2D(Collider2D coll)
 {
     if (coll.CompareTag("Player"))
     {
         Player player = coll.gameObject.GetComponent <Player>();
         player.isChangingRoom = false;
         if (!isStartingRoom && !isSafeRoom)
         {
             EnemySpawner enemySpawner          = transform.parent.Find("Enemy Spawner").GetComponent <EnemySpawner>();
             Transform    enemySpawnerTransform = enemySpawner.transform;
             Debug.Log(transform.parent.name);
             transform.parent.Find("Door Blocks").gameObject.SetActive(true);
             enemySpawner.spawnEnemies();
             isSafeRoom = true;
         }
     }
 }
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.CompareTag("Player"))
     {
         if (other.gameObject.transform.position.y >
             this.transform.position.y + killOffset)
         {
             Debug.Log("Enemy is dead");
             animator.SetBool("isDead", true);
             StartCoroutine(KillOnAnimationEnd());
         }
         else
         {
             Debug.Log("Killed player");
         }
     }
 }
Пример #9
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.CompareTag("Gold") && !gameManager.gameOver)
        {
            SoundManager.Instance.PlaySound(SoundManager.Instance.hitGold);
            ScoreManager.Instance.AddScore(1);
            gameManager.CheckAndUpdateValue();

            ParticleSystem particle = Instantiate(gameManager.hitGold, other.transform.position, Quaternion.identity) as ParticleSystem;
            var main = particle.main;
            main.startColor = other.gameObject.GetComponent<SpriteRenderer>().color;
            particle.Play();
            Destroy(particle.gameObject, 1f);
            Destroy(other.gameObject);
            gameManager.CreateTarget();
        }
    }
Пример #10
0
    private void OnTriggerStay2D(Collider2D collision)
    {
        col = collision;
        if (col.CompareTag("Finger") || col.CompareTag("PlantEdge"))
        {
            isOver = true;

            if (collision.gameObject.name == "Zuignap")
            {
                hasDelay = true;
            }
            if (collision.CompareTag("PlantEdge"))
            {
                moveSat();
            }
        }
    }
Пример #11
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (PlayerPrefs.GetInt(playerPrefKey) == 1)
        {
            return;
        }
        if (!other.CompareTag("Player"))
        {
            return;
        }

        _playerController = other.GetComponent <PlayerController>();
        _playerController.gameObject.layer = LayerMask.NameToLayer("Invincible");

        StartCoroutine(StartActionSequence());
        PlayerPrefs.SetInt(playerPrefKey, 1);
    }
Пример #12
0
 // Update is called once per frame
 void OnTriggerEnter2D(Collider2D otro)
 {
     if (otro.CompareTag("Player"))
     {
         s = "";
         panelaviso.SetActive(true);
         avisoC.text = "Presiona Z o ENTER para interactuar";
         if (Complejo)
         {
             StartCoroutine(DialogoC());
         }
         else
         {
             StartCoroutine(iniciarDialogo());
         }
     }
 }
 void OnTriggerEnter2D(Collider2D other)
 {
     //when a ball enters the trigger
     if (other.CompareTag("ball"))
     {
         //randomly decide whether to shift horizontally or vertically
         //then fire the trigger to animate in that direction
         if (Random.value <= 0.5)
         {
             flowerAnimator.SetTrigger("RustleVertical");
         }
         else
         {
             flowerAnimator.SetTrigger("RustleHorizontal");
         }
     }
 }
Пример #14
0
    private void OnTriggerEnter2D(Collider2D col)
    {
        if (col.CompareTag("unweapon"))
        {
            checkWeapon = true;
            if (destroyweapon)
            {
                Destroy(col.gameObject);
                destroyweapon = false;
            }

            if (weaponController)
            {
                idItem = weaponController.id;
            }
        }
    }
Пример #15
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.CompareTag("Player"))
     {
         if (collision.GetComponent <PlayerHealth>().health <= 1)
         {
             collision.GetComponent <PlayerHealth>().health -= 1;
             collision.GetComponent <PlayerHealth>().Death();
         }
         else
         {
             collision.GetComponent <PlayerHealth>().health -= 1;
             FindObjectOfType <audioManager>().Play("GetHit");
             collision.transform.position = respawnPoint.position;
         }
     }
 }
Пример #16
0
 void OnTriggerEnter2D(Collider2D coll)
 {
     if (coll.CompareTag("Projectile"))
     {
         hitSound.Play();
         Destroy(coll.gameObject);
         if (size == AsteroidSize.Tiny)
         {
             Destroy(gameObject);
         }
         else
         {
             Split();
             Destroy(gameObject);
         }
     }
 }
Пример #17
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.CompareTag("Bullet"))
     {
         EnemySplit();
         other.gameObject.SetActive(false);
         AddScore();
         //Dropeamos una moneda si tenemos suerte
         if (coinDrop.coinDrop)
         {
             coinPool.SpawnCoins(transform.position);
         }
         gameObject.SetActive(false);
         //restamos el conteo de enemigos activados
         _spawnController.activeEnemies--;
     }
 }
Пример #18
0
    // If the player steps on a switch that has not been
    // previously stepped on, the "moveOnce()" method
    // is called for all block instances on the level.
    // The switch's sound effect is played and the
    // "stepped on" sprite replaces the switch's original sprite.
    // wasPressed will become true, and the next time this switch
    // is stepped on, nothing will happen.
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag("Player"))
        {
            if (!wasPressed)
            {
                for (int i = 0; i < block.Length; i++)
                {
                    block[i].moveOnce();
                }

                AudioManager.Instance.PlaySoundEffect(3);
                spriteRenderer.sprite = sprite2;
                wasPressed            = true;
            }
        }
    }
Пример #19
0
    private void OnTriggerExit2D(Collider2D collision)
    {
        if (collision.CompareTag("Note"))
        {
            if (collision.GetComponent <Note>().GetNoteFlag())
            {
                theTimingManager.MissRecord();
                theEffectManager.JudgementEffect(4);
                theComboManager.ResetCombo();
            }

            theTimingManager.boxNoteList.Remove(collision.gameObject);

            ObjectPool.instance.noteQueue.Enqueue(collision.gameObject);
            collision.gameObject.SetActive(false);
        }
    }
Пример #20
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     // 부딛히는 collision을 가진 객체의 태그가 "Click"이나 "Player"일 경우
     if (collision.CompareTag("Click"))
     {
         Debug.Log("적 기체와 player 충돌");
         enemyData.decreaseHP(25);
         collision.GetComponent <Collider2D>().enabled = false;
         if (enemyData.getHP() <= 0)
         {
             Destroy(gameObject);
             ScoreBar.score += 500;
             deadEnemy++;
             Debug.Log("deadEnemy : " + deadEnemy.ToString());
         }
     }
 }
Пример #21
0
    /// <summary>
    /// When player leaves room deactivate enemies and breakables.
    /// </summary>
    /// <param name="collision"></param>
    protected virtual void OnTriggerExit2D(Collider2D collision)
    {
        if (collision.CompareTag("Player") && !collision.isTrigger)
        {
            //Deactivate the enemies and destructables.
            for (int i = 0; i < enemies.Length; i++)
            {
                ChangeActivation(enemies[i], false);
            }

            for (int i = 0; i < breakables.Length; i++)
            {
                ChangeActivation(breakables[i], false);
            }
            virtualCamera.SetActive(false);
        }
    }
Пример #22
0
        void OnTriggerStay2D(Collider2D other)
        {
            if (other.CompareTag("Player"))
            {
                detected = true;
                RaycastHit2D hit = Physics2D.Raycast(transform.position, transform.right);

                if (hit.collider.CompareTag("Ground"))
                {
                    detected = false;
                }
                else
                {
                    detected = true;
                }
            }
        }
Пример #23
0
 public override void OnTriggerEnter2D(Collider2D other)
 {
     if (other.CompareTag("Player") && !other.isTrigger)
     {
         //Activate all enemies and breakable objects
         for (int i = 0; i < enemies.Length; i++)
         {
             ChangeActivation(enemies[i], true);
         }
         for (int i = 0; i < pots.Length; i++)
         {
             ChangeActivation(pots[i], true);
         }
         ClosedDoors();
         virtualCamera.SetActive(true);
     }
 }
Пример #24
0
 private void OnTriggerExit2D(Collider2D collision)
 {
     if (collision.CompareTag("Obstacle"))
     {
         Obstacle o = collision.GetComponent <Obstacle>();
         obstacles.Remove(o);
         if (obstacles.Count == 0)
         {
             parentRenderer.sortingOrder = 200;
         }
         else
         {
             obstacles.Sort();
             parentRenderer.sortingOrder = obstacles[0].MySpriteRenderer.sortingOrder - 1;
         }
     }
 }
 void OnTriggerEnter2D(Collider2D other)
 {
     // this checks if 2 spawnPoints have spawned ontop one another and neither has spawned a room yet
     // if so, they are both destroyed and a "closedRoom" is spawned instead
     // this stops some weird room spawns in the dungeon, and also prevents the player from running
     // around outside the dungeon space
     if (other.CompareTag("spawnPoint"))
     {
         var roomSpawn = other.GetComponent <roomSpawner> ();
         if (roomSpawn != null && roomSpawn.spawned == false && spawned == false)
         {
             Instantiate(templates.closedRoom, transform.position, Quaternion.identity);
             Destroy(gameObject);
         }
         spawned = true;
     }
 }
Пример #26
0
    protected override void OnTriggerEnter2D(Collider2D other)
    {
        /*
         * 有可能物体在这上面是一个反向电梯,需要减速
         */
//		public float delta_rate = 1.0f;
//		public void speed_init(GameObject other) {
//			var rb = other.GetComponent<Rigidbody2D> ();
//			rb.velocity *= delta_rate;
//		}

        base.OnTriggerEnter2D(other);
        if (other.CompareTag("Human"))
        {
            var rb = other.GetComponent <Rigidbody2D> ();
        }
    }
Пример #27
0
    void OnTriggerStay2D(Collider2D other)
    {
        if (other.CompareTag("Player") && rotParm == false)
        {
            //ぐるりんの位置を固定
            if (GetComponent <GanGanKamen.BossHand>() == null)
            {
                _gururinRb2d.MovePosition(gearPos.transform.position);
            }
            //ぐるりんの角度を固定
            _gururinRb2d.rotation = _gpQuaternion.eulerAngles.z;

            flagManager.moveStop = true;

            _gururinRb2d.velocity = Vector2.zero;
        }
    }
Пример #28
0
    bool showGUI;                                   //whether text is on screen or not

    //Activates when player enter trigger collider of one of the plates
    void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag("Puzzle_Interact"))                                                    //if the collider was on a puzzle pressure plate
        {
            square = collision.gameObject;                                                              //sets square to pressure plate object being collided with

            if (square.name == "Floor_yellow" && pressed_yellow == false)                               //if it is the yellow plate and the yellow plate hasn't been pressed
            {
                pressed_yellow = true;
                text           = "The plate clicks...";                                                 //sets text for display
                showGUI        = true;                                                                  //displays text on screen
            }
            else if (square.name == "Floor_blue" && pressed_blue == false && pressed_yellow == true)    //if it is the blue plate and the blue plate hasn't been pressed and yellow has
            {
                pressed_blue = true;
                text         = "The walls shake...";
                showGUI      = true;
            }
            else if (square.name == "Floor_red" && pressed_red == false && pressed_yellow == true && pressed_blue == true)  //if it is the red plate and red hasn't been pressed and blue and yellow have
            {
                pressed_red = true;
                text        = "The walls open!";
                showGUI     = true;
            }
            else                             //plates not pressed in right order, resets all values
            {
                pressed_blue   = false;
                pressed_yellow = false;
                pressed_red    = false;
                text           = "It resets!";
                showGUI        = true;
            }

            if (pressed_blue == true && pressed_red == true && pressed_yellow == true)  //if the puzzle has been solved by all plates baving been pressed
            {
                for (int i = 0; i < walls.GetLength(0); i++)                            //loops reveal treasure rooms by deactivating walls and overlays in array
                {
                    walls[i].SetActive(false);
                }
                for (int i = 0; i < overlays.GetLength(0); i++)
                {
                    overlays[i].SetActive(false);
                }
            }
        }
    }
Пример #29
0
    public Transform colliderChecked(ATTACK_TYPE attackType)
    {
        Collider2D hittedCollider = Physics2D.OverlapBox(attackRangeCenter.position, colliderSize, obstacleLayer);

        if (hittedCollider.CompareTag("Monster"))
        {
            MonsterController monster = hittedCollider.GetComponent <MonsterController>();
            GameManager.Instance.currentScore += monster.score;
            Debug.Log(GameManager.Instance.currentScore);
            monster.DestroyItself();
            if (attackType == ATTACK_TYPE.NORMAL)
            {
                manaGained += 1;
            }
        }
        return(null);
    }
Пример #30
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (isUsingMovementSpeed == false)
     {
         if (collision.CompareTag("Player") == true)
         {
             if (playerMovement == null)
             {
                 playerMovement = collision.GetComponent <PlayerMovement>();
             }
             isUsingMovementSpeed = true;
         }
         playerMovement.SetNewMovementSpeed(multiplySpeedBy);
         audioSource.PlayOneShot(audioClip);
         spriteRenderer.enabled = false;
     }
 }