Esempio n. 1
0
        private void doClone(MonstorSpr m)
        {
            pausebg = true;
            if (currClone != null)
            {
                Destroy(currClone);
                Debug.Log("销毁生成的");
            }
            Debug.Log("生成clone  " + Time.time);
            GameObject go = m.go;

            if (currIndex == 0)
            {
                first = m.data;
                //GameEntry.Event.Fire(this, new ChooseMonstorEvent(first));
                this.showFirstComList();
            }
            else
            {
                second = m.data;
            }
            //音效
            GameEntry.Sound.PlaySound(1);
            //特效
            doEffect();
            currClone = Instantiate(go) as GameObject;
            currClone.transform.parent        = monsSpr.transform;
            currClone.transform.localPosition = go.transform.localPosition;
            m.SetActive(false);
        }
Esempio n. 2
0
        public void SetData(DRMonster d)
        {
            this.data = d;
            this.used = true;
            leftTime  = 0;
            monBase.SetActive(true);

            monBase.transform.localEulerAngles = new Vector3(0, 0, -90);
            w        = -0.4f;
            moveFlag = false;
            //Debug.Log("显示");
            go.transform.Find("Text").gameObject.GetComponent <Text>().text = data.BName;
            string imgUrl = AssetUtility.GetUIImageAssets(data.asset);

            GameEntry.Resource.LoadAsset(imgUrl, new LoadAssetCallbacks((assetName, asset, duration, userData) =>
            {
                //Log.Info("Load font '{0}' OK.{1}", imgUrl,asset);
                //Image img = go.GetComponent<Image>();
                //创建Sprite
                Texture2D texture = (Texture2D)asset;
                Sprite sprite     = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));
                img.sprite        = sprite;
            },

                                                                        (assetName, status, errorMessage, userData) =>
            {
                Log.Error("Can not load font '{0}' from '{1}' with error message '{2}'.", data.asset, assetName, errorMessage);
            }));
        }
Esempio n. 3
0
        //结果判断
        private void doEndStory(DRMonster dMon)
        {
            Debug.Log("游戏结束 完成结局");
            GameEntry.Sound.PlaySound(8);
            GameObject endGo = this.gameObject.transform.Find("endTxt").gameObject;

            endGo.GetComponent <Text>().text = getEndStory(dMon.endValue.ToString());

            endingSprImg.SetActive(true);

            showStartButton();
            m_start = false;
        }
Esempio n. 4
0
        //生成怪物
        public void GenerateMonstor()
        {
            int       l       = genMonstors.Count;
            DRMonster monData = generateSingle();

            if (l < maxNum)
            {
            }
            else
            {
                //删除第一个
                genMonstors.RemoveAt(0);
            }
            genMonstors.Add(monData);

            //显示
            GameEntry.Event.Fire(this, new MonstorCountChange(genMonstors));
        }
Esempio n. 5
0
        private void setMonInfo(GameObject go, DRMonster data)
        {
            GameObject ts    = go.transform.Find("Text").gameObject;
            GameObject img   = go.transform.Find("Image").gameObject;
            string     asset = "wrong";

            if (data != null)
            {
                string info = data.BName;
                ts.GetComponent <Text>().text = info;
                asset = data.asset;
            }
            else
            {
                ts.GetComponent <Text>().text = "失败";
            }
            LoadAndSetImage(asset, img.GetComponent <Image>());
        }
Esempio n. 6
0
 private void clearShow(bool des = false)
 {
     if (des)
     {
         //音效
         GameEntry.Sound.PlaySound(5);
         showCompose(null, first, second);
         setHp(failSub);
     }
     first  = null;
     second = null;
     firstGO.gameObject.SetActive(false);
     secondGO.gameObject.SetActive(false);
     lImg.SetActive(false);
     rImg.SetActive(false);
     //finGO.gameObject.SetActive(false);
     tableView.gameObject.SetActive(false);
 }
Esempio n. 7
0
        private static void ShowBiology(this EntityComponent entityComponent, Type logicType, string entityGroup, EntityData data)
        {
            if (data == null)
            {
                Log.Warning("Data is invalid.");
                return;
            }

            IDataTable <DRMonster> dtEntity = GameEntry.DataTable.GetDataTable <DRMonster>();
            DRMonster drEntity = dtEntity.GetDataRow(data.Id);

            if (drEntity == null)
            {
                Log.Warning("Can not load entity id '{0}' from data table.", data.TypeId.ToString());
                return;
            }

            entityComponent.ShowEntity(data.Id, logicType, AssetUtility.GetBiology("MonstorPrefab"), entityGroup, data);
        }
Esempio n. 8
0
        public void InitConfig()
        {
            //获得第一类怪物
            IDataTable <DRMonster> dtMonstor = GameEntry.DataTable.GetDataTable <DRMonster>();

            DRMonster[] list = dtMonstor.GetAllDataRows();
            currMonstors = new List <DRMonster>();
            genMonstors  = new List <DRMonster>();
            int lent = list.Length;

            for (int i = 0; i < lent; i++)
            {
                DRMonster dr = list[i];
                if (dr.IsFirst())
                {
                    currMonstors.Add(dr);
                }
            }
        }
