Example #1
0
 public void getRes(EncounterRes res)
 {
     if (res == null)
     {
         return;
     }
     if (res.type == eFinishType.NORMAL)
     {
         if (res.rewords.Count > 0)
         {
             List <string> l = GameStaticData.getInstance().getRandomComponents(3);
             //GameManager.getInstance ().getItemManager.initAndShow (l);
             GameManager.getInstance().getItemManager.initAndShow(res.rewords);
         }
         else
         {
             GameManager.getInstance().finishItemGet();
         }
         panelHide();
         //GameManager.getInstance ().showConfirm (panelHide);
     }
     else if (res.type == eFinishType.NEXT_LEVEK)
     {
         GameManager.getInstance().nextLevel();
     }
 }
Example #2
0
    void checkBattleRes()
    {
        if (!PlayerData.getInstance().isWaitingBattle || !PlayerData.getInstance().isFixedBattle)
        {
            return;
        }
        Debug.Log(PlayerData.getInstance().beforeEid);
        EncounterInfo  einfo   = GameStaticData.getInstance().getEncounterInfo(PlayerData.getInstance().beforeEid);
        EncounterStage es      = einfo.stages [PlayerData.getInstance().beforeStage];
        int            showIdx = -1;

        if (PlayerData.getInstance().battleWin)
        {
            showIdx = es.converts [0].nextStageIdx;
        }
        else
        {
            showIdx = es.converts [1].nextStageIdx;
        }
        if (showIdx != -1)
        {
            sbManager.initEncounter(einfo.eId, showIdx);
            sbManager.RequestFocus();
        }
        PlayerData.getInstance().isWaitingBattle = false;
    }
Example #3
0
    //game state

    // Use this for initialization
    void Start()
    {
        //DontDestroyOnLoad (this);
        //DontDestroyOnLoad (mainCamera.gameObject);

        GameStaticData.getInstance();
        initPlayer();
        initUI();
        resetStats();

        lockUI();

        gridManager.initGrid();

        _mask.visible = true;
        _mask.alpha   = 1;

        _mask.TweenFade(0, 1.5f).OnComplete(delegate() {
            _mask.visible = false;
            if (PlayerData.getInstance().guideStage == 0)
            {
                GuideManager.getInstance().showGuideMoveMark(gridManager.getToturialGridPos());
            }
            unlockUI();
            checkBattleRes();
        });

        Time.timeScale = 1;
    }
Example #4
0
    public override void setSkillCD(int readySkill)
    {
        SkillState s  = skills [readySkill];
        TowerSkill ts = GameStaticData.getInstance().getTowerSkillInfo(s.skillId);

        skillCoolDown[readySkill] = ts.cooldown[s.skillLevel - 1];
    }
Example #5
0
    public void initAndShow(List <EncounterReward> rewards)
    {
        List <string> items = new List <string> ();

        for (int i = 0; i < rewards.Count; i++)
        {
            if (rewards [i].rewardName == "fix_base_tower")
            {
                items.Add("t01");
                items.Add("t01");
                items.Add("t01");
            }
            else if (rewards [i].rewardName == "fix_base_equip")
            {
                items.Add("c01");
                items.Add("c01");
                items.Add("c01");
            }
            else
            {
                items = GameStaticData.getInstance().getRandomComponents(3);
            }
        }
        this.items = items;
        Show();
    }
Example #6
0
//	public bool checkOverlap(){
//		Collider2D[] cols = Physics2D.OverlapCircleAll (transform.position,r,1<<LayerMask.NameToLayer("enemy"));
//		if (cols.Length == 0) {
//			Debug.Log ("可建造");
//		}
//		return false;
//	}


    public void applyNormalAtk(GameLife hit, string damageEffect = "damaged01")
    {
        //hit.knock (atkTarget.transform.position - this.transform.position, 0.2f, 6f);

        List <Buff> attackEffect = new List <Buff> ();

        foreach (SkillState skill in skillComponent.skills)
        {
            if (skill == null || skill.skillId == null)
            {
                continue;
            }
            TowerSkill sinfo = GameStaticData.getInstance().getTowerSkillInfo(skill.skillId);
            if (sinfo.tsType == eTowerSkillType.PASSIVE && sinfo.checkPoint == ePassiveCheckPoint.ATK)
            {
                attackEffect.Add(new Buff(sinfo.x[skill.skillLevel - 1], 50, 1000));
            }
        }
        List <AtkInfo> atk = new List <AtkInfo> ();

        atk.Add(mainAtk);
        atk.AddRange(extraAtk);
        hit.DoDamage(atk, mingzhong, property, attackEffect);

        EffectManager.inst.EmitFollowingEffect(damageEffect, 500, hit);
    }
