private void ReceiveSyncTrans(TransformDto dto) { if (dto == null) { return; } Dispatch(AreaCode.GAME, GameEvent.GAME_SYNC_TRANS, dto); }
void Awake() { Bind(TransformEvent.TRANS_MOVE, TransformEvent.TRANS_POS, TransformEvent.TRANS_SET_SPEED, TransformEvent.TRANS_RESET_SPEED); characterController = GetComponent <CharacterController>(); transformDto = new TransformDto(); animationMesg = new AnimationMesg(); localAcc = PlayerPrefs.GetString("ID"); }
private void ReceivePlayerReSpawn(TransformDto dto) { if (dto == null) { return; } Dispatch(AreaCode.GAME, GameEvent.GAME_PLAYER_SPAWN, dto); }
private void ReceiveNewPlayer(UserDto dto) { if (dto == null) { return; } //将新玩家存到游戏控制器的字典里 Dispatch(AreaCode.GAME, GameEvent.GAME_PLAYER_ADD, dto); TransformDto transformDto = new TransformDto(); transformDto.Account = dto.Account; Dispatch(AreaCode.GAME, GameEvent.GAME_PLAYER_SPAWN, transformDto); }
/// <summary> /// 处理传来的其他玩家的方位信息 /// </summary> /// <param name="dto"></param> private void SyncTrans(TransformDto dto) { string acc = dto.Account; GameObject obj = userGameObjDict[acc]; Vector3 pos = new Vector3(dto.pos[0], dto.pos[1], dto.pos[2]); Vector3 rota = new Vector3(dto.rota[0], dto.rota[1], dto.rota[2]); Quaternion qRota = Quaternion.Euler(rota); obj.transform.position = pos; //obj.transform.position = Vector3.Lerp(obj.transform.position, pos, 0.5f); obj.transform.rotation = qRota; //播放行走动画 animationMesg.Change(acc, "Walk", true); Dispatch(AreaCode.ANIMATION, AnimationEvent.ANIMATION_SET_BOOL, animationMesg); }
/// <summary> /// 根据数据生成玩家角色(加入或者复活) /// </summary> /// <param name="dto"></param> private void SpawnPlayer(TransformDto dto) { Vector3 pos = new Vector3(dto.pos[0], dto.pos[1], dto.pos[2]); Vector3 rota = new Vector3(dto.rota[0], dto.rota[1], dto.rota[2]); Quaternion qRota = Quaternion.Euler(rota); GameObject obj = Instantiate(character, pos, qRota); string acc = dto.Account; userGameObjDict.Add(acc, obj); UserDto userDto = userDtoDict[acc]; GameObject model = Resources.Load("Model/Model" + userDto.ModelID) as GameObject; Instantiate(model, obj.transform); obj.gameObject.GetComponent <AnimationController>().SetAccount(acc); obj.gameObject.GetComponent <FightController>().SetAccount(acc); EffectMesg effectMesg = new EffectMesg(obj, EffectType.RespawnEffect); Dispatch(AreaCode.EFFECT, EffectsEvents.SHOW_EFFECTS, effectMesg); if (acc == localAcc) { obj.tag = "Player"; //obj.AddComponent<CharacterController>(); obj.AddComponent <MainTransformCtrl>(); obj.gameObject.GetComponent <FightController>().IsLocalPlayer = true; obj.AddComponent <AudioListener>(); obj.transform.Find("Canvas").gameObject.SetActive(false); Dispatch(AreaCode.UI, UIEvent.UI_SHOWHIDE_ETC, true); SocketMessage socketMessage = new SocketMessage(OpCode.GAME, GameCode.GAME_LOADCOMPLETE_CERQ, null); Dispatch(AreaCode.NET, 0, socketMessage); return; } obj.transform.Find("Canvas").transform.Find("NameText").GetComponent <Text>().text = userDto.Name; obj.transform.Find("Canvas").transform.Find("LVText").GetComponent <Text>().text = "LV." + userDto.Lv.ToString(); Sprite sprite = Resources.Load("Icon/Icon" + userDto.IconID, typeof(Sprite)) as Sprite; obj.transform.Find("Canvas").transform.Find("ICON").GetComponent <Image>().sprite = sprite; }
public static Action <IMatrixTransformationBuilder> MapApiTransformToDomainAction(TransformDto input) { switch (input.TransformType) { case TransformDto.TransformationType.RotateX: return(tx => tx.RotateX(input.RotationRadians)); case TransformDto.TransformationType.RotateY: return(tx => tx.RotateY(input.RotationRadians)); case TransformDto.TransformationType.RotateZ: return(tx => tx.RotateZ(input.RotationRadians)); case TransformDto.TransformationType.Scale: return(tx => tx.Scale(new Vector3(input.VectorTransformation.X, input.VectorTransformation.Y, input.VectorTransformation.Z))); case TransformDto.TransformationType.Translate: return(tx => tx.Translate(new Vector3(input.VectorTransformation.X, input.VectorTransformation.Y, input.VectorTransformation.Z))); case TransformDto.TransformationType.Shear: var sx = input.ShearTransformation; return(tx => tx.Shear(sx.X2Y, sx.X2Z, sx.Y2X, sx.Y2Z, sx.Z2X, sx.Z2Y)); default: throw new ArgumentOutOfRangeException(nameof(input.TransformType), "Unrecognized transform type: " + input.TransformType); } }
/// <summary> /// 向服务器发送方位信息 /// </summary> private void SendTrans(TransformDto dto) { dto.Account = localAcc; smg.Change(OpCode.GAME, GameCode.GAME_SYNC_TRASNFORM_CERQ, dto); Dispatch(AreaCode.NET, 0, smg); }