Ejemplo n.º 1
0
    public void TakeDamage(int attack)
    {
        if (state == PlayerState.Death)
        {
            return;
        }
        float def  = EquipmentUI._instance.def + ps.def + ps.def_plus;
        float temp = attack * ((200 - def) / 200);

        if (temp < 1)
        {
            temp = 1;
        }

        float value = Random.Range(0f, 1f);

        if (value < miss_rate)  //MISS
        {
            AudioSource.PlayClipAtPoint(miss_sound, transform.position);
            hudtext.Add("MISS", Color.gray, 1);
        }
        else
        {
            hudtext.Add("-" + temp, Color.red, 1);
            ps.hp_remain -= (int)temp;
            StartCoroutine(ShowBodyRed());
            if (ps.hp_remain <= 0)
            {
                state = PlayerState.Death;
            }
        }
        HeadStatusUI._instance.UpdateShow();
    }
Ejemplo n.º 2
0
    public void TakeDamage(int attack)
    {
        if (state == WolfState.Death)
        {
            return;
        }
        target = GameObject.FindGameObjectWithTag(tags.player).transform;
        state  = WolfState.Attack;
        float value = UnityEngine.Random.Range(0, 1f);

        if (value < miss_rate)
        {
            AudioSource.PlayClipAtPoint(miss_sound, transform.position);
            hudtext.Add("Miss", Color.gray, 1);
        }
        else
        {
            hudtext.Add("-" + attack, Color.red, 1);
            this.hp -= attack;
            StartCoroutine(showbodyRed());
            isattacked   = true;
            attack_timer = 0;
            if (hp <= 0)
            {
                state = WolfState.Death;
                Destroy(this.gameObject, 2);
            }
        }
    }
Ejemplo n.º 3
0
    public void TakeDamage(int damageValue)
    {
        if (state == WolfState.Death)
        {
            return;
        }

        float value = Random.Range(0f, 1f);

        target = GameObject.FindGameObjectWithTag(Tags.player).transform;
        state  = WolfState.Attack;
        if (value <= dodgeProbability)
        {
            AudioSource.PlayClipAtPoint(missAudio, transform.position);
            hudText.Add("Miss", Color.gray, 1);
            return;
        }

        hudText.Add("-" + damageValue, Color.red, 1);
        StartCoroutine(ChangeBodyRed());
        hp -= damageValue;
        if (hp <= 0)
        {
            state = WolfState.Death;
        }
        else
        {
            animation.Play(takeDamageAnimationName);
        }
    }
Ejemplo n.º 4
0
    public void TakeDamage(int attack)  //受到伤害
    {
        if (state == WolfState.Death)
        {
            return;
        }

        target = GameObject.FindGameObjectWithTag(Tags.player).transform;  //受到攻击的时候小狼进行自动攻击
        state  = WolfState.Attack;

        float value = Random.Range(0f, 1f);

        if (value < miss)                                                //miss
        {
            AudioSource.PlayClipAtPoint(miss_sound, transform.position); //miss时候的声音
            hudText.Add("Miss", Color.grey, 0.1f);                       //显示miss效果
        }
        else  //打中
        {
            hp -= attack;
            hudText.Add("-" + attack, Color.red, 0.1f); //显示掉血量
            StartCoroutine(ShowBodyRed());              //使用协同方法
            if (hp <= 0)
            {
                state = WolfState.Death;
                Destroy(gameObject, 2);
            }
        }
    }
Ejemplo n.º 5
0
    /// <summary>
    /// 受到伤害
    /// </summary>
    public void TakeDamage(int attack)
    {
        if (state == WolfState.Death)
        {
            return;
        }

        //转换为攻击状态
        state = WolfState.Attack;
        //target会被设置为null,所以要每一次受伤都设置
        target = player.transform;

        float value = Random.Range(0f, 1f);

        //miss效果
        if (value < miss)
        {
            AudioSource.PlayClipAtPoint(missSound, transform.position);
            hudText.Add("Miss", Color.gray, 1);
        }
        //打中
        else
        {
            ShowEffect();
            //掉血多少
            hudText.Add("-" + attack, Color.red, 1);

            hp -= attack;
            if (hp <= 0)
            {
                state = WolfState.Death;
            }
        }
    }
