Ejemplo n.º 1
0
    virtual public void Init()
    {
        complexBattleParam = new DataUnit.BasicBattleParam();
        complexBattleParam.Copy(_dataUnit.battleParam);

        if (isPlayerUnit)
        {
            if (InstancePlayer.instance.model_User.isLogin)
            {
                Model_Unit     modelUnit = InstancePlayer.instance.model_User.unlockUnits [unitId];
                DataUnitPart[] dataParts = modelUnit.GetDataParts();
                foreach (DataUnitPart part in dataParts)
                {
                    complexBattleParam.Add(part.battleParam);
                }
            }

            if (heroId > 0)
            {
                SlgPB.Hero hero     = InstancePlayer.instance.model_User.model_heroGroup.GetHero(heroId);
                DataHero   dataHero = DataManager.instance.dataHeroGroup.GetHero(heroId, hero.exp, hero.stage);
                complexBattleParam.Add(dataHero.basicParam);
            }
        }

        complexBattleParam.damage *= powerScale;
        complexBattleParam.ammo   *= powerScale;
        complexBattleParam.hp     *= unitCount;
        currentHp = complexBattleParam.hp;
    }
Ejemplo n.º 2
0
    public static int CalcUnitPower(int unitId, int unitCount, int heroId)
    {
        Model_Unit modelUnit = InstancePlayer.instance.model_User.unlockUnits [unitId];
        DataUnit   dataUnit  = DataManager.instance.dataUnitsGroup.GetUnit(unitId);

        DataUnitPart[] dataUnitParts = modelUnit.GetDataParts();

        int pHero = 0;

        if (heroId > 0)
        {
            SlgPB.Hero modelHero = InstancePlayer.instance.model_User.model_heroGroup.GetHero(heroId);
            DataHero   dataHero  = DataManager.instance.dataHeroGroup.GetHero(heroId, modelHero.exp, modelHero.stage);
            pHero = dataHero.basicParam.CalcPower();
        }

        int pUnit  = dataUnit.battleParam.CalcPower();
        int pTotal = pHero + pUnit * unitCount;

        foreach (DataUnitPart dataUnitPart in dataUnitParts)
        {
            if (dataUnitPart != null)
            {
                int pPart = dataUnitPart.battleParam.CalcPower();
                pTotal += pPart;
            }
        }

        return(pTotal);
    }
Ejemplo n.º 3
0
    public void InitHeroSlotUI()
    {
        GameObject prefab = Resources.Load(HERO_TIEM_PATH) as GameObject;
        GameObject obj    = NGUITools.AddChild(this.gameObject, prefab);

        obj.transform.parent = _heroPanel.dragDropRoot.transform;

        obj.transform.Find("Hero_Head_Sprite").gameObject.SetActive(true);
        obj.transform.Find("Hero_Body_Sprite").gameObject.SetActive(false);

        dragItemUI = obj.GetComponent <UIHeroDragItem>();
        dragItemUI.InitForSlot();
        dragItemUI.attachSlotUI = this;

        UIHeroHeadItem slotItem = obj.GetComponent <UIHeroHeadItem>();

        SlgPB.Hero hero = InstancePlayer.instance.model_User.model_heroGroup.GetHero(model_UnitGroup.heroId);
        slotItem.UpdateUI(hero);

        UIHeroDragItem dragItem = obj.GetComponent <UIHeroDragItem>();

        dragItem.attachSlotUI  = this;
        dragItem.heroPanel     = _heroPanel;
        dragItem.slotUIManager = _heroPanel._battleFormationPanel.slotUIManager;
    }
Ejemplo n.º 4
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;
    }
Ejemplo n.º 5
0
    public int CalcHeroLeadership(int heroId, int unitId)
    {
        SlgPB.Hero hero = InstancePlayer.instance.model_User.model_heroGroup.GetHero(heroId);

        DataHero dataHero = DataManager.instance.dataHeroGroup.GetHero(heroId, hero.exp, hero.stage);

        return(dataHero.leadership);
    }
Ejemplo n.º 6
0
    public void UpdateUI(UIHeroCategory.Hero heroCategory)
    {
        SlgPB.Hero pb_hero = heroCategory.pb_Hero;
        heroId = pb_hero.heroId;

        DataHero dataHero = DataManager.instance.dataHeroGroup.GetHero(pb_hero.heroId, pb_hero.exp, pb_hero.stage);

        _heroSprite.spriteName = UICommon.HERO_BODY_ICON_PATH + pb_hero.heroId;
        _nameLabel.text        = dataHero.name;

        SetOnDutyVisible(heroCategory.isOnDuty);
    }
Ejemplo n.º 7
0
    public void UpdateUI(int heroId)
    {
        _heroId = heroId;

        SlgPB.Hero hero     = InstancePlayer.instance.model_User.model_heroGroup.GetHero(heroId);
        DataHero   dataHero = DataManager.instance.dataHeroGroup.GetHero(heroId, hero.exp, hero.stage);

        _heroSprite.spriteName = UICommon.HERO_HEAD_ICON_PATH + hero.heroId;
        _nameLabel.text        = dataHero.name;

        this.GetComponent <UIHeroBodyItem> ().heroId = heroId;
    }
Ejemplo n.º 8
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;
    }
Ejemplo n.º 9
0
    // 创建离线测试数据
    public void CreateLocalHeroList()
    {
        Dictionary <int, SlgPB.Hero> heroesMap = InstancePlayer.instance.model_User.model_heroGroup.heroesMap;

        DataHero[] heros = DataManager.instance.dataHeroGroup.GetAllHeroPrimitive();

        for (int i = 0; i < heros.Length; ++i)
        {
            SlgPB.Hero hero = new SlgPB.Hero();
            hero.heroId = heros [i].id;
            hero.exp    = 1;
            hero.stage  = 1;

            heroesMap.Add(hero.heroId, hero);
        }
    }
Ejemplo n.º 10
0
    public static RESULT CheckResult(int heroId)
    {
        SlgPB.Hero hero    = InstancePlayer.instance.model_User.model_heroGroup.GetHero(heroId);
        bool       hasHero = (hero != null);

        if (hasHero)
        {
            return(RESULT.LACK_ALREADY_HAVE);
        }

        if (!InstancePlayer.instance.model_User.model_heroGroup.HasEnoughItemToCompose(heroId))
        {
            return(RESULT.LACK_ITEM);
        }


        return(RESULT.OK);
    }
Ejemplo n.º 11
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;
 }
Ejemplo n.º 12
0
 public void AddHero(SlgPB.Hero hero)
 {
     heroesMap[hero.heroId] = hero;
 }