Exemplo n.º 1
0
    /// <summary>
    /// 创建一个推送动画
    /// </summary>
    /// <param name="StartPoint"></param>
    public static void PushAnimation(PPlayer Player, string PushText, PPushType PushType)
    {
        const int   FrameNumber = 25;
        const float TotalTime   = 0.5f;
        float       Offset      = 100.0f;
        Vector3     Speed       = new Vector3(0.0f, Offset / FrameNumber, 0.0f);
        Text        NewPush     = null;
        Color       PushColor   = PushType.PushColor;

        AddAnimation("推送[" + PushText + "]", () => {
            PushColor.a  -= 0.8f / FrameNumber;
            NewPush.color = PushColor;
            NewPush.rectTransform.Translate(Speed);
        }, FrameNumber, TotalTime, () => {
            PUIManager.AddNewUIAction("删除推送[" + PushText + "]", () => {
                UnityEngine.Object.Destroy(NewPush.gameObject);
            });
        }, () => {
            NewPush = UnityEngine.Object.Instantiate(PUIManager.GetUI <PMapUI>().PushText);
            NewPush.transform.SetParent(PUIManager.GetUI <PMapUI>().UIBackgroundImage);
            NewPush.rectTransform.localScale *= PUIManager.GetUI <PMapUI>().PushText.rectTransform.lossyScale.y;
            NewPush.color = PushColor;
            NewPush.text  = PushText;
            NewPush.rectTransform.position = PPlayerScene.GetScreenPosition(Player);
            NewPush.gameObject.SetActive(true);
        });
    }
Exemplo n.º 2
0
 public override void OnPointerEnter(PointerEventData eventData)
 {
     if (ToolTip == null || ToolTip.Length == 0)
     {
         base.OnPointerEnter(eventData);
         return;
     }
     PUIManager.AddNewUIAction(string.Empty, () => {
         float Th   = 200 * PUIManager.GetUI <PMapUI>().ToolTip.UIBackgroundImage.GetComponent <RectTransform>().lossyScale.x;
         float PosX = 0.0f;
         if (Input.mousePosition.x > Screen.width - Th)
         {
             PosX = Input.mousePosition.x - Th - 10;
         }
         else
         {
             PosX = Input.mousePosition.x + 10;
         }
         PUIManager.GetUI <PMapUI>().ToolTip.Show(ToolTip, new Vector3(PosX, Input.mousePosition.y - 10, 0));
         float HhtTh = PUIManager.GetUI <PMapUI>().ToolTip.UIBackgroundImage.GetComponent <RectTransform>().rect.height *PUIManager.GetUI <PMapUI>().ToolTip.UIBackgroundImage.GetComponent <RectTransform>().lossyScale.y;
         float PosY  = PUIManager.GetUI <PMapUI>().ToolTip.UIBackgroundImage.GetComponent <RectTransform>().position.y;
         if (Input.mousePosition.y > Screen.height - HhtTh - 10)
         {
             PosY -= HhtTh + 10;
             PUIManager.GetUI <PMapUI>().ToolTip.Show(ToolTip, new Vector3(PosX, PosY, 0));
         }
     });
 }
Exemplo n.º 3
0
 public PRefreshGeneralOrder() : base("refresh_general",
                                      null,
                                      (string[] args) => {
     List <PSkillInfo> SkillInfoList = new List <PSkillInfo>();
     int PlayerIndex    = Convert.ToInt32(args[1]);
     string GeneralName = args[2];
     int SkillCount     = Convert.ToInt32(args[3]);
     for (int i = 4; i + 1 < args.Length; i += 2)
     {
         PSkillInfo SkillInfo = FindInstance <PSkillInfo>(args[i])?.Copy();
         if (SkillInfo != null)
         {
             SkillInfo.Type = FindInstance <PSkillType>(args[i + 1]);
             SkillInfoList.Add(SkillInfo);
         }
     }
     if (PlayerIndex == PSystem.PlayerIndex)
     {
         PUIManager.AddNewUIAction("更新技能栏", () => {
             PUIManager.GetUI <PMapUI>().InitializeSkillButton(SkillInfoList);
         });
     }
     PUIManager.AddNewUIAction("更新武将头像", () => {
         PNetworkManager.NetworkClient.GameStatus.PlayerList[PlayerIndex].General = ListSubTypeInstances <PGeneral>().Find((PGeneral General) => General.Name.Equals(GeneralName));
         PNetworkManager.NetworkClient.GameStatus.PlayerList[PlayerIndex].General.SkillInfoList = SkillInfoList;
         PUIManager.GetUI <PMapUI>().PlayerInformationGroup.GroupUIList[PlayerIndex].UpdateInformation();
     });
 }) {
 }