Ejemplo n.º 6
0
    public void TakeDamage(int attack)  //受到伤害
    {
        if (state == WolfState.Death)
        {
            return;
        }
        target = GameObject.FindGameObjectWithTag(Tags.player).transform;
        state  = WolfState.Attack;
        float value = Random.Range(0f, 1f);

        if (value < miss_rate)  // Miss效果
        {
            AudioSource.PlayClipAtPoint(miss_sound, transform.position);
            hudtext.Add("Miss", Color.gray, 1);
        }
        else    //打中的效果
        {
            hudtext.Add("-" + attack, Color.red, 1);
            this.hp -= attack;
            StartCoroutine(ShowBodyRed());
            if (hp <= 0)
            {
                state = WolfState.Death;
                Destroy(this.gameObject, 2);
            }
        }
    }
Ejemplo n.º 7
0
    public void TakeDamage(int attack)
    {
        if (state == PlayerState.Death)
        {
            return;
        }

        float def  = Equipment._Instance.defend + ps.def + ps.def_plus;
        float temp = attack * ((200 - def) / 200);

        if (temp < 1)
        {
            temp = 1;
        }

        float value = Random.Range(0f, 1f);

        if (value < missRate)
        {
            AudioSource.PlayClipAtPoint(missSound, transform.position);
            hudtext.Add("MISS", Color.gray, 1);
        }
        else
        {
            hudtext.Add("-" + temp, Color.red, 1);
            ps.hpRemain -= temp;
            if (ps.hpRemain <= 0)
            {
                ps.hpRemain = 0;
                state       = PlayerState.Death;
            }
        }
    }
Ejemplo n.º 8
0
    //玩家受到攻擊
    public void TakeDamage(int attack)
    {
        if (state == PlayerState.Death)
        {
            return;                                   //死亡就不做任何動作
        }
        float def  = ps.def;
        float temp = attack * ((200 - def) / 200);  //當def大於200 可把所有傷害抵銷

        print("有");
        if (temp < 1)
        {
            temp = 1;
        }

        float value = Random.Range(0f, 1f);

        if (value < miss_rate)//Miss效果
        {
            AudioSource.PlayClipAtPoint(miss_sound, transform.position);
            hudtext.Add("MISS", Color.gray, 1);
            print("玩家顯示MISS");
        }
        else// 打中的效果
        {
            hudtext.Add("-" + temp, Color.red, 1);  //減多少血
            ps.hp_remain -= (int)temp;
            StartCoroutine(ShowBodyRed());
            if (ps.hp_remain <= 0)
            {
                state = PlayerState.Death;
            }
        }
        HeadStatusUI._instance.UpdateShow();
    }
Ejemplo n.º 9
0
    public void TakeDamage(int attack)  //受伤扣血
    {
        int def  = ps.def + ps.def_plus;
        int temp = attack - (int)(def * 0.5);  //扣血公式,当小于1的时候,默认扣1

        if (temp < 1)
        {
            temp = 1;
        }
        float value = Random.Range(0f, 1f);

        if (value < miss_rate)
        {
            AudioSource.PlayClipAtPoint(miss_sound, transform.position);
            hudText.Add("miss", Color.grey, 0.1f);
        }
        else
        {
            //打中
            ps.hp_remain -= temp;
            hudText.Add("-" + temp, Color.red, 0.1f);  //显示掉血量
            HeadStatus.instance.UpdateShow();

            StartCoroutine(ShowBodyRed());  //使用协同方法
            if (ps.hp_remain <= 0)
            {
                state = PlayerState.Death;
            }
        }
        if (state == PlayerState.Death) //如果死亡就播放死亡动画
        {
            DieScript.instance.DeadWindow();
            GetComponent <Animation>().CrossFade(aniname_death);
        }
    }
