예제 #1
0
    public void Damage(float dmg)
    {
        if (dmg > 0 && health > 0)
        {
            if (!invisible)
            {
                health -= dmg;
                if (au)
                {
                    au.pitch = Random.Range(0.75f, 1.25f);
                }

                if (health <= 0)
                {
                    health = 0;
                    if (mobController)
                    {
                        mobController.Dead();
                    }
                    if (fbc)
                    {
                        fbc.Death();
                    }
                    Death();
                }
                else
                {
                    anim.SetTrigger("Hurt");
                    if (fbc)
                    {
                        fbc.Hurt();
                    }
                    if (mobController)
                    {
                        mobController.Hurt();
                    }
                    if (hurtClips.Count > 0)
                    {
                        au.PlayOneShot(hurtClips[Random.Range(0, hurtClips.Count)]);
                    }
                }

                if (health > 0)
                {
                    StartCoroutine("InvisibleFrames");
                }

                if (player)
                {
                    GameManager.instance.playerController.Hurt(0.75f, "", null);
                    GameManager.instance.gui.SetHealth();
                }
            }
        }
    }
예제 #2
0
    void Awake()
    {
        string mtRecieverName = "";

        if (mt)
        {
            mtRecieverName = mt.recieverName;
        }

        StateManager.instance.SetStatefulObject(gameObject.name, activeOnStart, mtRecieverName, transform.position);

        if (StateManager.instance.GetActive(gameObject.name) == false) //is inactive?
        {
            gameObject.SetActive(false);
        }
        if (mt)
        {
            mt.SetRecieverName(StateManager.instance.GetRecieverName(gameObject.name));
        }
        if (interactive)
        {
            interactive.SetActiveDialog(StateManager.instance.GetActiveDialog(gameObject.name)); // set index
        }
        if (anim)
        {
            SetAnimatorBoolsOnAwake();
        }
        if (mobController)
        {
            if (StateManager.instance.GetMobDead(gameObject.name)) // if mob is dead
            {
                mobController.health.StopSound();
                mobController.Dead();
            }
        }

        GameManager.instance.AddStateful(this);
        //print("AddStateful " + gameObject.name);
        if (tag != "MapMarker")
        {
            Vector3 tempPos = StateManager.instance.GetStatefulPosition(gameObject.name);
            if (tempPos != new Vector3(0, -100f, 100f))
            {
                transform.position = tempPos;
            }
        }
    }