Пример #1
0
    void SetUnitGroup()     //设置阵型
    {
        InstancePlayer.instance.model_User.model_Formation.SetSelectTeamId(1);

        //
        SetUnitGroupRequest request = new SetUnitGroupRequest();

        Model_Formation model_Formation = InstancePlayer.instance.model_User.model_Formation;

        Model_Unit model_Unit;

        InstancePlayer.instance.model_User.unlockUnits.TryGetValue(1, out model_Unit);
        Model_UnitGroup model_UnitGroup = new Model_UnitGroup();

        if (model_Unit != null)
        {
            model_UnitGroup.unitId = model_Unit.unitId;
            model_UnitGroup.num    = model_Unit.num;
            model_UnitGroup.teamId = 1;
            model_UnitGroup.posId  = 1;
        }
        model_Formation.Add(model_UnitGroup);

        model_Formation.CreateUnitGroupsResquest(request.unitGroup);

        request.api = new Model_ApiRequest().api;
        (new PBConnect_setUnitGroup()).Send(request, OnSetUnitGroup);
    }
Пример #2
0
    private void CalcWinResult()
    {
        DataMission mission  = DataManager.instance.dataMissionGroup.GetMission(_multiFightRequest.missionId);
        int         gotExp   = mission.exp;
        int         gotHonor = mission.honor;

        InstancePlayer.instance.model_User.UpdateHonor(gotHonor * _multiFightRequest.num);

        Model_HeroGroup heroGroup = InstancePlayer.instance.model_User.model_heroGroup;
        Model_Formation formation = InstancePlayer.instance.model_User.model_Formation;

        int[] HeroesId = formation.GetSelectTeamHeroesId();

        for (int i = 0; i < _multiFightRequest.num; ++i)
        {
            List <Model_HeroGroup.ExpChangeResult> result = new List <Model_HeroGroup.ExpChangeResult> ();
            InstancePlayer.instance.multiFightHeroGotExp.Add(result);

            foreach (int heroId in HeroesId)
            {
                if (heroId > 0)
                {
                    Model_HeroGroup.ExpChangeResult r = heroGroup.AddExp(heroId, gotExp);
                    result.Add(r);
                }
            }
        }
    }
Пример #3
0
    private void CreateBattle(DataMission mission)
    {
        //CreateTestPlayerTeam ();

        Model_Formation model_Formation = InstancePlayer.instance.model_User.model_Formation;

        if (GameOffine.START_OF_OFFLINE || !InstancePlayer.instance.model_User.isLogin)
        {
            int batteUnitCount = model_Formation.GetCurrentTeamUnitCount();
            if (batteUnitCount <= 0)
            {
                model_Formation.CreateLocalData();                  //创建本地测试Team1数据
            }

            if (false)
            {
                CreateTestPvp();
            }
        }
        model_Formation.CreatePlayerArmy();

        InstancePlayer.instance.battle = new InstanceBattle();
        InstancePlayer.instance.battle.ImportFromPlayer();
        if (InstancePlayer.instance.pvpUser != null)
        {
            InstancePlayer.instance.battle.ImportFromPvp(InstancePlayer.instance.pvpUser);
        }
        else
        {
            InstancePlayer.instance.battle.ImportFromLevel(mission);
        }
        InstancePlayer.instance.battle.ImportMap();
    }
