void OnCollisionEnter2D(Collision2D col)
    {
        if (col.gameObject.tag.Equals("FlamingSkull"))
        {
            SoundManger.PlaySound("hitSound");
            TakeDamage(10);
        }
        if (col.gameObject.tag.Equals("Goblin"))
        {
            SoundManger.PlaySound("hitSound");
            TakeDamage(20);
        }
        if (col.gameObject.tag.Equals("Spikes"))
        {
            SoundManger.PlaySound("hitSound");
            TakeDamage(100);
        }
        if (col.gameObject.tag.Equals("Boss"))
        {
            SoundManger.PlaySound("hitSound");
            TakeDamage(25);
        }

        if (currentHealth <= 0)
        {
            Instantiate(blood, transform.position, Quaternion.identity);
            animator.SetTrigger("dead");
            gameOverText.SetActive(true);
            restartButton.SetActive(true);
        }
    }
Example #2
0
    void Awake()
    {
        if (instance == null) instance = this;
        else if (instance != this) Destroy(gameObject);

        DontDestroyOnLoad(gameObject);
    }
Example #3
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
         DontDestroyOnLoad(gameObject);
     }
     else
     {
         Destroy(gameObject);
     }
 }
Example #4
0
 // Roll the die, blocking other tasks
 public IEnumerator Roll()
 {
     rolling = true;
     transform.localPosition = new Vector3();
     AddTorque();
     AddForce();
     SoundManger.PlayDiceRollSound();
     yield return new WaitForSeconds(3);
     if (GetResult() == -1)
     {
         yield return Roll(); // If the die lands on its side or between two values, re-roll
     }
     rolling = false;
 }
Example #5
0
    void Awake()
    {
        if (Instance == null)
        {
            Instance = this;
        }
        else if (Instance != this)
        {
            Destroy(gameObject);
        }

        AudioSource theSource = GetComponent <AudioSource>();

        soundEffectAudio = theSource;
    }
    public float highPitchRange = 1.05f;            //The highest a sound effect will be randomly pitched.



    void Awake()
    {
        //Check if there is already an instance of SoundManager
        if (instance == null)
        {
            //if not, set it to this.
            instance = this;
        }
        //If instance already exists:
        else if (instance != this)
        {
            //Destroy this, this enforces our singleton pattern so there can only be one instance of SoundManager.
            Destroy(gameObject);
        }

        //Set SoundManager to DontDestroyOnLoad so that it won't be destroyed when reloading our scene.
    }
Example #7
0
    // Use this for initialization
    void Start()
    {
        if (Instance == null)
        {
            Instance = this;
        }
        else if (Instance != this)
        {
            Destroy(gameObject);
        }
        AudioSource[] sources = GetComponents <AudioSource>();

        foreach (AudioSource source in sources)
        {
            if (source.clip == null)
            {
                SoundEffectAudio = source;
            }
        }
    }