Esempio n. 9
0
        protected internal override void OnOpen(object userData)
#endif
        {
            base.OnOpen(userData);
            InitConfig();
            upFlag    = true;
            lastTime  = 0;
            currIndex = 0;
            tickTime  = 0;
            curPos    = ufoMpoveImg.transform.localPosition;

            int ll = goMons.Length;

            monPool      = new MonstorSpr[ll];
            transAndPoss = new TransformAndPos[ll];
            for (int i = 0; i < ll; i++)
            {
                GameObject go = goMons[i];
                monPool[i]      = new MonstorSpr(go);
                transAndPoss[i] = new TransformAndPos(go.transform.localPosition, go.transform.localScale);
            }

            tableView.InitTableView(null, 0, updateItem);

            startBtn = Buttons.transform.Find("Start").gameObject;
            pauseBtn = Buttons.transform.Find("pause").gameObject;
            quitBtn  = Buttons.transform.Find("quit").gameObject;

            //monsSpr = this.transform.Find("monsSpr").gameObject;
            defaultMon       = new DRMonster();
            defaultMon.asset = "none";
            defaultMon.BName = "未知";

            sld.maxValue = maxHp;
            sld.value    = maxHp;
            lastHp       = curHp;

            firTrans = firstGO.transform.localPosition;
            secTrans = secondGO.transform.localPosition;
            this.showStartButton();
        }
Esempio n. 10
0
        //添加到怪物->生成 表
        private void addToGenList(DRMonster data, DRMonster fir, DRMonster sec)
        {
            if (data.Id != 100 && data.Id != 200)
            {
                currMonstors.Add(data);
                if (myDictionary.ContainsKey(fir.Id))
                {
                    myDictionary[fir.Id].AddCompose(new SimpleName(sec, data));
                }
                else
                {
                    ComposedMon cmon = new ComposedMon();
                    myDictionary.Add(fir.Id, cmon);
                    cmon.AddCompose(new SimpleName(sec, data));
                }
                if (myDictionary.ContainsKey(sec.Id))
                {
                    myDictionary[fir.Id].AddCompose(new SimpleName(sec, data));
                }
                else
                {
                    ComposedMon cmon = new ComposedMon();
                    myDictionary.Add(sec.Id, cmon);
                    cmon.AddCompose(new SimpleName(fir, data));
                }

                //完全合成之后不再显示这怪物
                if ((myDictionary[fir.Id].currMonstors.Count >= DRSynthesis.allDictionary[fir.Id].Count()))
                {
                    delMonWithId(fir);
                }
                if (fir.Id != sec.Id)
                {
                    if ((myDictionary[sec.Id].currMonstors.Count >= DRSynthesis.allDictionary[sec.Id].Count()))
                    {
                        delMonWithId(sec);
                    }
                }
            }
        }
Esempio n. 11
0
        private void showCompose(DRMonster data, DRMonster fir, DRMonster sec)
        {
            string asset = "wrong";
            string BName = "失败";

            if (data != null)
            {
                asset = data.asset;
                BName = data.BName;
            }

            string imgUrl = AssetUtility.GetUIImageAssets(asset);

            GameEntry.Resource.LoadAsset(imgUrl, new LoadAssetCallbacks((assetName, assete, duration, userData) =>
            {
                //Log.Info("Load font '{0}' OK.{1}", imgUrl,asset);
                Image img = finGO.GetComponent <Image>();
                //创建Sprite
                Texture2D texture = (Texture2D)assete;
                Sprite sprite     = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));
                img.sprite        = sprite;

                finGO.transform.Find("Text").gameObject.GetComponent <Text>().text = BName;

                finGO.SetActive(true);
                Invoke("hideFinGo", 1.2f);


                clearShow();
            },

                                                                        (assetName, status, errorMessage, userData) =>
            {
                Log.Error("Can not load font '{0}' from '{1}' with error message '{2}'.", asset, assetName, errorMessage);
            }));
        }
Esempio n. 12
0
 public ChooseMonstorEvent(DRMonster mons)
 {
     mData = mons;
 }
Esempio n. 13
0
 private void delMonWithId(DRMonster data)
 {
     allGenWithDelet.Add(data.Id, true);
     Debug.Log("删除" + data.Id);
     currMonstors.Remove(data);
 }
