Exemplo n.º 1
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;
    }
Exemplo n.º 2
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();
    }
Exemplo n.º 3
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];
    }
Exemplo n.º 4
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;
    }
Exemplo n.º 5
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);
    }
Exemplo n.º 6
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);
    }
Exemplo n.º 7
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("");
    }
Exemplo n.º 8
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();
     }
 }
Exemplo n.º 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);
    }
Exemplo n.º 10
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;
        }
    }
Exemplo n.º 11
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
            {
            }
        }
    }
Exemplo n.º 12
0
 public void initBag()
 {
     for (int i = 0; i < 20; i++)
     {
         TowerComponent tc = GameStaticData.getInstance().getComponentInfo("c0" + (i % 6));
         bagComponents.Add(tc);
     }
 }
Exemplo n.º 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;
    }
Exemplo n.º 14
0
    public void gainTowerBase(string tid)
    {
        TowerBase     tb = GameStaticData.getInstance().getTowerBase(tid);
        TowerTemplate tt = new TowerTemplate();

        tt.tbase = tb;
        ownedTowers.Add(tt);
    }
Exemplo n.º 15
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;
            }
        }
    }
Exemplo n.º 16
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"));
    }
Exemplo n.º 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;;
    }
Exemplo n.º 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;
    }
Exemplo n.º 19
0
    protected override bool isPermanentSkill(string skillId)
    {
        TowerSkill ts = GameStaticData.getInstance().getTowerSkillInfo(skillId);

        if (ts.tsType == eTowerSkillType.AURA)
        {
            return(true);
        }
        return(false);
    }
Exemplo n.º 20
0
    protected override bool isPassiveSkill(string skillId)
    {
        TowerSkill ts = GameStaticData.getInstance().getTowerSkillInfo(skillId);

        if (ts.tsType == eTowerSkillType.PASSIVE)
        {
            return(true);
        }
        return(false);
    }
Exemplo n.º 21
0
 public void initMemoState()
 {
     foreach (var kv in GameStaticData.getInstance().memoInfo)
     {
         if (kv.Key != "default" && int.Parse(kv.Key) < 10)
         {
             memoState [kv.Key] = 1;
         }
     }
 }
Exemplo n.º 22
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;
    }
Exemplo n.º 23
0
    public void enterNextLevel()
    {
        LevelEntry entry       = GameStaticData.getInstance().getLevelInfo(nowLevelId);
        string     nextLevelId = entry.NextLevel;

        nowLevelId = nextLevelId;
        if (nextLevelId == "end")
        {
            return;
        }
        generateDungeon(nextLevelId);
    }
Exemplo n.º 24
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();
 }
Exemplo n.º 25
0
    public void changeEncounterDetail(int index)
    {
        if (index < 0 || index > grids.Length)
        {
            return;
        }
        EncounterState encounterState = PlayerData.getInstance().grids [index / GRID_WIDTH] [index % GRID_WIDTH];
        string         eid            = encounterState.eid;
        EncounterInfo  einfo          = new EncounterInfo();

        if (eid != "")
        {
            einfo = GameStaticData.getInstance().getEncounterInfo(eid);
        }
        GameManager.getInstance().showDetailPanel(einfo.desp);
        //detailText.text = eList [index].eid + "号遭遇";
    }
Exemplo n.º 26
0
 public void setInfo(EnemyCombo info)
 {
     this.info = info;
     for (int i = 0; i < 3; i++)
     {
         if (i >= info.enemyId.Count)
         {
             break;
         }
         string eid   = info.enemyId [i];
         int    num   = info.enemyNum [i];
         string ename = GameStaticData.getInstance().getEnemyInfo(eid).enemyName;
         numberTF [i].text    = "x" + num;
         nameTF [i].text      = ename;
         numberTF [i].visible = true;
         nameTF [i].visible   = true;
     }
     //this.GetController ("c0").;
 }
