コード例 #1
0
 private void Awake()
 {
     cc             = GetComponent <CharacterController>();
     info           = GetComponent <Info>();
     animatorManage = GetComponent <AnimatorManage>();
     InvokeRepeating("Sync", 0, 0.1f);
 }
コード例 #2
0
ファイル: GameManage.cs プロジェクト: hehay/hehayGame
    private void ReviveBro(int id)
    {
        UserDTO    userDto = IdToUserDtoDic[id] as UserDTO;
        GameObject go      = idToGameObjectDic[id];

        if (userDto != null)
        {
            userDto.hp = (int)(userDto.maxHp * 0.5);
            userDto.mp = (int)(userDto.maxMp * 0.5);
            Info           info           = go.GetComponent <Info>();
            AnimatorManage animatorManage = go.GetComponent <AnimatorManage>();
            info.state = AnimState.Idle;
            animatorManage.SetInt("state", info.state);
            go.transform.Find("infoUi")
            .GetComponent <CameraFacingBillboard>()
            .SetInfo(userDto.name, (float)userDto.hp / userDto.maxHp, (float)userDto.mp / userDto.maxMp);
            go.transform.position = fuhuoTransform.position;


            if (id == GameData.UserDto.id)
            {
                isFuhuo = false;
                mask.gameObject.SetActive(false);
                fuhuoText.gameObject.SetActive(false);
                GameData.SavaHpMp(userDto.hp, userDto.mp);
            }
        }
    }
コード例 #3
0
 public static AnimatorManage GetInstate()
 {
     if (_ani == null)
     {
         _ani = new AnimatorManage();
     }
     return(_ani);
 }
コード例 #4
0
ファイル: GameManage.cs プロジェクト: hehay/hehayGame
 private void DamageBro(DamageDTO damagedto)//damagedto.targets[i][0]//0为被攻击者id,1为收到伤害的值,2被攻击者是否死亡,3是否触发暴击
 {
     for (int i = 0; i < damagedto.targets.Length; i++)
     {
         UserDTO    userDto = IdToUserDtoDic[damagedto.targets[i][0]] as UserDTO;
         GameObject model   = idToGameObjectDic[damagedto.targets[i][0]];
         if (userDto != null)
         {
             if (userDto.id >= 0)                       //受到伤害的是否为玩家
             {
                 if (userDto.id == GameData.UserDto.id) //受到攻击为本人,更新ui界面的数据
                 {
                     GameData.SetHpMp(-damagedto.targets[i][1]);
                 }
                 else
                 {
                     userDto.hp -= damagedto.targets[i][1];
                     if (userDto.hp <= 0)
                     {
                         userDto.hp = 0;
                     }
                 }
                 //更新玩家血条数据
                 model.transform.Find("infoUi").GetComponent <CameraFacingBillboard>().SetInfo(userDto.name, (float)userDto.hp / userDto.maxHp, (float)userDto.mp / userDto.maxMp);
             }
             else
             {
                 model.transform.Find("infoUi").GetComponent <CameraFacingBillboard>().SetInfo(userDto.name, (float)userDto.hp / userDto.maxHp);
             }
             Info info = model.GetComponent <Info>();
             InitFallBoold(info, damagedto.targets[i][1], Color.red, damagedto.targets[i][3]);//实例化掉血
             AnimatorManage animatorManage = model.GetComponent <AnimatorManage>();
             info.state = AnimState.Control;
             animatorManage.SetInt("state", (int)AnimState.Control);
             if (damagedto.targets[i][2] == 0 || userDto.hp <= 0)
             {
                 if (userDto.id == GameData.UserDto.id)//自己死亡,显示复活时间和开启ui遮罩
                 {
                     mask.gameObject.SetActive(true);
                     fuhuoText.gameObject.SetActive(true);
                     timer   = 11;
                     isFuhuo = true;
                 }
                 info.state = AnimState.Die;
                 animatorManage.SetInt("state", (int)AnimState.Die);
             }
         }
     }
 }
コード例 #5
0
ファイル: GunManager.cs プロジェクト: Qishihao1994/sence
 public virtual void mShot()
 {
     _takeguns  = GameObject.Find("hand (1)").GetComponent <TakeGuns> ();
     _CurrenCD += Time.deltaTime * 2;
     if (_CurrenCD >= _ShotSpeed && Input.GetMouseButtonDown(0))
     {
         if (_BulletNum > 0)
         {
             _BulletNum--;
             GameObject clone = Instantiate <GameObject> (bullet, _takeguns.Fpoint.position, _takeguns.Fpoint.rotation);
             clone.GetComponent <Rigidbody> ().AddForce(Camera.main.transform.TransformDirection(0, 0, 10) * 500);
             Destroy(clone, 2);
             _takeguns._other.GetComponent <AudioSource> ().Play();
             _CurrenCD = 0;
             AnimatorManage.GetInstate().SetAnimator(_takeguns.ani, "shoot");
             Animator anim = _takeguns.gun.GetComponent <Animator> ();
             AnimatorManage.GetInstate().SetAnimator(anim, "shoot");
             RaycastHit hit;
             if (Physics.Raycast(_takeguns.Fpoint.position, _takeguns.Fpoint.TransformDirection(Vector3.forward), out hit))
             {
                 if (hit.transform.tag.Equals("Enemy"))
                 {
                     hp -= _damage;
                     print(hp);
                     if (hp <= 0)
                     {
                         Destroy(hit.transform.gameObject, 2);
                     }
                 }
             }
         }
         else
         {
             AudioManager.GetInstance().PlayClip(_takeguns.source, "Audio/Zhuangdan/cocked", false);
         }
     }
 }
コード例 #6
0
 void Awake()
 {
     animatorManage = GetComponent <AnimatorManage>();
 }