找回密码
 立即注册
查看: 4213|回复: 70

[脚本] 血条的控制(每次5滴血)

[复制链接]
发表于 2013-3-5 18:52 | 显示全部楼层 |阅读模式
  1. function Start()
  2. {
  3.    animation.wrapMode = WrapMode.Loop;
  4.    var chujiao = player_.animation["chujiao"];
  5.    chujiao.wrapMode = WrapMode.Once;
  6.    var chuquan = player_.animation["chuquan"];
  7.    chuquan.wrapMode = WrapMode.Once;
  8. }
复制代码

  1. function Update () {
  2. //血量系统
  3. HealthSystem();

  4. if(target_ == null){
  5.   return;
  6. }

  7. //距离满足碰撞条件
  8. var dis :float = Vector3.Distance(player_.transform.position,target_.position);
  9. if(dis < attackRange)
  10. {
  11.   if(dis >10)
  12.   {
  13.    player_.animation.CrossFade("pao");
  14.   }
  15.   else if(dis <= 10)
  16.   {
  17.    //Random.value 控制出拳还是出脚
  18.    if(!(player_.animation.IsPlaying("chujiao")||player_.animation.IsPlaying("chuquan")))
  19.    {
  20.        var x=Random.Range(0f,1f);
  21.        health -= 5;
  22.    }
  23.    if(x< 0.5)
  24.    {
  25.      if(!(player_.animation.IsPlaying("chujiao")||player_.animation.IsPlaying("chuquan")))
  26.      {
  27.         player_.animation.CrossFade("chuquan");//出拳
  28.        }
  29.    }
  30.    if(x >= 0.5)
  31.    {
  32.     if(!(player_.animation.IsPlaying("chujiao")||player_.animation.IsPlaying("chuquan")))
  33.      {
  34.          player_.animation.CrossFade("chujiao"); //出脚
  35.          target_.animation.CrossFade("zhongquanhuangdong");
  36.      }
  37.   }
  38. }
  39.     //血量为0,挂
  40.    if(health <= 0)
  41.    {
  42.      target_.animation.CrossFade("guale");//玩家挂了
  43.       player_.animation.CrossFade("yaotou");//怪物很无奈
  44.    }
  45.    
  46.   }
  47. }
复制代码

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×

评分

参与人数 1鲜花 +1 收起 理由
va251ww + 1

查看全部评分

发表于 2013-3-6 00:24 | 显示全部楼层

感谢楼主的无私分享!{:soso__11402694654016840197_7:}
发表于 2013-3-6 19:21 | 显示全部楼层
{:5_435:}{:5_435:}谢谢 学习学习
发表于 2013-9-9 23:39 | 显示全部楼层
谢谢楼主分享,灰常感谢
发表于 2013-9-10 06:52 | 显示全部楼层

感谢楼主的无私分享!{:soso__11402694654016840197_7:}
发表于 2013-12-11 16:42 | 显示全部楼层
感谢楼主的无私分享!
发表于 2017-4-29 16:38 | 显示全部楼层
很不错
发表于 2017-4-29 16:36 | 显示全部楼层
楼主是超人
发表于 2017-4-29 16:13 | 显示全部楼层
好帖就是要顶
发表于 2017-4-29 16:31 | 显示全部楼层
真心顶
懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Unity开发者联盟 ( 粤ICP备20003399号 )

GMT+8, 2024-5-3 20:25 , Processed in 0.402763 second(s), 29 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表