void onClick(GameObject e) { if (!e.GetComponent <Button>().enabled) { return; } switch (e.name) { case "moveBtn": float newDate = Time.fixedTime; if (newDate - date < moveTimeout) { return; } date = newDate; float centerX = Screen.width * 0.5f; float centerY = Screen.height * 0.5f; float angle = Statics.GetAngle(Input.mousePosition.x, Input.mousePosition.y, centerX, centerY); if (angle < 45 || angle >= 315) { Messenger.Broadcast <string, bool>(NotifyTypes.MoveOnArea, AreaTarget.Down, true); } else if (angle >= 45 && angle < 135) { Messenger.Broadcast <string, bool>(NotifyTypes.MoveOnArea, AreaTarget.Left, true); } else if (angle >= 135 && angle < 225) { Messenger.Broadcast <string, bool>(NotifyTypes.MoveOnArea, AreaTarget.Up, true); } else if (angle >= 225 && angle < 315) { Messenger.Broadcast <string, bool>(NotifyTypes.MoveOnArea, AreaTarget.Right, true); } break; default: break; } }
void onClick(GameObject e) { switch (e.name) { case "moveBtn": if (!moveBtn.enabled) { return; } float newDate = Time.fixedTime; if (newDate - date < moveTimeout) { return; } date = newDate; float centerX = Screen.width * 0.5f; float centerY = Screen.height * 0.5f; float angle = Statics.GetAngle(Input.mousePosition.x, Input.mousePosition.y, centerX, centerY); if (angle < 45 || angle >= 315) { Messenger.Broadcast <string, bool>(NotifyTypes.MoveOnArea, AreaTarget.Down, true); } else if (angle >= 45 && angle < 135) { Messenger.Broadcast <string, bool>(NotifyTypes.MoveOnArea, AreaTarget.Left, true); } else if (angle >= 135 && angle < 225) { Messenger.Broadcast <string, bool>(NotifyTypes.MoveOnArea, AreaTarget.Up, true); } else if (angle >= 225 && angle < 315) { Messenger.Broadcast <string, bool>(NotifyTypes.MoveOnArea, AreaTarget.Right, true); } break; case "prop1BlockImage": // ConfirmCtrl.Show("一件夜行衣能避免一场野外战斗\n(观看一段视频可以获得1-2件)", () => { // if (propsData[0].Num >= propsData[0].Max) // { // AlertCtrl.Show(string.Format("最多只能携带{0}件夜行衣", propsData[0].Max)); // return;; // } // int randomNum = UnityEngine.Random.Range(1, 3); // Messenger.Broadcast<PropType, int>(NotifyTypes.AddProp, PropType.NocturnalClothing, randomNum); // AlertCtrl.Show(string.Format("获得了{0}件夜行衣", randomNum)); // }, null, "观看", "不了"); PropsMallPanelCtrl.Show(propsData[0]); break; case "prop2BlockImage": // ConfirmCtrl.Show("一位镖师能够抵消一位侠客受伤\n(观看一段视频可以雇佣1-2位)", () => { // if (propsData[1].Num >= propsData[1].Max) // { // AlertCtrl.Show(string.Format("最多只能雇佣{0}个镖师", propsData[1].Max)); // return; // } // int randomNum = UnityEngine.Random.Range(1, 3); // Messenger.Broadcast<PropType, int>(NotifyTypes.AddProp, PropType.Bodyguard, randomNum); // AlertCtrl.Show(string.Format("雇佣了{0}个镖师", randomNum)); // }, null, "观看", "不了"); PropsMallPanelCtrl.Show(propsData[1]); break; case "prop3BlockImage": // ConfirmCtrl.Show("石灰粉有50%概率能脱离战斗\n(观看一段视频可以获得1-2包)", () => { // if (propsData[2].Num >= propsData[2].Max) // { // AlertCtrl.Show(string.Format("最多只能携带{0}包石灰粉", propsData[2].Max)); // return; // } // int randomNum = UnityEngine.Random.Range(1, 3); // Messenger.Broadcast<PropType, int>(NotifyTypes.AddProp, PropType.LimePowder, randomNum); // AlertCtrl.Show(string.Format("获得了{0}包石灰粉", randomNum)); // }, null, "观看", "不了"); PropsMallPanelCtrl.Show(propsData[2]); break; case "prop4BlockImage": // ConfirmCtrl.Show("探子可以追踪未知的任务目标\n(观看一段视频可以获得1-2个)", () => { // if (propsData[3].Num >= propsData[3].Max) // { // AlertCtrl.Show(string.Format("最多只能拥有{0}个探子", propsData[3].Max)); // return; // } // int randomNum = UnityEngine.Random.Range(1, 3); // Messenger.Broadcast<PropType, int>(NotifyTypes.AddProp, PropType.Scout, randomNum); // AlertCtrl.Show(string.Format("获得了{0}个探子", randomNum)); // }, null, "观看", "不了"); PropsMallPanelCtrl.Show(propsData[3]); break; default: break; } }