Пример #4
0
    public static RESULT SetFormation(PBConnect_setUnitGroup.DelegateConnectCallback OnSetFormation)
    {
        RESULT result = RESULT.OK;

        SetUnitGroupRequest request         = new SetUnitGroupRequest();
        Model_Formation     model_Formation = InstancePlayer.instance.model_User.model_Formation;

        model_Formation.CreateUnitGroupsResquest(request.unitGroup);
        request.api = new Model_ApiRequest().api;

        (new PBConnect_setUnitGroup()).Send(request, OnSetFormation);

        return(result);
    }
    void Awake()
    {
        scrollViewItemUI = transform.Find("formation_unit_scrollview").gameObject;

        name_Label  = scrollViewItemUI.transform.Find("name_Label").GetComponent <UILabel>();
        count_Label = scrollViewItemUI.transform.Find("count_Label").GetComponent <UILabel>();
        unit_Sprite = scrollViewItemUI.transform.Find("unit_Sprite").GetComponent <UISprite>();

        battle_Sprite = scrollViewItemUI.transform.Find("battle_Sprite").GetComponent <UISprite>();
        bg_Sprite     = scrollViewItemUI.transform.Find("bg_Sprite").GetComponent <UISprite>();

        model_Formation = InstancePlayer.instance.model_User.model_Formation;

        UIHelper.AddBtnClick(GetComponent <UIButton> (), UnitDetialPanelCB);
    }
Пример #6
0
    public void UpdateData()
    {
        unitsGroup      = DataManager.instance.dataUnitsGroup.GetAllUnits();
        unlockUnits     = InstancePlayer.instance.model_User.unlockUnitsId;
        model_units     = InstancePlayer.instance.model_User.unlockUnits;
        model_Formation = InstancePlayer.instance.model_User.model_Formation;
        model_itemGroup = InstancePlayer.instance.model_User.model_itemGroup;
        allList.Clear();
        gunList.Clear();
        cannonList.Clear();
        missileList.Clear();
        howitzerList.Clear();

        int unitsGroupCount = unitsGroup.Length;

        for (int i = 0; i < unitsGroupCount; i++)
        {
            if (unitsGroup[i].buildingLevel == 0)
            {
                continue;
            }
            UnitData unit = InitUnitData(unitsGroup[i]);
            allList.Add(unit);

            switch (unitsGroup[i].bulletType)
            {
            case DataConfig.BULLET_TYPE.GUN:
                gunList.Add(unit);
                break;

            case DataConfig.BULLET_TYPE.CANNON:
                cannonList.Add(unit);
                break;

            case DataConfig.BULLET_TYPE.MISSILE:
                missileList.Add(unit);
                break;

            case DataConfig.BULLET_TYPE.HOWITZER:
                howitzerList.Add(unit);
                break;

            default:
                break;
            }
        }
    }
Пример #7
0
 private void UpdateHerosOnDuty(List <Hero> heros)
 {
     foreach (Hero hero in heros)
     {
         Model_Formation model_Formation = InstancePlayer.instance.model_User.model_Formation;
         int             teamId          = model_Formation.GetSelectTeamId();
         hero.isOnDuty = model_Formation.IsTeamContaninHero(teamId, hero.id);
         if (hero.isOnDuty)
         {
             hero.weight = HERO_BASIC_WEIGHT + hero.id;
         }
         else
         {
             hero.weight = hero.id;
         }
     }
 }
 private void UpdateUnitsOnDuty(List <FormationUnitCategory.Unit> units)
 {
     foreach (FormationUnitCategory.Unit unit in units)
     {
         Model_Formation model_Formation = InstancePlayer.instance.model_User.model_Formation;
         int             teamId          = model_Formation.GetSelectTeamId();
         unit.isOnDuty = model_Formation.IsTeamContaninUnit(teamId, unit.id);
         if (unit.isOnDuty)
         {
             int slotId = model_Formation.GetPosId(teamId, unit.id);
             unit.Weight = UNIT_SLOT_NUM - slotId;
         }
         else
         {
             unit.Weight = -1;
         }
     }
 }