Exemplo n.º 4
0
 public PRefreshHandCardsOrder() : base("refresh_hand_cards",
                                        null,
                                        (string[] args) => {
     PAnimation.AddAnimation("更新手牌区", () => {
         PUIManager.GetUI <PMapUI>().HandCardArea.Refresh(args);
     });
 }) {
 }
Exemplo n.º 5
0
 public PRefreshEquipmentsOrder() : base("refresh_equipments",
                                         null,
                                         (string[] args) => {
     PAnimation.AddAnimation("更新装备区", () => {
         PUIManager.GetUI <PMapUI>().EquipCardArea.Refresh(args);
     });
 }) {
 }
Exemplo n.º 6
0
 public PRefreshAmbushOrder() : base("refresh_ambush",
                                     null,
                                     (string[] args) => {
     PAnimation.AddAnimation("更新伏兵区", () => {
         PUIManager.GetUI <PMapUI>().AmbushCardArea.Refresh(args);
     });
 }) {
 }
Exemplo n.º 7
0
 /// <summary>
 /// 跟踪某个玩家的棋子
 /// </summary>
 /// <param name="Player"></param>
 public void SetTracking(PPlayer Player)
 {
     PAnimation.AddAnimation("转换跟踪目标", () => {
         IsTracking = false;
         Tracking   = PUIManager.GetUI <PMapUI>().Scene.PlayerGroup.GroupUIList[Player.Index].UIBackgroundImage;
         ChangePerspective(Tracking.position + Config.CameraLockedDistance);
         IsTracking = true;
     });
 }
Exemplo n.º 8
0
 public PShowInformationOrder() : base("show_information",
                                       null,
                                       (string[] args) => {
     string Information = args[1];
     PAnimation.AddAnimation("显示消息[" + Information + "]", () => {
         PUIManager.GetUI <PMapUI>().AddNewInformation(Information);
     }, 1, 0.2f);
 }) {
 }
Exemplo n.º 9
0
 public PStartTurnOrder() : base("start_turn",
                                 null,
                                 (string[] args) => {
     int NowPlayerIndex = int.Parse(args[1]);
     PNetworkManager.NetworkClient.GameStatus.NowPlayerIndex = NowPlayerIndex;
     PUIManager.AddNewUIAction("开始跟踪", () => {
         PUIManager.GetUI <PMapUI>().CameraController.SetTracking(PNetworkManager.NetworkClient.GameStatus.NowPlayer);
     });
 }) {
 }
Exemplo n.º 10
0
 public PDieOrder() : base("die",
                           null,
                           (string[] args) => {
     int DiePlayerIndex = Convert.ToInt32(args[1]);
     PAnimation.AddAnimation("玩家死亡", () => {
         PNetworkManager.NetworkClient.GameStatus.FindPlayer(DiePlayerIndex).IsAlive = false;
         PUIManager.GetUI <PMapUI>().PlayerInformationGroup.GroupUIList[DiePlayerIndex].Initialize(PNetworkManager.NetworkClient.GameStatus.FindPlayer(DiePlayerIndex));
         PUIManager.GetUI <PMapUI>().Scene.PlayerGroup.GroupUIList[DiePlayerIndex].Close();
     });
 }) {
 }
Exemplo n.º 11
0
 public PRejectOrder() : base("reject",
                              null,
                              (string[] args) => {
     if (PUIManager.IsCurrentUI <PJoinUI>())
     {
         PUIManager.AddNewUIAction("Reject-显示拒绝信息", () => {
             PUIManager.GetUI <PJoinUI>().ErrorText.text = "房间已满";
         });
     }
 }) {
 }