Ejemplo n.º 10
0
    public void ShowAnger(int anger)
    {
        string txt = anger.ToString();

        if (anger > 0)
        {
            txt = "+" + txt;
        }
        mAngerText.Add(txt, Color.yellow, JumbTextDuration);
    }
Ejemplo n.º 11
0
 //Break the multiplier
 public void BreakMultiplier()
 {
     multiplier            = 0;
     _multiplierLabel.text = multiplier + "x";
     if (currentStreak > 0)
     {
         _multiplierHUDText.Add("Lost Multiplier", Color.red, 0.6f);
     }
     currentStreak = 0;
 }
Ejemplo n.º 12
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         text.Add(-10, Color.red, 1f);
     }
     else if (Input.GetMouseButtonDown(1))
     {
         text.Add(10, Color.green, 1f);
     }
 }
 private void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         hudText.Add(-10, Color.red, 1);
     }
     if (Input.GetMouseButtonDown(1))
     {
         hudText.Add(+10, Color.green, 1);
     }
 }
Ejemplo n.º 14
0
 void OnHover(bool isOver)
 {
     if (mText != null && isOver && !mHover)
     {
         mHover = true;
         mText.Add("Left-click, right-click", Color.cyan, 2f);
     }
     else if (!isOver)
     {
         mHover = false;
     }
 }
Ejemplo n.º 15
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         hUDText.Add(-10, Color.red, 1);
         //          显示的文字,颜色,停留时间
     }
     if (Input.GetMouseButtonDown(1))
     {
         hUDText.Add(+10, Color.green, 1);
         //          显示的文字,颜色,停留时间
     }
 }
Ejemplo n.º 16
0
 // 每帧调用此函数一次
 void Update()
 {
     if (Input.GetMouseButton(0))
     {
         m_hudText.Add("+100", Color.red, 0);
     }
     if (Input.GetMouseButton(1))
     {
         m_hudText.Add("-30", Color.green, 0);
     }
     if (Input.GetMouseButton(2))
     {
         m_hudText.Add("Miss", Color.cyan, 0);
     }
 }
Ejemplo n.º 17
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         value = -10;
         text.Add(value, Color.red, 1f);
         UpdateLabelAndSlider(value);
     }
     else if (Input.GetMouseButtonDown(1))
     {
         value = +10;
         text.Add(value, Color.green, 1f);
         UpdateLabelAndSlider(value);
     }
 }
Ejemplo n.º 18
0
    IEnumerator ProgressChat()
    {
        mDisplay = true;

        // Get the Combat text for the current chatter.
        HUDText ct = mParticipants[mCurrentChatter].hudText;

        if (ct != null)
        {
            ct.Add(chatMessages[mCurrentMessage], Color.white, 2f);
            cameraLookAt.target = mParticipants[mCurrentChatter].lookAt;
        }

        yield return(new WaitForSeconds(4f));

        mCurrentChatter++;
        mCurrentMessage++;

        if (mCurrentChatter >= mParticipants.Count)
        {
            mCurrentChatter = 0;
        }

        // Rand out of message start again
        if (mCurrentMessage >= chatMessages.Length)
        {
            mCurrentMessage = 0;
            yield return(new WaitForSeconds(5f));
        }

        mDisplay = false;
    }