Example #8
0
        // Move a piece on the board
        public IEnumerator MovePiece(ChessMove chessMove, bool attackOnly)
        {
            ChessPiece initialPiece = ChessGrid.GetPosition(chessMove.InitialSquare);
            string     notation     = UIManager.BuildNotation(initialPiece.type, chessMove.InitialSquare, chessMove.TargetSquare, chessMove.Attack);
            Color      color        = Color.white;

            // Assume it will succeed if not an attack
            bool success = true;

            if (chessMove.Attack)
            {
                // Update attacking text
                ChessPiece targetPiece = ChessGrid.GetPosition(chessMove.TargetSquare);
                int        minNeeded   = CaptureMatrix.GetMin(initialPiece.type, targetPiece.type, chessMove.AddOne);
                Game.Controller.uiManager.UpdateAttack(UIManager.BuildNotation(initialPiece.type,
                                                                               chessMove.InitialSquare, chessMove.TargetSquare, true) + " - " + minNeeded + "+ needed.");

                // Only do the die roll if it is not a king attacking a pawn (this move is automatic)
                if (!(initialPiece.type == "king" && targetPiece.type == "pawn"))
                {
                    yield return(Game.Controller.die.Roll());

                    int num = Game.Controller.die.GetResult();
                    success = num >= minNeeded;
                }

                // Set color of move history text
                color = success ? Color.green : Color.red;
            }

            // set commander as having moved
            initialPiece.GetCommander().SetMoved();

            // Add move history record
            Game.Controller.uiManager.InsertMoveRecord(notation, false, color);

            if (success)
            {
                if (chessMove.Attack)
                {
                    // Play sounds
                    SoundManger.PlayAttackSuccessSound();
                    yield return(new WaitForSeconds(0.7f));

                    SoundManger.PlayCaptureSound();

                    ChessPiece targetPiece = ChessGrid.GetPosition(chessMove.TargetSquare);
                    // if king was taken, a player has won the game
                    if (targetPiece.type == "king")
                    {
                        Game.Winner(targetPiece.Owner.Name == "player1" ? "player2" : "player1");
                    }
                    targetPiece.transform.GetChild(0).GetComponent <SpriteRenderer>().enabled = false;   // Disable commander icon on this piece

                    // transition command authority to king if bishop was captured
                    if (targetPiece.type == "bishop")
                    {
                        Player player = targetPiece.Owner;
                        player.RemainingMoves--;
                        if (targetPiece.Owner == PovManager.Instance.Pov)
                        {
                            CommandDelegation.Instance.DisableButton(targetPiece.GetDivision());
                        }
                        player.TransitionCommand(targetPiece.GetDivision());
                    }

                    // move piece to graveyard
                    Graveyard grave = targetPiece.Owner.Name == "player1" ? player1Graveyard : player2Graveyard;
                    targetPiece.moveable = false;
                    targetPiece.dragging = true;
                    ChessGrid.Captured.Add(targetPiece);
                    grave.AddToGrave(targetPiece.gameObject.transform);
                }

                // If piece moves to the square it attacked (not an archer)
                if (!attackOnly)
                {
                    SoundManger.PlayMoveSound();
                    ChessGrid.SetPositionEmpty(initialPiece.Position);
                    ChessGrid.SetPosition(chessMove.TargetSquare, initialPiece);
                    initialPiece.SpriteRenderer.sortingOrder = 1;
                    initialPiece.Position = chessMove.TargetSquare;
                }
                else
                {
                    ChessGrid.SetPositionEmpty(chessMove.TargetSquare);
                }
            }
            else
            { // Attack Failed
                Game.Controller.lastMoveFailed = true;
                SoundManger.PlayAtackFailedSound();
            }

            // Increment turn regardless of fail/success
            DestroyMovePlates();
            Game.Controller.IncrementTurnCounter();
        }
Example #9
0
 // Use this for initialization
 void Start()
 {
     startLives = playerLives;                  // set our start lives
     sm         = GetComponent <SoundManger>(); // get our sound manager componenet
     AS         = GetComponent <AudioSource>(); // get our auido source component
 }
Example #10
0
        public HttpResponseMessage English(string empId)
        {
            ISoundManager manager = new SoundManger(AppDomain.CurrentDomain.BaseDirectory + "\\Sounds\\English\\");

            return(ReturnBytes(manager.GetEnglishSound(empId), "english"));
        }
Example #11
0
        public HttpResponseMessage Khmer(string empId)
        {
            ISoundManager manager = new SoundManger(AppDomain.CurrentDomain.BaseDirectory + "\\Sounds\\Khmer\\");

            return(ReturnBytes(manager.GetKhmerSound(empId), "khmer"));
        }
Example #12
0
 private void Start()
 {
     soundMgr = SoundManger.instance;
 }
Example #13
0
 void OnDestroy()
 {
     instance = null;
 }
Example #14
0
 void Start()
 {
     instance = this;
     source   = GameObject.Find("SoundManager").transform.GetChild(0).GetComponent <AudioSource>();
 }
Example #15
0
 private void Awake()
 {
     _instance = this;
 }