Exemplo n.º 12
0
 public PDiceResultOrder() : base("dice_result",
                                  null,
                                  (string[] args) => {
     int DiceResult = int.Parse(args[1]);
     if (DiceResult >= 1 && DiceResult <= 6)
     {
         PUIManager.AddNewUIAction("DiceResult-掷骰结果:" + DiceResult.ToString(), () => {
             PUIManager.GetUI <PMapUI>().Dice(DiceResult);
         });
     }
 }) {
 }
Exemplo n.º 13
0
 public PArchButtonUI Initialize(Transform Prototype, int _Index, int LineCapacity, PArchInfo _ArchInfo)
 {
     Index    = _Index;
     ArchInfo = _ArchInfo;
     UIBackgroundImage.GetComponentInChildren <Text>().text = ArchInfo.Name;
     UIBackgroundImage.localScale    = new Vector3(1, 1, 1);
     UIBackgroundImage.localPosition = new Vector3(70.0f * (Index % LineCapacity) + Prototype.localPosition.x, -70.0f * (Index / LineCapacity) + Prototype.localPosition.y, 0.0f);
     ArchButton.onClick.AddListener(() => {
         PUIManager.GetUI <PArchUI>().ArchInfoInputField.text = ArchInfo.Name + "\n" + ArchInfo.Info;
     });
     UIBackgroundImage.gameObject.SetActive(true);
     return(this);
 }
Exemplo n.º 14
0
 public PRefreshMarkStringOrder() : base("refresh_mark_string",
                                         null,
                                         (string[] args) => {
     int PlayerIndex   = Convert.ToInt32(args[1]);
     string MarkString = args[2];
     PAnimation.AddAnimation("RefreshMarkString-刷新信息栏", () => {
         if (0 <= PlayerIndex && PlayerIndex < PNetworkManager.NetworkClient.GameStatus.PlayerNumber)
         {
             PNetworkManager.NetworkClient.GameStatus.PlayerList[PlayerIndex].MarkString = MarkString;
             PUIManager.GetUI <PMapUI>().PlayerInformationGroup.Update(PlayerIndex);
         }
     });
 }) {
 }
Exemplo n.º 15
0
 public PRefreshHandCardNumberOrder() : base("refresh_hand_card_number",
                                             null,
                                             (string[] args) => {
     int PlayerIndex    = Convert.ToInt32(args[1]);
     int HandCardNumber = Convert.ToInt32(args[2]);
     PAnimation.AddAnimation("RefreshHandCardNumber-刷新信息栏", () => {
         if (0 <= PlayerIndex && PlayerIndex < PNetworkManager.NetworkClient.GameStatus.PlayerNumber)
         {
             PNetworkManager.NetworkClient.GameStatus.PlayerList[PlayerIndex].HandCardNumber = HandCardNumber;
             PUIManager.GetUI <PMapUI>().PlayerInformationGroup.Update(PlayerIndex);
         }
     });
 }) {
 }
Exemplo n.º 16
0
 public override void OnPointerExit(PointerEventData eventData)
 {
     if (ToolTip == null || ToolTip.Length == 0)
     {
         base.OnPointerExit(eventData);
         return;
     }
     PUIManager.AddNewUIAction(string.Empty, () => {
         if (PUIManager.GetUI <PMapUI>().ToolTip.ToolTipText.text.Equals(ToolTip))
         {
             PUIManager.GetUI <PMapUI>().ToolTip.Close();
         }
     });
 }
Exemplo n.º 17
0
 public PRefreshMoneyOrder() : base("refresh_money",
                                    null,
                                    (string[] args) => {
     int PlayerIndex = int.Parse(args[1]);
     int Money       = int.Parse(args[2]);
     PAnimation.AddAnimation("RefreshMoney-刷新信息栏", () => {
         if (0 <= PlayerIndex && PlayerIndex < PNetworkManager.NetworkClient.GameStatus.PlayerNumber)
         {
             PNetworkManager.NetworkClient.GameStatus.PlayerList[PlayerIndex].Money = Money;
         }
         PUIManager.GetUI <PMapUI>().PlayerInformationGroup.Update(PlayerIndex);
     });
 }) {
 }