Ejemplo n.º 19
0
    //收到攻击调用这个方法
    // 0,收到多少伤害
    // 1,后退的距离
    // 2,浮空的高度
    void TakeDamage(string args)
    {
        if (hp <= 0)
        {
            return;
        }
        Combo._instance.ComboPlus();
        string[] proArray = args.Split(',');
        //减去伤害值
        int damage = int.Parse(proArray[0]);

        hp -= damage;
        hpBarSlider.value = (float)hp / hpTotal;
        hudText.Add("-" + damage, Color.red, 0.3f);
//        受到攻击的动画
        GetComponent <Animation>().Play("takedamage");
//浮空和后退
        float backDistance = float.Parse(proArray[1]);
        float jumpHeight   = float.Parse(proArray[2]);

        iTween.MoveBy(this.gameObject,
                      transform.InverseTransformDirection(targetGo.transform.forward) * backDistance
                      + Vector3.up * jumpHeight,
                      0.3f);
//出血特效实例化
        GameObject.Instantiate(damageEffectPrefab, bloodPoint.transform.position, Quaternion.identity);
        if (hp <= 0)
        {
            Dead();
        }
    }
Ejemplo n.º 20
0
 public void AddHudText(string text)
 {
     if (m_hudText != null)
     {
         m_hudText.Add(text, new Color(1.0f, 1.0f, 98.0f / 255.0f, 1.0f), 0.5f);
     }
 }
Ejemplo n.º 21
0
    public void createHUDText(Transform targetPosition, string text, Color color, float duration)
    {
        if (HUDRoot.go == null)
        {
            GameObject.Destroy(this.gameObject);
            return;
        }

        _isStart  = true;
        _playTime = duration;

        this.transform.parent = HUDRoot.go.transform;

        this.transform.localPosition = Vector3.zero;
        this.transform.localRotation = Quaternion.identity;
        this.transform.localScale    = Vector3.one;

        this.gameObject.layer = HUDRoot.go.layer;

        gameObject.GetComponent <UIFollowTarget> ().target = targetPosition;

        HUDText hudText = gameObject.GetComponent <HUDText> ();

        hudText.Add(text, color, duration);
    }
Ejemplo n.º 22
0
    void TakeDamage(string args) //受到伤害
    {
        if (hp_now == 0)         //死亡
        {
            return;
        }
        Combo.instance.ShowCombo();  //显示连击数
        //受到伤害的动画
        GetComponent <Animation>().Play("takedamage");
        string[] proArray = args.Split(',');
        //0 伤害值
        int damage = int.Parse(proArray[0]);

        hp_now     -= damage;
        hpBar.value = (float)hp_now / hp_max;       //更新血条显示
        hudText.Add("-" + damage, Color.red, 0.1f); //更新伤害显示
        if (hp_now < 0)
        {
            hp_now = 0;
        }
        if (hp_now == 0)  //死亡
        {
            Dead();
        }
        //1 后退的距离
        //2 浮空的高度
        float   back   = float.Parse(proArray[1]);                                        //敌人后退的方向为主角的前方向
        float   height = float.Parse(proArray[2]);
        Vector3 pos    = transform.InverseTransformDirection(targetGo.transform.forward); //将主角前方向坐标转换为敌人的局部坐标

        iTween.MoveBy(gameObject, pos * back + Vector3.up * height, 0.2f);                //后退和浮空
        //出血的特效
        Instantiate(bloodEffect, bloodPoint.position, Quaternion.identity);
    }
Ejemplo n.º 23
0
    public override void TakeDamage(int attack)
    {
        if (playerInformation.HP <= 0)
        {
            return;
        }
        if (state == WolfState.Death)
        {
            return;
        }
        float value = Random.Range(0f, 1f);

        if (value < miss)
        {
            isAttacked = false;
            AudioSource.PlayClipAtPoint(misss_Audio, transform.position);
            HUDText.Add("miss", Color.white, 0.5f);
        }
        else
        {
            isAttacked = true;
            hp        -= attack;
            StartCoroutine(ChangeColor());
            HUDText.Add(-attack, Color.red, 0.5f);
            AudioSource.PlayClipAtPoint(attack1_Audio, transform.position);
        }
    }
