예제 #1
0
    public void StartTrain()
    {
        if (startTrainReceive)
        {
            MarchVo march = playerProxy.marchList [marchIndex];
            bool    find  = false;
            for (int i = 0; i < march.troopList.Count; i++)
            {
                if (GetTroopState(i) == TroopState.NeedTrain)
                {
                    find = true;
                    startTrainReceive = false;
                    SendCGTroopTrain(march.troopList [i].queueIndex, curBuildingGuid, march.troopList [i].type, 20);
                    break;
                }
            }

            //临时处理 队伍列表里没找到可以训练的  那就看看新添加的列表有没有
            if (!find)
            {
                if (addTrainList.Count > 0)
                {
                    SendCGTroopTrain(addTrainList[0].queueIndex, curBuildingGuid, addTrainList[0].type, 20);
                    addTrainList.RemoveAt(0);
                }
            }
        }
    }
        private void SetProxy(GC_LOGIN_RET packet)
        {
            PlayerProxy proxy = GameFacade.GetProxy <PlayerProxy>();

            proxy.userid      = packet.Userid;
            proxy.oid         = packet.Oid;
            proxy.accesstoken = packet.Accesstoken;
            proxy.playername  = packet.Playername;
            proxy.level       = packet.Level;

            //城市数据
            proxy.city.cityId   = packet.City.CityId;
            proxy.city.tileId   = packet.City.TileId;
            proxy.city.level    = packet.City.Level;
            proxy.city.food     = packet.City.Food;
            proxy.city.stone    = packet.City.Stone;
            proxy.city.iron     = packet.City.Iron;
            proxy.city.WorldPos = new Coord(packet.City.Posx, packet.City.Posz);

            proxy.city.buildList.Clear();
            for (int i = 0; i < packet.City.buildlistCount; i++)
            {
                GC_BuildingData data = packet.City.GetBuildlist(i);
                BuildingVo      vo   = new BuildingVo();
                PlayerProxy.SetBuildVo(data, vo);
                proxy.city.buildList.Add(vo);
            }

            proxy.city.trainList.Clear();
            for (int i = 0; i < packet.City.trainListCount; i++)
            {
                GC_TrainData data = packet.City.GetTrainList(i);
                TrainVo      vo   = new TrainVo();
                PlayerProxy.SetTrainVo(data, vo);
                proxy.city.trainList.Add(vo);
            }

            //英雄数据
            proxy.heroList.Clear();
            for (int i = 0; i < packet.HeroList.heroListCount; i++)
            {
                GC_HeroData data = packet.HeroList.GetHeroList(i);
                HeroVo      vo   = new HeroVo();
                PlayerProxy.SetHeroVo(data, vo);
                proxy.heroList.Add(vo);
            }

            //队伍数据
            proxy.marchList.Clear();
            for (int i = 0; i < packet.Marchlist.marchlistCount; i++)
            {
                GC_MarchData data = packet.Marchlist.GetMarchlist(i);
                MarchVo      vo   = new MarchVo();
                PlayerProxy.SetMarchVo(data, vo);
                proxy.marchList.Add(vo);
            }
        }
예제 #3
0
    //获取当前队伍某位置的单位的训练状态
    public TroopState GetTroopState(int index)
    {
        MarchVo march = playerProxy.marchList [marchIndex];
        //临时处理
        TroopVo troop = null;

        if (march.troopList.Count <= index)
        {
            if (addTrainList.Count > index - march.troopList.Count)
            {
                troop = addTrainList [index - march.troopList.Count];
            }
        }
        else
        {
            troop = march.troopList [index];
        }

        List <Tab_RoleBaseAttr> attrList = TableManager.GetRoleBaseAttrByID(troop.type);
        Tab_RoleBaseAttr        roleAttr = attrList [troop.level - 1];
        int totalHP = roleAttr.MaxHP * 18;

        if (troop.health < totalHP)
        {
            for (int i = 0; i < playerProxy.city.trainList.Count; i++)
            {
                if (playerProxy.city.trainList[i].queueIndex == troop.queueIndex)
                {
                    if (playerProxy.city.trainList[i].troopType <= 0)
                    {
                        break;
                    }
                    //类型为0说明没有训练了 时间到了等于训练结束了
                    System.DateTime dt1 = System.Convert.ToDateTime("1970-1-1 00:00:00");
                    long            now = System.DateTime.Now.ToFileTimeUtc() - dt1.ToFileTimeUtc();
                    float           a   = now / 10000000;
                    int             aa  = Mathf.FloorToInt(a);
                    //等于0也算是空闲
                    if (playerProxy.city.trainList[i].troopType >= 0)
                    {
                        if (playerProxy.city.trainList[i].endTime <= aa)
                        {
                            return(TroopState.Training);                           //训练中
                        }
                    }
                }
            }
            return(TroopState.NeedTrain);
        }

        return(TroopState.TrainFull);
    }
