Пример #1
0
    private static void DOWNLOAD_CITIES_REPLY(byte[] bytes)
    {
        DownloadCitiesReply input = DownloadCitiesReply.Parser.ParseFrom(bytes);

        if (!input.Ret)
        {
            string msg = $"查询城市信息失败!";
            GameRoomManager.Instance.Log("MSG: DOWNLOAD_CITIES_REPLY Error - " + msg);
            return;
        }
        GameRoomManager.Instance.Log($"MSG: DOWNLOAD_CITIES_REPLY OK - 城市个数:{input.MyCount}/{input.TotalCount}");

        // 如果我一个城市都没有,则主动创建一个城市
        if (input.MyCount == 0)
        {
            UrbanCity city = GameRoomManager.Instance.RoomLogic.UrbanManager.CreateRandomCity();
            if (city == null)
            {
                string msg = "自动创建城市失败!";
                UIManager.Instance.SystemTips(msg, PanelSystemTips.MessageType.Error);
                GameRoomManager.Instance.Log("MSG: DOWNLOAD_CITIES_REPLY - " + msg);
            }
            else
            {
                CityAdd output = new CityAdd()
                {
                    RoomId    = city.RoomId,
                    OwnerId   = city.OwnerId,
                    CityId    = city.CityId,
                    PosX      = city.PosX,
                    PosZ      = city.PosZ,
                    CellIndex = city.CellIndex,
                    CityName  = city.CityName,
                    CitySize  = city.CitySize,
                };
                GameRoomManager.Instance.SendMsg(ROOM.CityAdd, output.ToByteArray());
                GameRoomManager.Instance.Log("MSG: DOWNLOAD_CITIES_REPLY OK - 申请创建城市...");
            }
        }

        {
            string msg = $"查询城市信息成功!";
            GameRoomManager.Instance.Log("MSG: DOWNLOAD_CITIES_REPLY OK - " + msg + $"City Count:{input.MyCount}/{input.TotalCount}");
        }
        // 进入房间整体流程完成
        UIManager.Instance.EndLoading();
    }
Пример #2
0
    bool AskBuildCity()
    {
        HexCell cell = GetCellUnderCursor();

        if (cell && cell.Unit)
        {
            string msg = $"这里有部队存在,不能创建城市!";
            UIManager.Instance.SystemTips(msg, PanelSystemTips.MessageType.Error);
            GameRoomManager.Instance.Log("AskBuildCity - " + msg);
            return(false);
        }
        UrbanCity city = GameRoomManager.Instance.RoomLogic.UrbanManager.CreateCityHere(cell);

        if (city == null)
        {
            string msg = "无法创建城市!";
            UIManager.Instance.SystemTips(msg, PanelSystemTips.MessageType.Error);
            GameRoomManager.Instance.Log("AskBuildCity - " + msg);
            return(false);
        }
        else
        {
            CityAdd output = new CityAdd()
            {
                RoomId    = city.RoomId,
                OwnerId   = city.OwnerId,
                CityId    = city.CityId,
                PosX      = city.PosX,
                PosZ      = city.PosZ,
                CellIndex = city.CellIndex,
                CityName  = city.CityName,
                CitySize  = city.CitySize,
            };
            GameRoomManager.Instance.SendMsg(ROOM.CityAdd, output.ToByteArray());
            GameRoomManager.Instance.Log("AskBuildCity - 申请创建城市...");
        }
        return(true);
    }
Пример #3
0
    public void Run()
    {
        var pi = CommandManager.Instance.CurrentExecuter;

        if (pi == null || !pi.CurrentActor)
        {
            string msg = $"没有选中任何部队!";
            UIManager.Instance.SystemTips(msg, PanelSystemTips.MessageType.Error);
            GameRoomManager.Instance.Log("CmdBuildCity Error - " + msg);
            return;
        }

        long creatorId = 0;
        var  av        = pi.CurrentActor;

        if (av != null)
        {
            creatorId = av.ActorId;
        }
        else
        {
            string msg = "没有找到开拓者,无法创建城市!";
            UIManager.Instance.SystemTips(msg, PanelSystemTips.MessageType.Error);
            GameRoomManager.Instance.Log("CmdBuildCity Error - " + msg);
            return;
        }

        UrbanCity city = GameRoomManager.Instance.RoomLogic.UrbanManager.CreateCityHere(av.HexUnit.Location);

        if (city == null)
        {
            string msg = "这个位置无法创建城市!";
            UIManager.Instance.SystemTips(msg, PanelSystemTips.MessageType.Error);
            GameRoomManager.Instance.Log("CmdBuildCity Error - " + msg);
            return;
        }
        // 看看行动点够不够
        if (!CmdAttack.IsActionPointGranted())
        {
            string msg = "行动点数不够, 本操作无法执行! ";
            UIManager.Instance.SystemTips(msg, PanelSystemTips.MessageType.Error);
            Debug.Log("CmdBuildCity Run Error - " + msg);
            return;
        }

        {
            CityAdd output = new CityAdd()
            {
                RoomId    = city.RoomId,
                OwnerId   = city.OwnerId,
                CityId    = city.CityId,
                PosX      = city.PosX,
                PosZ      = city.PosZ,
                CellIndex = city.CellIndex,
                CityName  = city.CityName,
                CitySize  = city.CitySize,
                CreatorId = creatorId,
            };
            GameRoomManager.Instance.SendMsg(ROOM.CityAdd, output.ToByteArray());
            GameRoomManager.Instance.Log("AskBuildCity - 申请创建城市...");
            // 消耗行动点
            CmdAttack.TryCommand();
        }
    }