Exemplo n.º 27
0
    public void updateView()
    {
        _hp.text    = PlayerData.getInstance().hp + "";
        _san.text   = PlayerData.getInstance().san + "";
        _money.text = PlayerData.getInstance().money + "";

        UsableHeroInfo heroinfo = GameStaticData.getInstance().heroes [PlayerData.getInstance().heroIdx];

        for (int i = 0; i < heroinfo.talent.Length; i++)
        {
            int ii = i;
            _talents [i].onClick.Add(delegate() {
                if (heroinfo.talent [ii] == null)
                {
                    GameManager.getInstance().showDetailAmplifier("无天赋", null);
                }
                else
                {
                    GameManager.getInstance().showDetailAmplifier("talent", heroinfo.talent [ii]);
                }
            });
        }
//		for (int i = 0; i < _talents.Length; i++) {
//			_talents [i].onTouchBegin.Add (delegate() {
//				UsableHeroInfo heroinfo = GameStaticData.getInstance().heroes[PlayerData.getInstance().heroIdx]
//				GameManager.getInstance().showDetailAmplifier("减少生命上限");
//			});
//		}
        l0.RemoveChildrenToPool();
        l1.RemoveChildrenToPool();

        foreach (Potion p in PlayerData.getInstance().potions)
        {
            PotionSmall item = (PotionSmall)l0.AddItemFromPool();
            item.setInfo(p);
        }
        foreach (Scar scar in PlayerData.getInstance().scars)
        {
            ScarSmallIcon item = (ScarSmallIcon)l1.AddItemFromPool();
            item.setInfo(scar);
        }
    }
Exemplo n.º 28
0
 public void init(string itemId)
 {
     if (itemId.StartsWith("t"))
     {
         TowerBase tb = GameStaticData.getInstance().getTowerBase(itemId);
         _icon.url = "";
         _txt.text = tb.tname + '\n' + tb.tdesp;
     }
     else if (itemId.StartsWith("c"))
     {
         TowerComponent tc = GameStaticData.getInstance().getComponentInfo(itemId);
         _icon.url = "";
         _txt.text = tc.cname + '\n' + tc.cdesp;
     }
     else
     {
         Debug.Log(itemId);
         _txt.text = "要水货伤痕p";
     }
 }
Exemplo n.º 29
0
    public void conbineAndGen()
    {
        if (isChangingView)
        {
            return;
        }
        string res = GameStaticData.getInstance().getPossibleCombination(memoWindow.selected);

        if (res == "")
        {
            Debug.Log("invalid");
        }
        else
        {
            Debug.Log("valud, res:" + res);
            memoWindow.fadeUsedMemo();
            memoWindow.addMemo("18", true);
            _combDetail.text = "";
            this.touchable   = false;
        }
    }
Exemplo n.º 30
0
    public void addMemo(string memoIdx, bool withEffect = false)
    {
        MemoItem button = (MemoItem)UIPackage.CreateObject("UIMain", "MemoItem").asCom;

        this.AddChild(button);
        MemoInfo info = null;

        GameStaticData.getInstance().memoInfo.TryGetValue(memoIdx, out info);
        if (info == null)
        {
            info = GameStaticData.getInstance().memoInfo["default"];
        }
        button.memoId = info.memoId;
        allShownMemo.Add(button);
        button.SetXY(info.fixedX, info.fixedY);
        button.setDesp(info.desp);
        button.onChanged.Add(delegate() {
            if (button.selected)
            {
                if (selected.Count > MAX_COMBINATION_COUNT)
                {
                    return;
                }
                selected.Add(button);
            }
            else
            {
                selected.Remove(button);
            }
            ((MemoPanel)(this.parent.asCom)).updateDetail(selected);
        });
        if (withEffect)
        {
            button.alpha = 0;
            button.TweenFade(1, 1f).OnComplete(delegate() {
                ((MemoPanel)(this.parent.asCom)).combineCallback();
            });
        }
    }