Exemplo n.º 1
0
    void ImmediatelyRepairUnit()     // 立即完成维修
    {
        UIHelper.LoadingPanelIsOpen(true);
        RepairUnitRequest request = new RepairUnitRequest();

        request.api = new Model_ApiRequest().api;


        if (_tankRepairItemDic != null)
        {
            foreach (KeyValuePair <int, TankRepairItem> kv in _tankRepairItemDic)
            {
                TankRepairItem tankItem  = kv.Value;
                Model_Unit     modelUnit = tankItem.GetCurrentModelUnit();
                int            tankNum   = tankItem.GetCurrentRepairTankNum();
                if (tankNum != null && tankNum > 0)
                {
                    SlgPB.Unit unit = new SlgPB.Unit();
                    unit.unitId = modelUnit.unitId;
                    unit.num    = tankItem.GetCurrentRepairTankNum();
                    request.units.Add(unit);
                }
            }
        }
        request.buyCd = 1;
        (new PBConnect_repairUnit()).Send(request, OnImmediatelyRepairUnit);
    }
Exemplo n.º 2
0
    private void CreateTestPvp()
    {
        SlgPB.PVPUser pvp = new SlgPB.PVPUser();

        SlgPB.UnitGroup unitGroup = new SlgPB.UnitGroup();
        pvp.unitGroups.Add(unitGroup);
        unitGroup.posId  = 1;
        unitGroup.unitId = 1;
        unitGroup.num    = 10;
        unitGroup.heroId = 2;

        SlgPB.Hero pbHero = new SlgPB.Hero();
        pvp.heroes.Add(pbHero);
        pbHero.heroId = 2;
        pbHero.exp    = 100;
        pbHero.stage  = 1;

        SlgPB.Unit pbUnit = new SlgPB.Unit();
        pvp.units.Add(pbUnit);
        pbUnit.unitId = 1;
        pbUnit.unitPartLevel.Add(1);
        pbUnit.unitPartLevel.Add(1);
        pbUnit.unitPartLevel.Add(1);
        pbUnit.unitPartLevel.Add(1);

        InstancePlayer.instance.pvpUser = pvp;
    }
Exemplo n.º 3
0
    public void ImportFromPvp(SlgPB.PVPUser pvpUser)
    {
        InitPvpDataMap(pvpUser);

        mission       = new DataMission();
        mission.asset = DataMission.BK_NAMES [(int)RandomHelper.Range(0, DataMission.BK_NAMES.Length)];

        extraTeamCount = 1;
        enemyTeams     = new InstanceTeam[extraTeamCount];
        friendTeams    = new InstanceTeam[extraTeamCount];

        InstanceTeam instanceTeam = new InstanceTeam();

        instanceTeam.units = new InstanceUnitPvp[DataConfig.FORMATION_TOTAL_SLOT];

        int memberCount = pvpUser.unitGroups.Count;

        for (int i = 0; i < memberCount; ++i)
        {
            SlgPB.UnitGroup group = pvpUser.unitGroups [i];

            int   unitId     = group.unitId;
            int   unitCount  = group.num;
            int   heroId     = group.heroId;
            float powerScale = 1;

            if (unitId > 0 && unitCount > 0)
            {
                SlgPB.Hero pbHero = null;
                if (pbHeroesMap.ContainsKey(heroId))
                {
                    pbHero = pbHeroesMap [heroId];
                }

                SlgPB.Unit pbUnit = null;
                if (pbUnitsMap.ContainsKey(unitId))
                {
                    pbUnit = pbUnitsMap [unitId];
                }

                InstanceUnitPvp instanceUnitPvp = new InstanceUnitPvp(false, heroId, unitId, unitCount, powerScale, pbHero, pbUnit);
                instanceUnitPvp.Init();

                int slotId = group.posId - 1;
                instanceTeam.units[slotId] = instanceUnitPvp;
            }
        }

        enemyTeams [0] = instanceTeam;
    }
