示例#1
0
 private void DrawButtons()
 {
     if (GUILayout.Button("Apply"))
     {
         WorldObstacle obstacle = (WorldObstacle)target;
         obstacle.UpdateBlocksEditMode();
     }
 }
    private bool hasTriggered = false;                          // Required for non-normal collidrs, otherwise can have multiple collisions


    //Remove the other object
    //Remove health from the player
    //Play a "hurt" gui effect
    private void OnTriggerEnter(Collider other)
    {
        WorldObstacle worldObstacle = other.gameObject.GetComponent <WorldObstacle>();

        if (worldObstacle != null && !hasTriggered)
        {
            hasTriggered = true;
            //Adjusts the player's health, and flashes the 'hurt' gui element (red).
            playerScoreController.TakeDamage(worldObstacle.attackdamage, Color.red);
            //Play a hurt sound
            AudioSource.PlayClipAtPoint(hurtSound, transform.position);
            Destroy(other.gameObject);
            hasTriggered = false;
        }
    }