Example #1
0
    public void readyForBattle()
    {
        _curRound   = -1;
        _actionTime = 0;
        _isWin      = false;

        _star  = 0;
        _score = 0;

        _gold  = 0;
        _paper = 0;

        SolaEngine engine = SolaEngine.getInstance();
        PartnerMgr pMgr   = (PartnerMgr)engine.getMgr(typeof(PartnerMgr));

        _partners = new Dictionary <int, BattleHeroModel> ();
        Dictionary <int, HeroModel> partner = pMgr.getPartners();

        foreach (int pos in partner.Keys)
        {
            HeroModel       model   = partner[pos];
            BattleHeroModel bhModel = new BattleHeroModel();
            bhModel.setModel(model, false, new Vector3(0, 0, 0));
            bhModel.formatModel();

            _partners.Add(pos, bhModel);
            bhModel.HERO_DIED += _onPartnerDeath;
        }

        MissionModel missionModel = _missionModel;

        _curBattleInfos = missionModel.getBattleInfos();
    }
Example #2
0
    private void _updateHeroView()
    {
        foreach (Image image in heroImgs)
        {
            image.gameObject.SetActive(false);
        }

        PartnerMgr pMgr  = (PartnerMgr)_engine.getMgr(typeof(PartnerMgr));
        int        index = 0;

        Dictionary <int, HeroModel> partners = pMgr.getPartners();
        int heroIndex = 0;

        foreach (HeroModel model in partners.Values)
        {
            if (heroIndex > 2)
            {
                break;
            }

            heroIndex++;

            string img        = model.getBodyImg();
            Sprite bodySprite = Resources.Load <Sprite> (img);

            Image image = heroImgs [index];
            image.gameObject.SetActive(true);
            image.sprite = bodySprite;

            if (index == 0)
            {
                int start = model.getStart();
                int size  = heroStars.Length;

                for (int i = 0; i < size; i++)
                {
                    GameObject gameObject = heroStars [i].gameObject;
                    gameObject.SetActive(i < start);
                }

                heroName.text = model.getName();

                int atk = model.getAtk();
                int hp  = model.getHp();
                int spd = model.getSpd();

                heroAtkSlider.value = atk;
                heroHpSlider.value  = hp;
                heroSpdSlider.value = spd;

                heroAtkText.text  = atk.ToString();
                heroHpText.text   = hp.ToString();
                heroSpdkText.text = spd.ToString();
            }

            index++;
        }
    }
Example #3
0
    private void _onSelectedPartner(int partnerPos)
    {
        ToBattleSelectItem selectedItem = _selectedHeroItem;

        if (selectedItem == null)
        {
            return;
        }

        SolaEngine engine = SolaEngine.getInstance();
        PartnerMgr pMgr   = (PartnerMgr)engine.getMgr(typeof(PartnerMgr));

        pMgr.setPartner(partnerPos, selectedItem.getModel());

        selectedItem.setSelected(false);
        _selectedHeroItem = null;
    }
Example #4
0
    private void _onSelectedHero(ToBattleSelectItem selectedItem)
    {
        if (_selectedHeroItem != null)
        {
            _selectedHeroItem.setSelected(false);
        }

        _selectedHeroItem = selectedItem;

        HeroModel heroModel = selectedItem.getModel();

        if (heroModel.isToBattle() == true)
        {
            SolaEngine engine = SolaEngine.getInstance();
            PartnerMgr pMgr   = (PartnerMgr)engine.getMgr(typeof(PartnerMgr));

            pMgr.removePartner(heroModel);
        }

        selectedItem.setSelected(true);
    }
Example #5
0
    private void _updatePartners()
    {
        SolaEngine engine = SolaEngine.getInstance();
        PartnerMgr pMgr   = (PartnerMgr)engine.getMgr(typeof(PartnerMgr));

        Dictionary <int, HeroModel> partners = pMgr.getPartners();

        for (int i = 0; i < partnerItems.Length; i++)
        {
            HeroModel partner = null;
            if (partners.ContainsKey(i))
            {
                partner = partners[i];
            }

            ToBattlePartnerItem partnerItem = partnerItems[i];
            partnerItem.setModel(partner);
            partnerItem.setPos(i);

            partnerItem.onClicked += _onSelectedPartner;
        }
    }
Example #6
0
    public override bool loadData(JsonObject data)
    {
        string     MGR_NAME = this.GetType().Name;
        JsonObject heroInfos;

        if (!data.ContainsKey(MGR_NAME))
        {
            _heroData       = new JsonObject();
            data [MGR_NAME] = _heroData;

            _heroIndex = 1;
            heroInfos  = new JsonObject();
        }
        else
        {
            _heroData = (JsonObject)data [MGR_NAME];

            _heroIndex = Convert.ToInt32(_heroData [HeroData.HERO_INDEX]);
            heroInfos  = (JsonObject)_heroData [HeroData.HERO_INFOS];
        }

        foreach (JsonObject savaData in heroInfos.Values)
        {
            int id       = Convert.ToInt32(savaData [HeroData.Info.ID]);
            int configId = Convert.ToInt32(savaData [HeroData.Info.CONFIG_ID]);
            int level    = Convert.ToInt32(savaData [HeroData.Info.LEVEL]);
            int exp      = Convert.ToInt32(savaData [HeroData.Info.EXP]);

            HeroModel model = createHero(id, configId, level, exp);
            addHero(model);
        }

        PartnerMgr pMgr = (PartnerMgr)_engine.getMgr(typeof(PartnerMgr));

        pMgr.loadDataAfterHeroMgr(data, this);

        return(true);
    }
Example #7
0
    public void sign(string roleId)
    {
        if (_roleId != "")
        {
            return;
        }

        CreateRoleConfig createRoleCfg = _createRoleCfg;

        _roleId    = roleId;
        _roleLevel = 1;
        _roleExp   = 0;

        _gold  = Convert.ToInt32(createRoleCfg.gold);
        _paper = Convert.ToInt32(createRoleCfg.paper);


        int configId = Convert.ToInt32(createRoleCfg.heroId);
        int level    = Convert.ToInt32(createRoleCfg.heroLevel);

        HeroMgr   hMgr      = (HeroMgr)_engine.getMgr(typeof(HeroMgr));
        HeroModel heroModel = hMgr.createHero(configId, level, 0);

        hMgr.addHero(heroModel);
        //Fix me:Test Data.
        for (int i = 1; i <= 5; i++)
        {
            HeroModel hero = hMgr.createHero(i, 5, 5);
            hMgr.addHero(hero);
        }
        hMgr.saveData();

        PartnerMgr pMgr = (PartnerMgr)_engine.getMgr(typeof(PartnerMgr));

        pMgr.setPartner(0, heroModel);
        saveData();
    }