static public void SetTroopVo(GC_TroopData data, TroopVo vo)
    {
        vo.type         = data.Type;
        vo.level        = data.Level;
        vo.health       = data.Hp;
        vo.mana         = data.Mp;
        vo.arrangeIndex = data.Arrangeindex;
        vo.marchId      = data.Marchid;
        vo.queueIndex   = data.Queueindex;

        vo.skillIdList.Clear();
        for (int i = 0; i < data.skillCount; i++)
        {
            int skill = data.GetSkill(i);
            vo.skillIdList.Add(skill);
        }

        vo.cooldownList.Clear();
        for (int i = 0; i < data.cooldownCount; i++)
        {
            GC_CoolDownInfo coolDown = data.GetCooldown(i);
            CoolDownVo      cVo      = new CoolDownVo();
            cVo.cdTime  = coolDown.Cdtime;
            cVo.elapsed = coolDown.Elapsed;
            cVo.id      = coolDown.Id;
            vo.cooldownList.Add(cVo);
        }
    }
Exemplo n.º 2
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);
    }
Exemplo n.º 3
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);
        }
    }
Exemplo n.º 5
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);
    }
Exemplo n.º 6
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);
        }