Exemplo n.º 4
0
    void RepairUnit()     // 正常维修
    {
        RepairUnitRequest request = new RepairUnitRequest();

        request.api = new Model_ApiRequest().api;

        SlgPB.Unit unit = new SlgPB.Unit();
        unit.unitId = InstancePlayer.instance.model_User.unlockUnitsId [0];
        unit.num    = 1;
        request.units.Add(unit);

        request.buyCd = 0;

        (new PBConnect_repairUnit()).Send(request, OnRepairUnit);

        InstancePlayer.instance.model_User.model_Queue.AddUnitRepairQueue();
    }
Exemplo n.º 5
0
    /// <summary>
    /// Updates the state of the current tank.
    /// </summary>
    void UpdateCurrentTankState()
    {
        if (_dataUnit != null)
        {
            _model_RepairUnit = InstancePlayer.instance.model_User.model_RepairUnit;

            _RepairUnits = _model_RepairUnit.GetRepairUnits();
            foreach (SlgPB.Unit unit in _RepairUnits)
            {
                if (_dataUnit.id == unit.unitId)
                {
                    _RepairUnit = unit;
                    break;
                }
                else
                {
                    _RepairUnit = null;
                }
            }
        }

        if (_model_unit != null)
        {
            if (_unitData.isUnLock == true)
            {
                _currentInventoryLabel.text = _model_unit.num.ToString();
                _currentDamageLabel.text    = _model_unit.onDamaged.ToString();
                if (_RepairUnit != null)
                {
                    _repairIngLabel.text = _RepairUnit.onRepair.ToString();
                }
                else
                {
                    _repairIngLabel.text = "0";
                }
            }
        }
        else
        {
            _currentInventoryLabel.text = "0";
            _repairIngLabel.text        = "0";
            _currentDamageLabel.text    = "0";
        }
    }
Exemplo n.º 6
0
    public void Parse(SlgPB.Unit unit)
    {
        unitId            = unit.unitId;
        num               = unit.num;
        onProduce         = unit.onProduce;
        produceEndTimeSec = unit.produceEndTime;
        produceTotalTime  = unit.produceTotalTime;
        onRepair          = unit.onRepair;

        onDamaged = unit.onDamaged;

        if (onProduce > 0)
        {
            nextProduceEndTimestamp = TimeHelper.GetCurrentRealTimestamp() + produceEndTimeSec * 1000;
        }
        else
        {
            nextProduceEndTimestamp = 0;
        }

        partLevels = unit.unitPartLevel.ToArray();
        Assert.assert(partLevels.Length > 0);
    }
Exemplo n.º 7
0
    // unit
    // ============================================================

    public void UpdateUnit(SlgPB.Unit slgUnit)
    {
        Model_Unit model_Unit;
        int        unitId = slgUnit.unitId;

        unlockUnits.TryGetValue(unitId, out model_Unit);
        if (model_Unit == null)
        {
            model_Unit = new Model_Unit();
            unlockUnits.Add(unitId, model_Unit);
        }

        model_Unit.Parse(slgUnit);

        // 添加已解锁unitId
        if (!unlockUnitsId.Contains(unitId))
        {
            unlockUnitsId.Add(unitId);
        }

        //服务器下发Unit 数量
        //DataUnit dataUnit = DataManager.instance.dataUnitsGroup.GetUnit (slgUnit.unitId);
        //Trace.trace ("id," + slgUnit.unitId + ",name," + dataUnit.name + ",num," + slgUnit.num, Trace.CHANNEL.UI);
    }
Exemplo n.º 8
0
 public InstanceUnitPvp(bool isPlayerUnit, int heroId, int unitId, int unitCount, float powerScale, SlgPB.Hero pbHero, SlgPB.Unit pbUnit)
     : base(isPlayerUnit, heroId, unitId, unitCount, powerScale)
 {
     this.pbHero = pbHero;
     this.pbUnit = pbUnit;
 }