Example #7
0
    public void applyMagicAtk(GameLife hit, SkillState skill, string damageEffect = "damaged01")
    {
        TowerSkill sinfo = GameStaticData.getInstance().getTowerSkillInfo(skill.skillId);

        int lv     = skill.skillLevel;
        int damage = 0;

        switch (skill.skillId)
        {
        case "1004":
            damage = sinfo.x [lv - 1];
            //damageEffect = "";
            break;

        case "1005":
            damage = sinfo.x[lv - 1];
            break;

        case "1006":
            damage = sinfo.x[lv - 1];
            break;

        default:
            break;
        }


        hit.DoDamage(damage);

        EffectManager.inst.EmitFollowingEffect(damageEffect, 500, hit);
    }
Example #8
0
    public string getPossibleCombination(List <MemoItem> toCombine)
    {
        List <string> toCombineIdx = new List <string> ();

        foreach (MemoItem item in toCombine)
        {
            toCombineIdx.Add(item.memoId);
        }

        foreach (MemoCombinationRule rule in GameStaticData.getInstance().memoCombineInfo)
        {
            if (toCombine.Count != rule.toCombine.Count)
            {
                continue;
            }
            bool flag = true;
            foreach (string idx in rule.toCombine)
            {
                if (!toCombineIdx.Contains(idx))
                {
                    flag = false;
                    break;
                }
            }
            if (flag)
            {
                return(rule.resId);
            }
        }
        return("");
    }
Example #9
0
    public static GameLife createEnemy(string name, Vector2Int posInWorld, Transform target)
    {
        GameObject prefab    = Resources.Load("Prefabs/enemy_base") as GameObject;
        EnemyData  enemyData = GameStaticData.getInstance().getEnemyInfo(name);

        GameObject o = GameObject.Instantiate(prefab, target);

//		GameObject viewPrefab = Resources.Load ("Prefabs/enemy/"+name) as GameObject;
//		if (viewPrefab == null) {
//			viewPrefab = Resources.Load ("Prefabs/enemy/default") as GameObject;
//		}
//		o.GetComponentInChildren<SpriteRenderer> ().sprite = viewPrefab.GetComponent<SpriteRenderer>().sprite;
//		o.GetComponentInChildren<SpriteRenderer> ().color = viewPrefab.GetComponent<SpriteRenderer> ().color;

        AnimatorOverrideController animCtrl = Resources.Load("OverrideAnimCtrl/enemy/" + name) as AnimatorOverrideController;

        o.GetComponentInChildren <Animator>().runtimeAnimatorController = animCtrl;


        GameLife gl = o.GetComponent <GameLife> ();

        gl.initEnemy(enemyData);
        gl.posXInt = posInWorld.x;
        gl.posYInt = posInWorld.y;
        BattleManager.getInstance().registerEnemy(gl);
        return(gl);
    }
Example #10
0
    void checkCastBehaviour(int dTime)
    {
//		if (atkTarget != null && atkBhvTimer < atkPreTime) {
//			return;
//		}

        //攻击前摇时 不进行施法
        if (atkStage == eAtkStage.PRE_YAO)
        {
            return;
        }

        //效果结算
        if (castStage == eAtkStage.READY)
        {
            return;
        }

        castBhvTimer += dTime;

        bool isSkillEffect = false;

        if (castStage == eAtkStage.PRE_YAO && castBhvTimer > castPreTime)
        {
            castStage     = eAtkStage.POST_YAO;
            isSkillEffect = true;
        }
        else if (castStage == eAtkStage.POST_YAO && castBhvTimer > castPreTime + castPostTime)
        {
            castStage    = eAtkStage.READY;
            castBhvTimer = 0;
        }

        if (isSkillEffect)
        {
            SkillState skill = skillComponent.skills [castIdx];
            TowerSkill s     = GameStaticData.getInstance().getTowerSkillInfo(skill.skillId);
            if (s.tsType == eTowerSkillType.SELF_TARGET)
            {
                gainBuff();
            }
            else if (s.tsType == eTowerSkillType.ACTIVE)
            {
                if (s.targetType == eAtkType.RANGED_HOMING)
                {
                    genBullet(s.bulletStyle.bulletName, castTarget, skill, true, false);
                    castTarget = null;
                }
                else if (s.targetType == eAtkType.RANGED_INSTANT)
                {
                    applyNormalAtk(castTarget, s.bulletStyle.bulletName);
                    castTarget = null;
                }
            }
            else
            {
            }
        }
    }