Exemplo n.º 18
0
 public PMovePositionOrder() : base("move_position",
                                    null,
                                    (string[] args) => {
     int PlayerIndex      = int.Parse(args[1]);
     int DestinationIndex = int.Parse(args[2]);
     if (0 <= PlayerIndex && PlayerIndex < PNetworkManager.NetworkClient.GameStatus.PlayerNumber && 0 <= DestinationIndex && DestinationIndex < PNetworkManager.NetworkClient.GameStatus.Map.BlockList.Count)
     {
         PBlock DestinationBlock          = PNetworkManager.NetworkClient.GameStatus.Map.BlockList[DestinationIndex];
         PPlayer Player                   = PNetworkManager.NetworkClient.GameStatus.PlayerList[PlayerIndex];
         Player.Position                  = DestinationBlock;
         Vector3 DestinationSpacePosition = PPlayerScene.GetSpacePosition(Player);
         PUIManager.GetUI <PMapUI>().Scene.PlayerGroup.MovePlayer(PlayerIndex, DestinationSpacePosition);
     }
 }) {
 }
Exemplo n.º 19
0
 public PCloseDiceOrder() : base("close_dice",
                                 null,
                                 (string[] args) => {
     int Frame = 0;
     PAnimation.AddAnimation("关闭骰子", () => {
         if (Frame == 0)
         {
             Frame = 1;
         }
         else
         {
             PUIManager.GetUI <PMapUI>().DiceImage.gameObject.SetActive(false);
         }
     }, 2, 0.3f);
 }) {
 }
Exemplo n.º 20
0
 public PGameOverOrder() : base("game_over",
                                null,
                                (string[] args) => {
     string Winners             = args[1];
     int WinnerBonus            = Convert.ToInt32(args[2]);
     int GetMoney               = 2 + WinnerBonus;
     PSystem.UserManager.Money += GetMoney;
     PSystem.UserManager.Write();
     PAnimation.AddAnimation("游戏结束", () => {
         PUIManager.GetUI <PMapUI>().Ask("游戏结束,银两+" + GetMoney, new string[] {
             "为" + Winners + "的胜利干杯!",
             "天佑" + Winners + "!"
         });
     });
 }) {
 }
Exemplo n.º 21
0
 public PRefreshBlockBasicOrder() : base("refresh_block_basic",
                                         null,
                                         (string[] args) => {
     int BlockIndex             = Convert.ToInt32(args[1]);
     int LordIndex              = Convert.ToInt32(args[2]);
     int HouseNumber            = Convert.ToInt32(args[3]);
     int Price                  = Convert.ToInt32(args[5]);
     PBusinessType BusinessType = FindInstance <PBusinessType>(args[4]);
     PBlock Block               = PNetworkManager.NetworkClient.GameStatus.Map.FindBlock(BlockIndex);
     PPlayer Lord               = PNetworkManager.NetworkClient.GameStatus.FindPlayer(LordIndex);
     if (Block != null && BusinessType != null)
     {
         PAnimation.AddAnimation("刷新格子基本信息", () => {
             PPlayer OriginalLord = Block.Lord;
             Block.Lord           = Lord;
             Block.Price          = Price;
             Block.HouseNumber    = HouseNumber;
             Block.BusinessType   = BusinessType;
             PUIManager.GetUI <PMapUI>().Scene.BlockGroup.GroupUIList[BlockIndex].InitializeBlock(Block);
             if (OriginalLord != null)
             {
                 if (Block.IsBusinessLand)
                 {
                     OriginalLord.BusinessLandNumber--;
                 }
                 else
                 {
                     OriginalLord.NormalLandNumber--;
                 }
                 PUIManager.GetUI <PMapUI>().PlayerInformationGroup.Update(OriginalLord.Index);
             }
             if (Lord != null)
             {
                 if (Block.IsBusinessLand)
                 {
                     Lord.BusinessLandNumber++;
                 }
                 else
                 {
                     Lord.NormalLandNumber++;
                 }
                 PUIManager.GetUI <PMapUI>().PlayerInformationGroup.Update(Lord.Index);
             }
         });
     }
 }) {
 }