Esempio n. 14
0
        private void doCompose()
        {
            pausebg = false;
            if (first == null || second == null)
            {
                Debug.LogError(string.Format("存在空 {0}  {1}", first == null, second == null));
                return;
            }
            Debug.Log("开始合成 .. " + first.Id + "   " + second.Id);

            string cid = first.Id + "_" + second.Id;
            IDataTable <DRSynthesis> dtScene = GameEntry.DataTable.GetDataTable <DRSynthesis>();

            DRSynthesis[] list    = dtScene.GetAllDataRows();
            DRSynthesis   drScene = null;
            int           lent    = list.Length;

            for (int i = 0; i < lent; i++)
            {
                DRSynthesis dr = list[i];
                if (dr.Id_Id.Equals(cid))
                {
                    drScene = dr;
                    break;
                }
            }


            if (drScene != null)
            {
                drScene.CanCompose();
                string tid = drScene.cId;
                Debug.Log("合成id" + drScene.cId);
                if (tid != null && tid != "")
                {
                    //查找表
                    IDataTable <DRMonster> dtmon = GameEntry.DataTable.GetDataTable <DRMonster>();
                    DRMonster drmon = dtmon.GetDataRow(int.Parse(tid));
                    if (drmon != null)
                    {
                        DRMonster dmon = currMonstors.Find((DRMonster obj) => drmon.Id == obj.Id);
                        if (dmon == null)
                        {
                            Debug.Log("添加新物种" + drmon.Id + "  " + drmon.asset);

                            addToGenList(drmon, first, second);
                            if (drmon.Id != 200 && drmon.Id != 100)
                            {
                                setHp(sucAddOnce);
                            }
                            else if (drmon.Id == 200)
                            {
                                //setHp(failSub);
                            }
                        }
                        else
                        {
                            Debug.Log("已有物种" + drmon.Id + "  " + drmon.asset);
                            if (drmon.Id != 200 && drmon.Id != 100)
                            {
                                setHp(sucAdd);
                            }
                            else if (drmon.Id == 200)
                            {
                                //setHp(failSub);
                            }
                        }

                        //显示合成
                        //音效
                        GameEntry.Sound.PlaySound(drmon.soundId);

                        showCompose(drmon, first, second);
                        //显示提示
                        tipTxt.text = drmon.intro;
                        eimg.SetActive(true);
                        eimg.transform.Find("infoTxt").gameObject.GetComponent <Text>().text = drmon.intro;
                        Invoke("hideTxt", 0.8f);
                        //drmon.endValue = 1000;
                        if (drmon.endValue >= 1000)
                        {
                            //结束
                            m_start = false;
                            doEndStory(drmon);
                        }
                    }
                    else
                    {
                        //todo  配置
                        //是不是平局
                        //if (tid.Equals("100"))
                        //{
                        //    //音效
                        //    GameEntry.Sound.PlaySound(5);
                        //    clearShow(false,"ashes","灰烬");
                        //}else if (tid.Equals("200"))
                        //{
                        //    clearShow(true,"wrong","残渣");
                        //}else
                        //{
                        clearShow(true);
                        //}
                    }
                }
                else
                {
                    clearShow(true);
                }
            }
            else
            {
                clearShow(true);
            }
        }
Esempio n. 15
0
 public bool hasAdd(DRMonster d)
 {
     return(d.Id == comMon.Id);
 }
Esempio n. 16
0
 public SimpleName(DRMonster c, DRMonster t)
 {
     this.comMon = c;
     this.toMon  = t;
 }
Esempio n. 17
0
        private MonstorSpr generateSingle()
        {
            int       num      = currMonstors.Count;
            DRMonster mon      = null;
            int       tryCount = 0;

            //是否有选中
            if (first != null && myDictionary.ContainsKey(first.Id))
            {
                //增加可合成几率
                //可合成的材料
                int sNum   = myDictionary[first.Id].currMonstors.Count;
                int allNum = sNum + num;
                int t      = Mathf.FloorToInt(Random.Range(0, allNum));
                int r      = (int)t;
                //默认逻辑
                while (tryCount < 9)
                {
                    if (r >= num)
                    {
                        mon = myDictionary[first.Id].currMonstors[r - num].comMon;
                    }
                    else
                    {
                        mon = currMonstors[r];
                        //Debug.Log("使用monstor" + (mon ==null));
                    }
                    Debug.Log(num + " 随机数生成 " + r);
                    if (mon != null && mon.Id != lastGenId)
                    {
                        break;
                    }
                    //伪随机
                    r++;
                    r = r > allNum - 1 ? 0 : r;
                    tryCount++;
                }
            }
            else
            {
                int t = Mathf.FloorToInt(Random.Range(0, num));
                int r = (int)t;
                //默认逻辑
                while (tryCount < 9)
                {
                    Debug.Log(num + " 随机数 " + r);
                    mon = currMonstors[r];
                    //Debug.Log("使用monstor" + (mon == null));
                    if (mon != null && mon.Id != lastGenId)
                    {
                        break;
                    }
                    //伪随机
                    r++;
                    r = r > num - 1 ? 0 : r;
                    tryCount++;
                }
            }
            lastGenId = mon.Id;


            for (int i = 0; i < goMons.Length; i++)
            {
                if (monPool[i].used == false)
                {
                    monPool[i].SetData(mon);
                    return(monPool[i]);
                }
            }
            return(null);
        }