예제 #4
0
    //临时处理 前端直接处理新增的Troop
    public void AddToBuildSequence(int id)
    {
        MarchVo march = playerProxy.marchList [marchIndex];

        if (march.troopList.Count + addTrainList.Count < 5)
        {
            TroopVo troop = new TroopVo();
            troop.type       = id;
            troop.health     = 0;
            troop.level      = 1;
            troop.queueIndex = march.troopList.Count + addTrainList.Count;
            addTrainList.Add(troop);
            //更新造兵队列
            EventManager.GetInstance().SendEvent("Private_TroopTrainRefreshTroops");
        }
    }
    static public void SetMarchVo(GC_MarchData data, MarchVo vo)
    {
        vo.marchId   = data.Marchid;
        vo.playerId  = data.Playerid;
        vo.cityId    = data.CityId;
        vo.fightId   = data.Fightid;
        vo.buildId   = data.Buildid;
        vo.sceneId   = data.Sceneid;
        vo.beginTime = data.Begintime;
        vo.status    = data.Status;
        vo.speed     = data.Speed;

        vo.hero = new HeroVo();
        SetHeroVo(data.Hero, vo.hero);

        vo.troopList.Clear();
        for (int i = 0; i < data.troopCount; i++)
        {
            GC_TroopData tData = data.GetTroop(i);
            TroopVo      tVo   = new TroopVo();
            SetTroopVo(tData, tVo);
            vo.troopList.Add(tVo);
        }
    }
예제 #6
0
    public int GetTroopQueueIndex(int index)
    {
        MarchVo march = playerProxy.marchList [marchIndex];
        //临时处理
        TroopVo troop = null;

        if (march.troopList.Count <= index)
        {
            if (addTrainList.Count > index - march.troopList.Count)
            {
                troop = addTrainList [index - march.troopList.Count];
            }
        }
        else
        {
            troop = march.troopList [index];
        }
        if (troop == null)
        {
            return(-1);
        }

        return(troop.queueIndex);
    }
예제 #7
0
    //获取当前部队 各个单位的头像
    public string GetTroopIcon(int index)
    {
        MarchVo march = playerProxy.marchList [marchIndex];
        //临时处理
        TroopVo troop = null;

        if (march.troopList.Count <= index)
        {
            if (addTrainList.Count > index - march.troopList.Count)
            {
                troop = addTrainList[index - march.troopList.Count];
            }
        }
        else
        {
            troop = march.troopList [index];
        }
        if (troop != null)
        {
            List <Tab_Troop> troopTempList = TableManager.GetTroopByID(troop.type);
            return(troopTempList [0].Portrait);
        }
        return("");
    }
        public uint Execute(PacketDistributed ipacket)
        {
            GC_Troop_Train packet = (GC_Troop_Train )ipacket;

            if (null == packet)
            {
                return((uint)PACKET_EXE.PACKET_EXE_ERROR);
            }
            //enter your logic
            if (packet.Ret == 0)
            {
                PlayerProxy playerProxy = GameFacade.GetProxy <PlayerProxy> ();

                bool find = false;
                for (int i = 0; i < playerProxy.city.trainList.Count; i++)
                {
                    if (playerProxy.city.trainList[i].queueid == packet.Data.Queueid)
                    {
                        find = true;
                        PlayerProxy.SetTrainVo(packet.Data, playerProxy.city.trainList [i]);
                    }
                }

                if (!find)
                {
                    TrainVo train = new TrainVo();
                    PlayerProxy.SetTrainVo(packet.Data, train);
                    playerProxy.city.trainList.Add(train);
                }

                find = false;
                MarchVo march = null;
                for (int i = 0; i < playerProxy.marchList.Count; i++)
                {
                    if (playerProxy.marchList [i].buildId == packet.Data.Buildid)
                    {
                        march = playerProxy.marchList [i];
                        for (int j = 0; j < playerProxy.marchList [i].troopList.Count; j++)
                        {
                            TroopVo vo = playerProxy.marchList [i].troopList [j];
                            if (vo.queueIndex == packet.Data.Queueindex)
                            {
                                find = true;
                            }
                        }
                    }
                }
                if (!find)
                {
                    TroopVo troop = new TroopVo();
                    troop.type       = packet.Data.Trooptype;
                    troop.health     = 0;
                    troop.level      = 1;
                    troop.queueIndex = packet.Data.Queueindex;
                    march.troopList.Add(troop);
                }

                EventManager.GetInstance().SendEvent(EventId.TroopTrain, null);
            }
            else
            {
                UnityEngine.Debug.Log("数据包报错了!!!");
            }

            return((uint)PACKET_EXE.PACKET_EXE_CONTINUE);
        }