Exemplo n.º 22
0
 public PStartPeriodOrder() : base("start_period",
                                   null,
                                   (string[] args) => {
     int NowPlayerIndex = Convert.ToInt32(args[1]);
     PPeriod Peroid     = FindInstance <PPeriod>(args[2]);
     if (Peroid != null)
     {
         PNetworkManager.NetworkClient.GameStatus.NowPeriod = Peroid;
         PAnimation.AddAnimation("切换阶段为[" + Peroid + "]", () => {
             PUIManager.GetUI <PMapUI>().PlayerInformationGroup.GroupUIList.ForEach((PPlayerInformationBox Box) => {
                 Box.PeriodText.gameObject.SetActive(false);
             });
             Text CurrentPeriodText = PUIManager.GetUI <PMapUI>().PlayerInformationGroup.GroupUIList[NowPlayerIndex].PeriodText;
             CurrentPeriodText.text = Peroid.IsFreeTime() ? "空闲时间点" : Peroid.Name;
             CurrentPeriodText.gameObject.SetActive(true);
             PUIManager.GetUI <PMapUI>().EndFreeTimeButton.interactable = Peroid.IsFreeTime() && NowPlayerIndex == PSystem.PlayerIndex;
         }, 1, Config.ChangePeriodTime);
     }
 }) {
 }
Exemplo n.º 23
0
 public PRoomDataOrder() : base("room",
                                null,
                                (string[] args) => {
     try {
         int Capacity        = int.Parse(args[1]);
         PSystem.CurrentRoom = new PRoom(Capacity);
         #region 分析房间的属性
         int Index = 2;
         for (int i = 0; i < Capacity; ++i)
         {
             PPlayerType playerType = FindInstance <PPlayerType>(args[Index++]);
             if (playerType != null)
             {
                 PSystem.CurrentRoom.PlayerList[i].PlayerType = playerType;
                 PSystem.CurrentRoom.PlayerList[i].Nickname   = args[Index++];
                 if (PSystem.CurrentRoom.PlayerList[i].Nickname.Equals("&"))
                 {
                     PSystem.CurrentRoom.PlayerList[i].Nickname = string.Empty;
                 }
             }
         }
         #endregion
         #region 更新RUI的数据(未打开则先打开)及开始游戏按钮可交互性
         PUIManager.AddNewUIAction("RoomData-更新RUI数据", () => {
             if (!PUIManager.IsCurrentUI <PRoomUI>())
             {
                 PUIManager.ChangeUI <PRoomUI>();
                 //如果游戏已经开始,把游戏关闭
             }
             PUIManager.GetUI <PRoomUI>().SeatList.ForEach((PRoomUI.PSeat Seat) => {
                 Seat.Update();
             });
             PUIManager.GetUI <PRoomUI>().StartGameButton.interactable = PSystem.CurrentRoom.IsFull();
         });
         #endregion
     } catch (Exception e) {
         PLogger.Log("房间数据错误");
         PLogger.Log(e.ToString());
     }
 }) {
 }
Exemplo n.º 24
0
 public PHighlightBlockOrder() : base("hightlight_block",
                                      null,
                                      (string[] args) => {
     int BlockIndex = Convert.ToInt32(args[1]);
     int Frame      = 0;
     if (PUIManager.IsCurrentUI <PMapUI>() && 0 <= BlockIndex && BlockIndex < PNetworkManager.NetworkClient.GameStatus.Map.BlockList.Count)
     {
         PAnimation.AddAnimation("高亮格子", () => {
             PBlockScene Scene = PUIManager.GetUI <PMapUI>().Scene.BlockGroup.GroupUIList[BlockIndex];
             if (Frame == 0)
             {
                 Frame = 1;
                 Scene.BlockImage.gameObject.GetComponent <MeshRenderer>().material.color = PBlockScene.Config.HighlightedBlockColor;
             }
             else
             {
                 Scene.BlockImage.gameObject.GetComponent <MeshRenderer>().material.color = PBlockScene.Config.DefaultBlockColor;
             }
         }, 2, 0.5f);
     }
 }) {
 }