Example #11
0
    // Use this for initialization
    void Start()
    {
        PlayerPrefs.DeleteAll();
        UIPackage.AddPackage("FairyGUI/UIMain");
        UIObjectFactory.SetPackageItemExtension("ui://UIMain/ClickShower", typeof(ShowClickMask));
        hasSave = PlayerPrefs.GetInt("hasSave", 0);

        _main_menu = GetComponent <UIPanel> ().ui;
        _main_menu.GetController("c0").SetSelectedPage("unsave");
        if (hasSave > 0)
        {
            _main_menu.GetController("c0").SetSelectedPage("save");
        }
        _main_menu.GetChild("loadGame").onClick.Add(loadGame);
        _main_menu.GetChild("newGame").onClick.Add(newGame);
        _main_menu.GetChild("options").onClick.Add(options);
        _main_menu.GetChild("quit").onClick.Add(quit);

        //_main_menu.onClick.Add (OnClick);
        _main_menu.onClick.Add(OnClickShow);
        effect = _main_menu.GetChild("effect").asMovieClip;
//		ShowClickMask _maskLayer = (ShowClickMask)UIPackage.CreateObject ("UIMain", "ClickShower").asCom;
//		_maskLayer.SetSize(GRoot.inst.width, GRoot.inst.height);
//		_maskLayer.AddRelation(GRoot.inst, RelationType.Size);
//
//
//
//		GRoot.inst.AddChild(_maskLayer);
//		_main_menu.AddChild (mask);
//		Debug.Log (_main_menu.numChildren);
//		Debug.Log (mask.position);

        _mask = _main_menu.GetChild("mask").asGraph;


        _newHeroPanel = _main_menu.GetChild("newHeroPanel").asCom;
        _info         = _newHeroPanel.GetChild("info").asTextField;
        _desp         = _newHeroPanel.GetChild("desp").asTextField;

        _start_game = _newHeroPanel.GetChild("startGame").asLoader;
        _start_game.onClick.Add(delegate(EventContext context) {
            PlayerData.getInstance().heroIdx = choosedHeroIdx;
            enterGame();
        });

        _hero_list = _newHeroPanel.GetChild("hero_list").asList;
        _hero_list.SetVirtualAndLoop();

        _hero_list.itemRenderer = RenderHeroes;
        _hero_list.numItems     = GameStaticData.getInstance().heroes.Count;
        _hero_list.scrollPane.onScroll.Add(doHeroScrollEffect);
        _hero_list.scrollPane.onScrollEnd.Add(changeHeroDetail);
        doHeroScrollEffect();
        changeHeroDetail();
        {
            _info.text = GameStaticData.getInstance().heroes[choosedHeroIdx].name;
            _desp.text = GameStaticData.getInstance().heroes [choosedHeroIdx].desp;
        }
    }
Example #12
0
 public void initBag()
 {
     for (int i = 0; i < 20; i++)
     {
         TowerComponent tc = GameStaticData.getInstance().getComponentInfo("c0" + (i % 6));
         bagComponents.Add(tc);
     }
 }
Example #13
0
    public void setInfo(Scar scar)
    {
        this.scar = scar;
        ScarStaticInfo sinfo = GameStaticData.getInstance().getScarInfo(scar.scarId);

        _num.text = scar.value + "";
        _icon.url = "image/Scar/" + sinfo.scarId;
    }
Example #14
0
    public void gainTowerBase(string tid)
    {
        TowerBase     tb = GameStaticData.getInstance().getTowerBase(tid);
        TowerTemplate tt = new TowerTemplate();

        tt.tbase = tb;
        ownedTowers.Add(tt);
    }
Example #15
0
 public static GameStaticData getInstance()
 {
     if (instance == null)
     {
         instance = new GameStaticData();
     }
     return(instance);
 }
Example #16
0
    protected override void calcuAuraSkill(SkillState skillState)
    {
        TowerSkill ts    = GameStaticData.getInstance().getTowerSkillInfo(skillState.skillId);
        int        level = skillState.skillLevel;

        int range = ts.x[level - 1];

        if (level - 1 < ts.y.Count)
        {
        }
        int y = ts.y [level - 1];
        int z = ts.z [level - 1];

        if (ts.debuff)
        {
            List <GameLife> enemyCopy = BattleManager.getInstance().getTmpEnemyList();
            Vector2         a         = new Vector2(owner.posXInt, owner.posYInt);
            foreach (GameLife e in enemyCopy)
            {
                Vector2 b = new Vector2(e.posXInt, e.posYInt);
                if ((a - b).magnitude < range)
                {
                    switch (ts.skillId)
                    {
                    case "1003":
                        EffectManager.inst.EmitFollowingEffect("burning", 300, e);
                        e.DoDamage(y);
                        break;

                    default:
                        break;
                    }
                }
            }
        }
        else
        {
            if (!localTimers.ContainsKey(ts.skillId))
            {
                localTimers [ts.skillId] = 0;
            }
            int timer = localTimers[ts.skillId];

            switch (ts.skillId)
            {
            case "1009":
                if (timer > 5000)
                {
                    localTimers[ts.skillId] = 0;
                    BattleManager.getInstance().player.gl.DoDamage(-5000);
                }
                break;

            default:
                break;
            }
        }
    }
