/// <summary> /// 同步血量 /// </summary> private void SyncHp(HpDto dto) { string acc = dto.Account; if (acc == localAcc) { SetLocalHp(dto.Hp); return; } if (!userGameObjDict.ContainsKey(acc)) { return; } GameObject obj = userGameObjDict[acc]; Image img = obj.transform.Find("Canvas").transform.Find("HPBar").GetComponent <Image>(); float fill = (float)dto.Hp / 100; img.fillAmount = fill; if (fill < 0.9) { img.color = new Color(1 - fill, fill, 0); } else { img.color = Color.green; } }
private void ReceiveSyncHp(HpDto dto) { if (dto == null) { return; } Dispatch(AreaCode.GAME, GameEvent.GAME_SYNC_HP, dto); }
void Awake() { Bind(GameEvent.GAME_PLAYER_ADD, GameEvent.GAME_PLAYER_SPAWN, GameEvent.GAME_SYNC_TRANS, GameEvent.GAME_PLAYER_EXIT, GameEvent.GAME_UPLOAD_TRANS, GameEvent.GAME_SYNC_HP, GameEvent.GAME_SYNC_HG, GameEvent.GAME_SYNC_KILL, GameEvent.GAME_SYNC_INFO, GameEvent.GAME_REDUCE_HP, GameEvent.GAME_AUGMENT_HP, GameEvent.GAME_PLAYER_DEATH, GameEvent.GAME_CREAT_PROPS, GameEvent.GAME_REMOVE_PROPS, GameEvent.GAME_REMOVE_PROPS_SEND, GameEvent.GAME_DOSKILL, GameEvent.GAME_STOPSKILL, GameEvent.GAME_REDUCE_HG, GameEvent.GAME_AUGMENT_HG ); localAcc = PlayerPrefs.GetString("ID"); smg = new SocketMessage(); animationMesg = new AnimationMesg(); hpDto = new HpDto(); hgDto = new HgDto(); infoDto = new InfoDto(); }