Exemplo n.º 25
0
 public override void Open()
 {
     base.Open();
     #region 返回按钮:回到InitialUI
     ReturnButton.onClick.AddListener(() => {
         PNetworkManager.AbortServer();
         PUIManager.AddNewUIAction("返回:转到IUI", () => PUIManager.ChangeUI <PInitialUI>());
     });
     #endregion
     #region 确定按钮:创建服务器
     EnterButton.onClick.AddListener(() => {
         string[] Parts = CodeInputField.text.Split(';');
         if (Parts.Length <= 2)
         {
             return;
         }
         int Times           = Math.Min(100, Math.Max(1, Convert.ToInt32(Parts[Parts.Length - 1])));
         PSystem.AllAiConfig = CodeInputField.text;
         PNetworkManager.CreateSingleServer(PSystem.CurrentMap, PSystem.CurrentMode);
         PThread.Async(() => {
             for (int i = 0; i < Times; ++i)
             {
                 string Time = DateTime.Now.ToLocalTime().ToString();
                 //PLogger.StartLogging(false);
                 List <PGeneral> GeneralList = GenerateGenerals(PSystem.AllAiConfig);
                 PNetworkManager.Game.Room.PlayerList.ForEach((PRoom.PlayerInRoom Player) => Player.PlayerType = PPlayerType.AI);
                 PNetworkManager.Game.StartGame(GeneralList);
                 PThread.WaitUntil(() => PNetworkManager.Game.ReadyToStartGameFlag);
                 PUIManager.AddNewUIAction("增加结果序列", () => {
                     PUIManager.GetUI <PTestUI>().ResultInputField.text += "Time: " + Time + "; Position: " + string.Join(",", PNetworkManager.Game.PlayerList.ConvertAll((PPlayer Player) => Player.General.Name)) + "; Winners: " + PNetworkManager.Game.Winners(true) + "\n";
                 });
             }
         });
     });
     #endregion
 }
Exemplo n.º 26
0
    public PAskOrder() : base("ask",
                              null,
                              (string[] args) => {
        string Title      = args[1];
        int OptionNumber  = Convert.ToInt32(args[2]);
        string[] Options  = new string[OptionNumber];
        string[] ToolTips = new string[OptionNumber];
        for (int i = 0; i < OptionNumber; ++i)
        {
            Options[i] = args[i + 3];
        }
        bool ToolTipEnabled = true;
        for (int i = 0; i < OptionNumber; ++i)
        {
            if (i + 3 + OptionNumber < args.Length)
            {
                ToolTips[i] = args[i + 3 + OptionNumber];
            }
            else
            {
                ToolTipEnabled = false;
                break;
            }
        }
        #region 点将卡和手气卡
        if (Title.Contains("点将卡"))
        {
            // 选将卡特殊判定
            // 必须要有选将卡才启用
            // 否则返回1
            if (PSystem.UserManager.ChooseGeneral == 0)
            {
                PNetworkManager.NetworkClient.Send(new PChooseResultOrder("1"));
                return;
            }
        }
        if (Title.Contains("手气卡"))
        {
            if (PSystem.UserManager.Lucky == 0)
            {
                PNetworkManager.NetworkClient.Send(new PChooseResultOrder("1"));
                return;
            }
        }
        if (Title.Equals("点将"))
        {
            for (int i = 0; i < Options.Length; ++i)
            {
                if (!PSystem.UserManager.GeneralList.Contains(Options[i]))
                {
                    Options[i] += "[未获得]";
                }
            }
        }
        #endregion


        PAnimation.AddAnimation("Ask-打开选择框", () => {
            PUIManager.GetUI <PMapUI>().Ask(Title, Options, ToolTipEnabled ? ToolTips : null);
        });
    }) {
    }
