Ejemplo n.º 1
0
    private void setJump(bool YayOrNay)
    {
        //this is an example of how you would get
        //the individual character type if you want them to make
        //specialized sounds
        // audio.Play("Jump_"+name[PlayerNumber]); //this will output Jump_Bibbs for player 0, Jump Leslie for player 1, etc
        //also note, if you want to have multiple jump sounds and randomly select them, you can add
        //Random.Range[0,5] and you'll get a 0,1,2,3, or 4 (not 5).

        //here's an example of what that might look like, this will print when a player jumps
        print("Jump_" + name[PlayerNumber] + "_" + Random.Range(1, 5));

        //technically you said you might want to just go male of female for now and individual characters
        //later, for that I would recommend just copying each file (two males and two females) and still
        //using the character names, that way it's up to the voice actors later to replace their individual
        //files if you specifically name them jump_male, then you have to go through and change the code
        //yourself... so more work that way.

        //That said, if you really want male or female tags, here's how you could get that string:
        print("Jump_" + (name[PlayerNumber] == "Hobbs" || name[PlayerNumber] == "Leslie" ? "Female" : "Male"));

        if (YayOrNay)
        {
            audio.Play("Jump" + name[PlayerNumber]);
        }


        AnimState.updateAnimationState(AnimationStates.Tag.jump, YayOrNay);
    }
Ejemplo n.º 2
0
    public void DealDamage(DamageMessage message)
    {
        //if (message.friend==gameObject||message.friend == colliders)
        //return;

        if (!_canTakeDamage)
        {
            return;
        }

        if (message.damage < 0)
        {
            //heal poison
            framesDamage = 0;

            if (_currentHealth > maxHealth)
            {
                return;
            }
            _currentHealth -= message.damage;
            if (_currentHealth > maxHealth)
            {
                _currentHealth = maxHealth;
            }
            info.say("HP: " + _currentHealth, 15);
            return;
        }

        GetComponent <ShowDamage>().animateDamage();

        audio.Play("Hurt" + name[PlayerNumber]);
        if (AnimState == null)
        {
            AnimState = GetComponent <CharacterMovement_Physics>().AnimState;
        }
        AnimState.updateAnimationState(AnimationStates.Tag.damage, true);

        //print("deal damage " + message.damage);

        if (message.effect == "blur")
        {
            startBlur();
        }
        if (message.effect.Contains("poison"))
        {
            string[] tokens = message.effect.Split(',');
            int.TryParse(tokens[1], out damageRate);
            int.TryParse(tokens[2], out framesDamage);
        }

        _currentHealth -= (int)(message.damage * character.damageFactor);

        //print("PLAYER HEALTH: " + _currentHealth);
        info.say("HP: " + _currentHealth, 15);
        health.text = " " + _currentHealth;

        damageEvent.Invoke();

        if (_currentHealth <= 0)
        {
            PlayerDeath();
            _currentHealth = 0;
        }
    }