Пример #9
0
    public override void Init()
    {
        base.Init();

        animationType = AnimationType.ALPHA;

        dragDropRoot        = UIHelper.FindChildInObject(gameObject, "UIDragDropRoot").GetComponent <UIDragDropRoot>();
        UIDragDropRootPanel = dragDropRoot.GetComponent <UIPanel>();

        _close_btn  = UIHelper.FindChildInObject(gameObject, "CloseBtn").GetComponent <UIButton> ();
        _battle_btn = UIHelper.FindChildInObject(gameObject, "BattleBtn").GetComponent <UIButton> ();

        UpdateBtnState(_battle_btn.gameObject);

        _attack_Label  = UIHelper.FindChildInObject(gameObject, "EnergyLabel").transform.Find("Label").GetComponent <UILabel> ();
        _replenish_btn = UIHelper.FindChildInObject(gameObject, "supplybtn").GetComponent <UIButton> ();

        formationUIController = gameObject.GetComponent <FormationUIController> ();


        for (int i = 0; i < TEAM_COUNT; ++i)
        {
            formation_team[i] = UIHelper.FindChildInObject(gameObject, "Formation_Team_" + i);
        }

        CreateScrollView();

        AddBtnClick();

        // 当前玩家拥有Unit分组
        formationUnitCategory = new FormationUnitCategory(InstancePlayer.instance.model_User.unlockUnits);

        // 阵型数据
        model_Formation = InstancePlayer.instance.model_User.model_Formation;

        // 初始化军官
        _heroPanel = this.GetComponent <UIHeroPanel>();
        _heroPanel.Init(this);

        // slot UI Manager
        slotUIManager = this.GetComponent <FormationSlotUIManager> ();

        // 初始化 slot 数据
        InitSlotUI();

        // 默认显示Team 1

        int teamId = InstancePlayer.instance.model_User.model_Formation.GetSelectTeamId();

        if (teamId <= 0)
        {
            teamId = 0;
        }
        else
        {
            teamId = teamId - 1;
        }
        UpdateTeamSlotUI(teamId);
        UpdateBottomBtnUI();

        // 更新底部 scrollView列表
        UpdateUnitList(0);

        //  默认显示unit
        UpdateState(STATE.UNIT);
    }
Пример #10
0
    public UnitData InitUnitData(DataUnit dataUnit)
    {
        if (dataUnit != null)
        {
            unlockUnits     = InstancePlayer.instance.model_User.unlockUnitsId;
            model_units     = InstancePlayer.instance.model_User.unlockUnits;
            model_Formation = InstancePlayer.instance.model_User.model_Formation;
            model_itemGroup = InstancePlayer.instance.model_User.model_itemGroup;
            UnitData unit = new UnitData();
            unit.id       = dataUnit.id;
            unit.quality  = dataUnit.quality;
            unit.unitData = dataUnit;
            if (unlockUnits.Contains(dataUnit.id))
            {
                unit.isUnLock = true;
            }
            else
            {
                unit.isUnLock = false;
            }
            unit.iconName   = UICommon.UNIT_SMALL_ICON_PATH + dataUnit.id;
            unit.iconBgName = UICommon.UNIT_ICON_BG + dataUnit.quality;
            switch ((int)dataUnit.quality)
            {
            case 0:
                unit.nameColor = UICommon.UNIT_NAME_COLOR_0;
                break;

            case 1:
                unit.nameColor = UICommon.UNIT_NAME_COLOR_1;
                break;

            case 2:
                unit.nameColor = UICommon.UNIT_NAME_COLOR_2;
                break;

            case 3:
                unit.nameColor = UICommon.UNIT_NAME_COLOR_3;
                break;

            case 4:
                unit.nameColor = UICommon.UNIT_NAME_COLOR_4;
                break;

            case 5:
                unit.nameColor = UICommon.UNIT_NAME_COLOR_5;
                break;

            default:
                unit.nameColor = UICommon.UNIT_NAME_COLOR_0;
                break;
            }

            Model_Unit model_unit;
            model_units.TryGetValue(dataUnit.id, out model_unit);
            if (model_unit != null && model_unit.onProduce > 0)
            {
                unit.isProduct = true;
            }
            else
            {
                unit.isProduct = false;
            }
            unit.isFormation = model_Formation.IsUnitOnDuty(dataUnit.id);
            unit.unitType    = dataUnit.bulletType;
            //isCanUnlock 是否能解锁
            Item item = model_itemGroup.QueryItem(dataUnit.chipId);
            if (item.num >= dataUnit.chipCount)
            {
                unit.isCanUnlock = true;
            }
            else
            {
                unit.isCanUnlock = false;
            }
            return(unit);
        }
        return(null);
    }
