private void RemoveEvent() { SceneEvent.GetInstance().removeEventListener(SCENE_EVENT.ADD_PLAYER, OnAddPlayer); SceneEvent.GetInstance().removeEventListener(SCENE_EVENT.ADD_COMMAND, OnAddCommand); SceneEvent.GetInstance().removeEventListener(SCENE_EVENT.UPDATE_GRASS_ID, OnUpdateGrassId); SceneEvent.GetInstance().removeEventListener(SCENE_EVENT.UPDATE_CAMERA, OnUpdateCamera); }
//使用技能 public void SkillCommand(SkillCommand command) { if (CanUseSkill() && null != command) { //BattleState = BATTLE_STATE.SKILL; SceneEvent.GetInstance().dispatchEvent(SCENE_EVENT.ADD_SKILL_PARSER, new Notification(command)); } }
//收到玩家进入场景 public void ParseEnterBattle(BPEnter bp) { SceneEvent.GetInstance().dispatchEvent(SCENE_EVENT.ADD_PLAYER, new Notification(bp)); //通知其他玩家自己位置 if (bp.BattleId != PlayerModule.GetInstance().RoleID&& !_sendList.Contains(bp.BattleId)) { _sendList.Add(bp.BattleId); BattleProtocol.GetInstance().SendEnterBattle(PlayerModule.GetInstance().RoleID, PlayerModule.GetInstance().RoleJob); } }
/// <summary> /// 相机跟随玩家 /// </summary> void FollowPlayer() { float upRidus = Mathf.Deg2Rad * initialAngle; float flatRidus = Mathf.Deg2Rad * horizontalAngle; float x = tx; //initialDistance * Mathf.Cos(upRidus) * Mathf.Cos(flatRidus); float z = ty; //initialDistance * Mathf.Cos(upRidus) * Mathf.Sin(flatRidus); float y = tz; //initialDistance * Mathf.Sin(upRidus); transform.position = Vector3.zero; tempVector.Set(x, y, z); tempVector = tempVector + target.position; transform.position = tempVector; tempVector.Set(target.position.x, target.position.y, target.position.z); transform.LookAt(tempVector); SceneEvent.GetInstance().dispatchEvent(SCENE_EVENT.UPDATE_CAMERA); }
private void CreatePlayerView(PlayerBattleInfo playerInfo) { if (null == playerInfo) { return; } GameObject gameObject = GameObject.Instantiate(_playerPrefab[playerInfo.CareerType]); gameObject.transform.localPosition = playerInfo.MovePos; gameObject.transform.parent = _playerLayer; _charaViewDic.Add(playerInfo.BattleId, gameObject); gameObject.AddComponent <PlayerBattleActor>(); gameObject.GetComponent <PlayerBattleActor>().SetInfo(playerInfo); //通知ui管理器 添加头像 SceneEvent.GetInstance().dispatchEvent(SCENE_EVENT.ADD_UI_HEAD, new Notification(playerInfo)); if (playerInfo.BattleId == PlayerModule.GetInstance().RoleID) { GameObject.Find("Main Camera").GetComponent <CameraFollow>().target = gameObject.transform; GameObject.Find("SkillJoystick").GetComponent <SkillArea>().player = gameObject; } }
//添加伤害 显示 public void AddHurt(HurtInfo info) { Hp += info.Value; SceneEvent.GetInstance().dispatchEvent(SCENE_EVENT.ADD_UI_HURT_VALUE, new Notification(info)); }
//技能使用 public void ParseSkillCommand(BPSkill bp) { SkillCommand command = FightDefine.GetSkillCommand(bp.BattleId, bp.Frame, bp.SkillId, bp.SkillDir, bp.TargetPos, bp.TargetId); SceneEvent.GetInstance().dispatchEvent(SCENE_EVENT.ADD_COMMAND, new Notification(command)); }
//移动 public void ParseMoveComand(BPMove bp) { MoveCommand command = FightDefine.GetMoveCommand(bp.BattleId, bp.Frame, bp.Dir); SceneEvent.GetInstance().dispatchEvent(SCENE_EVENT.ADD_COMMAND, new Notification(command)); }
private void RemoveEvent() { SceneEvent.GetInstance().removeEventListener(SCENE_EVENT.ADD_SKILL_PARSER, OnAddSkillParser); }
private void RemoveEvent() { SceneEvent.GetInstance().removeEventListener(SCENE_EVENT.ADD_UI_HURT_VALUE, OnAddUIHurtValue); SceneEvent.GetInstance().removeEventListener(SCENE_EVENT.ADD_UI_HEAD, OnAddUIHead); }