Ejemplo n.º 24
0
    /// <summary>
    /// 0、受到的攻击
    /// 1、收到的伤害
    /// 2、浮空或者后退的距离
    /// </summary>
    public void TakeDamage(object[] arg)
    {
        if (hp <= 0)
        {
            return;
        }

        StopAllCoroutines();
        Combo.Instance.ComboPlus();
        int   damage      = (int)arg[0];
        float moveforward = (float)arg[1];
        float jumpHeight  = (float)arg[2];

        anim.CrossFade("takedamage");

        iTween.MoveBy(this.gameObject, transform.InverseTransformDirection(TranscriptController.Instance.playerAnimation.transform.forward) * moveforward + Vector3.up * jumpHeight, 0.3f);
        GameObject effect = Instantiate <GameObject>(Resources.Load <GameObject>("Prefabs/EffectPrefabs/BloodSplatEffect"), bloodPoint.position, Quaternion.identity);

        hp -= damage;
        if (hp <= 0)
        {
            Dead();
        }
        hpBarSlider.value = (float)hp / hpTotal;
        hUDText.Add(damage, Color.red, 0.3F);
        StartCoroutine("PursurePlayer");
    }
Ejemplo n.º 25
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         test.Add(-10, Color.red, 1);
     }
 }
Ejemplo n.º 26
0
    //0受到多少伤害
    //1 后退距离
    //3 浮空高度
    void TakeDamage(string args)
    {
        if (hp <= 0)
        {
            return;
        }
        Combo._instance.ShowConboPlus();

        string[] proArray = args.Split(',');
        int      damage   = int.Parse(proArray[0]);

        hp -= damage;
        //血量显示
        hpSlider.value = (float)hp / TotalHp;
        //伤害显示
        hudText.Add("-" + damage, Color.red, 0.2f);
        //播放攻击动画
        animation.Play("takedamage");
        float backdistance = float.Parse(proArray[1]);
        float jumpHeight   = 0;

        iTween.MoveBy(this.gameObject,
                      transform.InverseTransformDirection(TranscriptManager._instance.player.transform.forward) * backdistance + Vector3.up * jumpHeight,
                      0.3f);

        GameObject.Instantiate(damageEffectPrefab, bloodPoint.transform.position, Quaternion.identity);

        if (hp <= 0)
        {
            Dead();
        }
    }
Ejemplo n.º 27
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         float sliderValue = slider.value;
         hUDText.Add(-10, Color.red, 1);
         //          显示的文字,颜色,停留时间
         slider.value = sliderValue - 0.1f;
     }
     if (Input.GetMouseButtonDown(1))
     {
         float sliderValue = slider.value;
         hUDText.Add(+10, Color.green, 1);
         //          显示的文字,颜色,停留时间
         slider.value = sliderValue + 0.1f;
     }
 }
Ejemplo n.º 28
0
 void OnClick()
 {
     if (hudtxt == null)
     {
         Start();
     }
     hudtxt.Add(1, Color.red, 1);
 }
Ejemplo n.º 29
0
 // Update is called once per frame
 void Update()
 {
     print(hudTest == null);
     if (Input.GetMouseButtonDown(0))
     {
         hudTest.Add(123, Color.red, 2f);
     }
 }
Ejemplo n.º 30
0
 private void AddText(string str, Color color, float stay, bool large = false, bool force = false)
 {
     if (force)
     {
         hudText.fontSize = (int)(((isPlayer ? 30 : 20) * (large ? 2 : 1)));
         hudText.Add(str, color, stay);
     }
     else
     {
         if (!ShowText)
         {
             return;
         }
         hudText.fontSize = (int)(((isPlayer ? 30 : 20) * (large ? 2 : 1)) * (6 - Vector3.Distance(Camera.main.transform.position, GetComponent <UIFollowTarget>().target.position)) / 5);
         hudText.Add(str, color, stay);
     }
 }