Exemplo n.º 27
0
    public PGeneralButtonUI Initialize(Transform Prototype, int _Index, int LineCapacity, PGeneral _General)
    {
        Index   = _Index;
        General = _General;
        UIBackgroundImage.GetComponentInChildren <Text>().text = General.Name;
        UIBackgroundImage.localScale    = new Vector3(1, 1, 1);
        UIBackgroundImage.localPosition = new Vector3(70.0f * (Index % LineCapacity) + Prototype.localPosition.x, -70.0f * (Index / LineCapacity) + Prototype.localPosition.y, 0.0f);

        void InvokeBuyGeneral(Button TargetButton)
        {
            string Method = (TargetButton.Equals(PUIManager.GetUI <PGeneralUI>().BuyArchPointButton) ? "成就点" : "银两");

            TargetButton.onClick.RemoveAllListeners();
            TargetButton.GetComponentInChildren <Text>().text = General.Cost.ToString() + Method + " 购买";
            TargetButton.onClick.AddListener(() => {
                if (!PSystem.UserManager.GeneralList.Contains(General.Name))
                {
                    bool CanPurchase = false;
                    if (Method.Equals("成就点") && PSystem.UserManager.ArchPoint >= General.Cost)
                    {
                        PSystem.UserManager.ArchPoint -= General.Cost;
                        CanPurchase = true;
                    }
                    else if (Method.Equals("银两") && PSystem.UserManager.Money >= General.Cost)
                    {
                        PSystem.UserManager.Money -= General.Cost;
                        CanPurchase = true;
                    }
                    if (CanPurchase)
                    {
                        PSystem.UserManager.GeneralList.Add(General.Name);
                        PSystem.UserManager.Write();
                        UIBackgroundImage.GetComponent <Image>().color = PGeneralUI.Config.GotGeneralColor;
                        PUIManager.GetUI <PGeneralUI>().BuyArchPointButton.interactable = false;
                        PUIManager.GetUI <PGeneralUI>().BuyMoneyButton.interactable     = false;
                    }
                }
            });
            if (PSystem.UserManager.GeneralList.Contains(General.Name))
            {
                TargetButton.interactable = false;
            }
            else
            {
                TargetButton.interactable = true;
            }
        }

        GeneralButton.onClick.AddListener(() => {
            PUIManager.GetUI <PGeneralUI>().GeneralInfoInputField.text = General.Name + "\n" +
                                                                         "性别:" + General.Sex + "\n" +
                                                                         "时代:" + General.Age + "\n" +
                                                                         string.Join("\n", General.SkillList.ConvertAll((PSkill Skill) => {
                PSkillInfo SkillInfo = ListInstance <PSkillInfo>().Find((PSkillInfo Info) => Info.Name.Equals(Skill.Name));
                if (SkillInfo == null)
                {
                    return(Skill.Name);
                }
                else
                {
                    return(Skill.Name + ":" + SkillInfo.ToolTip);
                }
            })) + "\n\n" +
                                                                         General.Tips;
            InvokeBuyGeneral(PUIManager.GetUI <PGeneralUI>().BuyArchPointButton);
            InvokeBuyGeneral(PUIManager.GetUI <PGeneralUI>().BuyMoneyButton);
        });
        UIBackgroundImage.gameObject.SetActive(true);
        return(this);
    }