Example #17
0
    void changeHeroDetail()
    {
        choosedHeroIdx = (_hero_list.GetFirstChildInView() + 1) % _hero_list.numItems;
        _info.text     = GameStaticData.getInstance().heroes [choosedHeroIdx].name;
        _desp.text     = GameStaticData.getInstance().heroes [choosedHeroIdx].desp;

        _hero_list.ClearSelection();
        _hero_list.GetChildAt(1).asButton.selected = true;;
    }
Example #18
0
    public void setInfo(SkillState skill)
    {
        this.skill = skill;
        TowerSkill sinfo = GameStaticData.getInstance().getTowerSkillInfo(skill.skillId);

        _desp.text   = sinfo.skillDesp;
        _lv_num.text = skill.skillLevel + "";
        _icon.url    = GameConstant.TOWER_SKILL_ICON_PATH + skill.skillId;
    }
Example #19
0
    public void initShop()
    {
        componentChoice = -1;
        componentsToSell.Clear();

        componentsToSell.Add(GameStaticData.getInstance().getComponentInfo("c02"));
        componentsToSell.Add(GameStaticData.getInstance().getComponentInfo("c01"));
        componentsToSell.Add(GameStaticData.getInstance().getComponentInfo("c03"));
    }
Example #20
0
    protected override bool isPermanentSkill(string skillId)
    {
        TowerSkill ts = GameStaticData.getInstance().getTowerSkillInfo(skillId);

        if (ts.tsType == eTowerSkillType.AURA)
        {
            return(true);
        }
        return(false);
    }
Example #21
0
    protected override bool isPassiveSkill(string skillId)
    {
        TowerSkill ts = GameStaticData.getInstance().getTowerSkillInfo(skillId);

        if (ts.tsType == eTowerSkillType.PASSIVE)
        {
            return(true);
        }
        return(false);
    }
Example #22
0
    // ######## Public methods #########

    public void Initialize()
    {
        // Get children
        GameObject game = this.transform.Find("Game").gameObject;

        GameSD = game.GetComponent <GameStaticData>();

        // Initialize children
        GameSD.Initialize();
    }
Example #23
0
        public void Setup(string url, string text)
        {
            var spr = GameStaticData.GetSprite(url);

            _image.sprite = spr;

            _text.text = text;

            Show(true);
        }
Example #24
0
 public void initMemoState()
 {
     foreach (var kv in GameStaticData.getInstance().memoInfo)
     {
         if (kv.Key != "default" && int.Parse(kv.Key) < 10)
         {
             memoState [kv.Key] = 1;
         }
     }
 }
Example #25
0
    public void updateDetail(List <MemoItem> selected)
    {
        string s = "";

        foreach (MemoItem item in selected)
        {
            string d = GameStaticData.getInstance().memoInfo[item.memoId].desp;
            s += d + "\n";
        }
        _combDetail.text = s;
    }
Example #26
0
 // Use this for initialization
 void Start()
 {
     if (GameObject.Find("LoadBLE"))
     {
         gameStaticData = GameObject.Find("LoadBLE").GetComponent <GameStaticData> ();
     }
             #if UNITY_EDITOR
     this.gameObject.AddComponent <LineRenderer> ();
     line = GetComponent <LineRenderer>();
             #endif
 }
Example #27
0
        public override void Setup(string question, string[] answerImage, Action <int> onActionQuestionButton)
        {
            _onClickButton = onActionQuestionButton;

            _questionText.text = question;

            for (int i = 0; i < answerImage.Length; i++)
            {
                var spr = GameStaticData.GetSprite(answerImage[i]);
                _answerButtons[i].Setup(spr);
            }
        }
Example #28
0
    public void enterNextLevel()
    {
        LevelEntry entry       = GameStaticData.getInstance().getLevelInfo(nowLevelId);
        string     nextLevelId = entry.NextLevel;

        nowLevelId = nextLevelId;
        if (nextLevelId == "end")
        {
            return;
        }
        generateDungeon(nextLevelId);
    }
        public override void Setup(string url, string[] buttonText, Action <int> onActionQuestionButton)
        {
            _onClickButton = onActionQuestionButton;

            var spr = GameStaticData.GetSprite(url);

            _image.Setup(spr);

            for (int i = 0; i < _gameButton.Length; i++)
            {
                _gameButton[i].Setup(buttonText[i]);
            }
        }
Example #30
0
 public void initEncounter(string eid = null, int stageIdx = 0)
 {
     if (eid == null)
     {
         encounter = GameStaticData.getInstance().getEncounterInfo("empty");
     }
     else
     {
         encounter = GameStaticData.getInstance().getEncounterInfo(eid);
     }
     //通过静态信息得到文字表
     this.stageIndex = stageIdx;
     this.Show();
 }