Пример #11
0
    public HeroData InitHeroData(DataHero data)
    {
        if (data != null)
        {
            DataHeroLeadership heroLeadershipData = heroGroupData.GetHeroLeadership(data.id);

            Model_HeroGroup model_heroGroup = InstancePlayer.instance.model_User.model_heroGroup;
            Model_ItemGroup model_itemGroup = InstancePlayer.instance.model_User.model_itemGroup;
            Model_Formation model_formation = InstancePlayer.instance.model_User.model_Formation;
            HeroData        heroData        = new HeroData();
            heroData.id       = data.id;
            heroData.heroType = (HeroType)data.type;
            heroData.quality  = heroLeadershipData.quality;
            heroData.IconName = UICommon.HERO_TEXTURE_ICON_PATH + data.id;
            heroData.skillId  = (int)heroLeadershipData.skill;
            heroData.data     = data;
            DataHeroUpgrade heroUpgradeData = heroGroupData.GetHeroUpgrade(data.id, 1);
            heroData.heroUpgradeData = heroUpgradeData;
            if (model_heroGroup.heroesMap.ContainsKey(data.id))
            {
                heroData.level       = model_heroGroup.GetCurrentLevel(data.id);
                heroData.recruitType = RecruitType.ALREADYRECRUIT;
                heroData.rank        = model_heroGroup.GetCurrentStage(data.id);
                heroData.rankName    = UICommon.HERO_RANK_ICON_PATH + model_heroGroup.GetCurrentStage(data.id);
                heroData.exp         = model_heroGroup.GetHero(data.id).exp;
            }
            else
            {
                heroData.level    = 1;
                heroData.rank     = 1;            //默认军衔为下士
                heroData.rankName = UICommon.HERO_RANK_ICON_PATH + "1";
                heroData.exp      = 0;

                //isCanUnlock 是否能解锁
                Item item = model_itemGroup.QueryItem(heroUpgradeData.itemId);
                if (item.num >= heroUpgradeData.itemCount)
                {
                    heroData.recruitType = RecruitType.CANRECRUIT;
                }
                else
                {
                    heroData.recruitType = RecruitType.UNABLERECRUIT;
                }
            }
            //英雄是否上阵
            for (int i = 1; i < 4; i++)
            {
                heroData.team = (TEAM)0;
                if (model_formation.IsTeamContaninHero(i, data.id))
                {
                    heroData.team = (TEAM)i;
                    break;
                }
            }

            switch ((int)heroLeadershipData.quality)
            {
            case 1:
                heroData.nameColor  = UICommon.UNIT_NAME_COLOR_0;
                heroData.IconBgName = UICommon.UNIT_ICON_BG + "0";
                break;

            case 2:
                heroData.nameColor  = UICommon.UNIT_NAME_COLOR_1;
                heroData.IconBgName = UICommon.UNIT_ICON_BG + "1";
                break;

            case 3:
                heroData.nameColor  = UICommon.UNIT_NAME_COLOR_2;
                heroData.IconBgName = UICommon.UNIT_ICON_BG + "2";
                break;

            case 4:
                heroData.nameColor  = UICommon.UNIT_NAME_COLOR_3;
                heroData.IconBgName = UICommon.UNIT_ICON_BG + "3";
                break;

            case 5:
                heroData.nameColor  = UICommon.UNIT_NAME_COLOR_4;
                heroData.IconBgName = UICommon.UNIT_ICON_BG + "4";
                break;

            default:
                heroData.nameColor  = UICommon.UNIT_NAME_COLOR_0;
                heroData.IconBgName = UICommon.UNIT_ICON_BG + "0";
                break;
            }

            return(heroData);
        }
        return(null);
    }