//private ETouch mTouch = new ETouch(); public override void SetDontDestroyOnLoad(Transform parent) { base.SetDontDestroyOnLoad(parent); //mTouch.Init(transform); ZTEvent.AddHandler <float, float>(EventID.MOVING_JOYSTICK, OnMoveJoystick); ZTEvent.AddHandler(EventID.ENDING_JOYSTICK, OnEndJoystick); ZTEvent.AddHandler <ESkillPos>(EventID.REQ_CAST_SKILL, OnCastSkill); ZTEvent.AddHandler(EventID.REQ_PLAYER_JUMP, OnJump); }
private void OnJoystickMove(EJoystick move) { float x = move.joystickAxis.x; float y = move.joystickAxis.y; if (Math.Abs(x) > 0.1f || Math.Abs(y) > 0.1f) { ZTEvent.FireEvent(EventID.MOVING_JOYSTICK, x, y); } }
public void RemoveMainPlayer() { ZTEvent.RemoveHandler(EventID.REQ_PLAYER_JUMP, OnMainPlayerJump); ZTEvent.RemoveHandler <float, float>(EventID.REQ_PLAYER_Walk, OnMainPlayerWalk); ZTEvent.RemoveHandler(EventID.REQ_PLAYER_Idle, OnMainPlayerIdle); ZTEvent.RemoveHandler(EventID.REQ_PLAYER_Attack, OnMainPlayerAttack); ZTEvent.RemoveHandler <int>(EventID.REQ_PLAYER_Change, SetMainPlayer); ZTEvent.RemoveHandler(EventID.REQ_PLAYER_TakeStone, TakeStone); ZTEvent.RemoveHandler(EventID.REQ_PLAYER_ThrowingStone, ThrowingStone); ZTEvent.RemoveHandler <Actor>(EventID.REQ_PLAYER_EnemyArea, EnemyArea); }
void FixedUpdate() { BTTreeManager.Instance.Step(); ZTTimer.Instance.Step(); ZTAction.Update(); ZTEffect.Instance.Step(); if (Input.GetKeyDown(KeyCode.S)) { ZTEvent.FireEvent(EventID.REQ_CAST_SKILL, ESkillPos.Skill_0); } }
public void OnCastSkill(ESkillPos arg1) { //if (!IsExistsMe()) //{ // return; //} ECommandReply reply = Laucher.instance.MainPlayer.Command(new USCommand(arg1)); if (reply == ECommandReply.Y) { ZTEvent.FireEvent(EventID.ACK_CAST_SKILL, arg1); } }
public bool UseMoney(int id, int num) { XMoney money = DataManager.Instance.Moneys[id]; if (money == null) { return(false); } if (money.Num < num) { return(false); } money.Num -= num; DataMoney.Update(id, money); ZTEvent.FireEvent(EventID.CHANGE_MONEY, id); return(true); }
public bool UseAction(int id, int num) { XAction action = DataManager.Instance.Actions[id]; if (action == null) { return(false); } if (action.Num < num) { return(false); } action.Num -= num; DataAction.Update(id, action); ZTEvent.FireEvent(EventID.CHANGE_ACTION, (EAction)(id - 100)); return(true); }
public void AddMoney(int id, int num) { XMoney money; if (DataManager.Instance.Moneys.ContainsKey(id)) { money = DataManager.Instance.Moneys[id]; money.Num += num; DataMoney.Update(id, money); } else { money = new XMoney(); money.Id = id; money.Num = num; DataMoney.Insert(id, money); } ZTEvent.FireEvent(EventID.CHANGE_MONEY, id); }
private void ActionStart() { mActionKeyList.Clear(); mNextActionTimes.Clear(); Dictionary <int, DBItem> .Enumerator em = ZTConfig.Instance.DictAction.GetEnumerator(); while (em.MoveNext()) { DBItem db = em.Current.Value; int id = db.Id; int count = DataManager.Instance.GetItemCountById(id); long timer = CurServerTime; if (count < db.Data1) { timer += db.Data2; } mActionKeyList.Add(id); mNextActionTimes.Add(timer); } em.Dispose(); ZTEvent.AddHandler(EventID.SECOND_TICK, ActionUpdate); }
public void AddAction(int id, int num) { XAction action; if (DataManager.Instance.Actions.ContainsKey(id)) { action = DataManager.Instance.Actions[id]; action.Num += num; DataAction.Update(id, action); } else { action = new XAction(); action.Id = id; action.Num = num; DataAction.Insert(id, action); } DBItem db = ZTConfig.Instance.GetDBItem(id); EAction type = ZTConfig.Instance.GetActionType(id); ZTEvent.FireEvent(EventID.CHANGE_ACTION, type); }
private void ActionUpdate() { for (int i = 0; i < mActionKeyList.Count; i++) { int key = mActionKeyList[i]; DBItem db = ZTConfig.Instance.GetDBItem(key); EAction actionType = ZTConfig.Instance.GetActionType(key); int count = GetActionCountByType(actionType); if (count >= db.Data1) { mNextActionTimes[i] = CurServerTime; } else { if (CurServerTime >= mNextActionTimes[i]) { AddAction(key, 1); mNextActionTimes[i] = CurServerTime + db.Data2; } } } ZTEvent.FireEvent(EventID.UPDATE_ACTION_TIMER); }
private void ActionExit() { ZTEvent.RemoveHandler(EventID.SECOND_TICK, ActionUpdate); }
private void OnJoystickMoveEnd(EJoystick move) { ZTEvent.FireEvent(EventID.ENDING_JOYSTICK); }
public override void Init(int id, Camera cam, CameraEvent callback, params object[] args) { base.Init(id, cam, callback, args); ZTEvent.AddHandler <float, float>(EventID.REQ_Camera_Move, MainCameraMove); }
public void OnClickSkill() { ESkillPos skillPos = ESkillPos.Skill_0; ZTEvent.FireEvent(EventID.REQ_CAST_SKILL, skillPos); }
public override void OnLeave() { base.OnLeave(); this.GetComponent <CameraFollow>().enabled = true; ZTEvent.RemoveHandler <float, float>(EventID.REQ_Camera_Move, MainCameraMove); }
public void UpdateAttr(EAttr attr, int value) { mCurrAttr.Update(attr, value); ZTEvent.FireEvent(EventID.REQ_PLAYER_Attr); }
void Update() { float x = Input.GetAxis("Horizontal"); float y = Input.GetAxis("Vertical"); if (Input.GetKeyDown(switchcontrolier)) { Camera cam = CameraManage.Instance.MainCamera; object[] args = new object[] { LevelData.MainPlayer.CacheTransform }; if (controllertype == ControllerType.mPlayer) { controllertype = ControllerType.mCamera; CameraManage.Instance.SwitchCameraEffect(ECameraType.MOVE, cam, null, args); } else { controllertype = ControllerType.mPlayer; CameraManage.Instance.SwitchCameraEffect(ECameraType.FOLLOW, cam, null, args); } } if (controllertype == ControllerType.mPlayer)//控制角色时 { if (Input.GetKeyDown(jump)) { ZTEvent.FireEvent(EventID.REQ_PLAYER_JUMP); } if (Input.GetKeyDown(attack)) { ZTEvent.FireEvent(EventID.REQ_PLAYER_Attack); } if (Input.GetKeyDown(changemainplayer)) { if (LevelData.MainPlayer.Id == 1) { ZTEvent.FireEvent(EventID.REQ_PLAYER_Change, 2); } else { ZTEvent.FireEvent(EventID.REQ_PLAYER_Change, 1); } } if (Input.GetKeyDown(takestone)) { ZTEvent.FireEvent(EventID.REQ_PLAYER_TakeStone); } if (Input.GetButtonDown("Fire1")) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { if (hit.collider.tag == "enemy") { ZTEvent.FireEvent(EventID.REQ_PLAYER_EnemyArea, hit.collider.gameObject.GetComponent <ActorBehavior>().Owner); } else if (hit.collider.tag == "Player") { if (hit.collider.gameObject.GetComponent <ActorBehavior>().Owner.Id == LevelData.MainPlayer.Id) { return; } ZTEvent.FireEvent(EventID.REQ_PLAYER_Change, hit.collider.gameObject.GetComponent <ActorBehavior>().Owner.Id); } else { ZTEvent.FireEvent(EventID.REQ_PLAYER_ThrowingStone); } } } if (Input.GetAxis("Mouse ScrollWheel") < 0) { CameraManage.Instance.SetFollowDis(1); } if (Input.GetAxis("Mouse ScrollWheel") > 0) { CameraManage.Instance.SetFollowDis(-1); } if (x != 0 || y != 0) { ZTEvent.FireEvent(EventID.REQ_PLAYER_Walk, x, y); } else { ZTEvent.FireEvent(EventID.REQ_PLAYER_Idle); } } else//控制相机时 { if (x != 0 || y != 0) { ZTEvent.FireEvent(EventID.REQ_Camera_Move, x, y); } if (Input.GetButtonDown("Fire1")) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { if (hit.collider.tag == "enemy") { ZTEvent.FireEvent(EventID.REQ_PLAYER_EnemyArea, hit.collider.gameObject.GetComponent <ActorBehavior>().Owner); } } } } }
void SetMainPlayer(int id) { LevelManage.Instance.SetMainPlayer(id); ZTEvent.FireEvent(EventID.REQ_PLAYER_Attr); }
protected override void OnRemoveHandler() { ZTEvent.RemoveHandler(EventID.REQ_PLAYER_Attr, InitWidget); }