Exemplo n.º 28
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            if (PUIManager.IsCurrentUI <PMapUI>())
            {
                PUIManager.GetUI <PMapUI>().Space();
            }
        }

        if (Input.GetMouseButtonDown(1))
        {
            MouseRightButtonDown = true;
            if (PUIManager.CurrentUI.Equals(PUIManager.GetUI <PMapUI>()))
            {
                PUIManager.AddNewUIAction("启动右键拖拽", () => {
                    PUIManager.GetUI <PMapUI>().CameraController.StopTracking();
                    LastMousePosition = Input.mousePosition;
                });
            }
        }
        if (Input.GetMouseButtonUp(1))
        {
            MouseRightButtonDown = false;
        }
        if (MouseRightButtonDown)
        {
            if (PUIManager.CurrentUI.Equals(PUIManager.GetUI <PMapUI>()))
            {
                PUIManager.AddNewUIAction(string.Empty, () => {
                    Vector3 MouseDirection = Input.mousePosition - LastMousePosition;
                    LastMousePosition      = Input.mousePosition;
                    Vector3 MoveDirection  = new Vector3(MouseDirection.y, 0, -MouseDirection.x) * Config.MouseSensitivity;
                    PUIManager.GetUI <PMapUI>().CameraController.ChangePerspective(PUIManager.GetUI <PMapUI>().CameraController.Camera.position + MoveDirection);
                });
            }
        }

        #region  标滚动
        if (Input.GetAxis("Mouse ScrollWheel") < 0)
        {
            if (PUIManager.CurrentUI.Equals(PUIManager.GetUI <PMapUI>()) && PUIManager.GetUI <PMapUI>().CameraController != null)
            {
                if (PMath.InRect(Input.mousePosition, PUIManager.GetUI <PMapUI>().InformationText.rectTransform))
                {
                    PUIManager.AddNewUIAction("查看下一条信息", () => {
                        PUIManager.GetUI <PMapUI>().NextInformation();
                    });
                }
                else
                {
                    PUIManager.AddNewUIAction("缩放[zoom+]", () => {
                        if (PCameraController.Config.CameraLockedDistance.magnitude < 80.0f)
                        {
                            PCameraController.Config.CameraLockedDistance += PCameraController.Config.CameraZoomDistance;
                            PUIManager.GetUI <PMapUI>().CameraController.ChangePerspective(PUIManager.GetUI <PMapUI>().CameraController.Camera.position + PCameraController.Config.CameraZoomDistance);
                        }
                    });
                }
            }
        }
        else if (Input.GetAxis("Mouse ScrollWheel") > 0)
        {
            if (PUIManager.CurrentUI.Equals(PUIManager.GetUI <PMapUI>()) && PUIManager.GetUI <PMapUI>().CameraController != null)
            {
                if (PMath.InRect(Input.mousePosition, PUIManager.GetUI <PMapUI>().InformationText.rectTransform))
                {
                    PUIManager.AddNewUIAction("查看上一条信息", () => {
                        PUIManager.GetUI <PMapUI>().LastInformation();
                    });
                }
                else
                {
                    PUIManager.AddNewUIAction("缩放[zoom-]", () => {
                        if (PCameraController.Config.CameraLockedDistance.magnitude > 20.0f)
                        {
                            PCameraController.Config.CameraLockedDistance -= PCameraController.Config.CameraZoomDistance;
                            PUIManager.GetUI <PMapUI>().CameraController.ChangePerspective(PUIManager.GetUI <PMapUI>().CameraController.Camera.position - PCameraController.Config.CameraZoomDistance);
                        }
                    });
                }
            }
        }
        #endregion

        #region  择格子
        if (Input.GetMouseButtonUp(0))
        {
            if (PUIManager.CurrentUI.Equals(PUIManager.GetUI <PMapUI>()) && !PUIManager.GetUI <PMapUI>().MessageBox.IsActive)
            {
                Vector3 WorldPosition1  = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 20.0f));
                Vector3 WorldPosition2  = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 30.0f));
                Vector3 WorldPosition   = new Vector3((WorldPosition1.x - WorldPosition2.x) / (WorldPosition1.y - WorldPosition2.y) * (-WorldPosition1.y) + WorldPosition1.x, 0, (WorldPosition1.z - WorldPosition2.z) / (WorldPosition1.y - WorldPosition2.y) * (-WorldPosition1.y) + WorldPosition1.z);
                PBlock  FindBlockResult = PNetworkManager.NetworkClient.GameStatus.Map.FindBlock(PUIManager.GetUI <PMapUI>().Scene.BlockGroup.FindBlockSceneIndex(WorldPosition));
                if (FindBlockResult != null)
                {
                    PNetworkManager.NetworkClient.Send(new PClickOnBlockOrder(FindBlockResult.Index.ToString()));
                }
            }
        }
        #endregion
    }
Exemplo n.º 29
0
 public static Vector3 GetScreenPosition(PPlayer Player)
 {
     return(PUIManager.GetUI <PMapUI>().CameraController.Camera.GetComponent <Camera>().WorldToScreenPoint(PUIManager.GetUI <PMapUI>().Scene.PlayerGroup.GroupUIList[Player.Index].UIBackgroundImage.position));
 }