Пример #1
0
    public void Clear()
    {
        Fish f = transform.parent.GetComponent <Fish>();

        f.Clear();
        //Destroy(transform.parent.gameObject);
    }
Пример #2
0
        public void Refresh()
        {
            AllFish.Clear();
            Fish.Clear();
            GetFish();

            SelectedFish = null;
        }
Пример #3
0
        void OnTriggerEnter(Collider other)
        {
            Fish fishCollide = other.GetComponent <Fish>();

            //不包含鱼组件,排除
            if (fishCollide == null)
            {
                return;
            }

            //目标鱼已死亡,排除
            if (!fishCollide.Attackable)
            {
                return;
            }

            //不在可吃鱼列表中,排除
            if (!mFishCanEatDict.ContainsKey(fishCollide.TypeIndex))
            {
                return;
            }

            //累计分大于最大限制,排除
            if (mOddsAccumul >= OddsAccumulMax)
            {
                return;
            }

            //本体已死亡
            if (mFish == null || !mFish.Attackable)
            {
                return;
            }

            if (EvtBeforeEatFish != null)
            {
                EvtBeforeEatFish(mFish, fishCollide);
            }

            //加分
            mOddsAccumul += fishCollide.Odds;

            mFish.Odds = mOddsAccumul;

            //清除目标鱼
            fishCollide.Clear();

            //更新分数牌
            Text_Odds.text = mOddsAccumul.ToString();
            Text_Odds.Commit();


            //YxDebug.Log("Fish =" + fishCollide.name + "   Odds = " + fishCollide.Odds + " totalOdds = " + mOddsAccumul);
        }
Пример #4
0
    // Use this for initialization
    IEnumerator Start()
    {
        //Ԥ������ͼƬ
        Fish[] prefabFishAll  = GameMain.Singleton.FishGenerator.Prefab_FishAll;
        float  oneFishUseTime = TimeLoadTexture / prefabFishAll.Length;

        foreach (Fish f in prefabFishAll)
        {
            Fish fishLoaded = Instantiate(f) as Fish;

            yield return(0);

            //Fish fishLoaded = Pool_GameObj.GetObj(f.gameObject).GetComponent<Fish>();
            fishLoaded.transform.parent = transform;
            //yield return new WaitForSeconds(oneFishUseTime*0.5F);
            fishLoaded.Clear();
            yield return(new WaitForSeconds(oneFishUseTime));
        }
    }
Пример #5
0
        //public
        public IEnumerator _Coro_Process()
        {
            //辣椒鱼往中间走
            var oneSideNum = 160;
            var fishUpDown = new Fish[2, oneSideNum];

            StartCoroutine(_Coro_GenerateRoadSideFish(fishUpDown, oneSideNum));

            Vector3[] posLineFish = new Vector3[2] {
                TsLineFish[0].position, TsLineFish[1].position
            };
            posLineFish[0].x -= GameMain.Singleton.WorldDimension.width * 0.5F;
            posLineFish[1].x += GameMain.Singleton.WorldDimension.width * 0.5F;
            for (int i = 0; i != 2; ++i)
            {
                TsLineFish[i].position = posLineFish[i];
            }

            Transform ts;

            while (true)
            {
                int nullNum = 0;
                for (int i = 0; i != TsLineFish.Length; ++i)
                {
                    if (TsLineFish[i] == null)
                    {
                        ++nullNum;
                        continue;
                    }

                    ts           = TsLineFish[i];
                    ts.position += ts.right * Speed * Time.deltaTime;
                    if ((ts.right.x > 0F && ts.position.x > GameMain.Singleton.WorldDimension.xMax) ||//向左并达到左边屏幕边
                        (ts.right.x <= 0F && ts.position.x < GameMain.Singleton.WorldDimension.x))   //向右移动并达到右边屏幕边
                    {
                        List <Fish> fishToClear = new List <Fish>();

                        foreach (Transform tChild in TsLineFish[i])
                        {
                            Fish f = tChild.GetComponent <Fish>();
                            if (f != null && f.Attackable)
                            {
                                fishToClear.Add(f);
                            }
                        }
                        foreach (Fish f in fishToClear)
                        {
                            f.Clear();
                        }

                        Destroy(TsLineFish[i].gameObject);
                        TsLineFish[i] = null;
                    }
                }

                if (nullNum == TsLineFish.Length)
                {
                    break;
                }

                yield return(0);
            }

            //两边路散走
            ////设置碰撞框

            //float fishSpeedHalf = Prefab_FishCompositeRoad.swimmer.Speed * 0.5F;
            Swimmer swimmerTmp = null;

            for (int i = 0; i != 2; ++i)
            {
                for (int j = 0; j != oneSideNum; ++j)
                {
                    if (fishUpDown[i, j] == null)
                    {
                        continue;
                    }
                    swimmerTmp = fishUpDown[i, j].swimmer;
                    swimmerTmp.SetLiveDimension(Defines.ClearFishRadius);
                    swimmerTmp.Speed = Random.Range(swimmerTmp.Speed * 0.9F, swimmerTmp.Speed * 1.5F);
                    swimmerTmp.Go();
                }
            }



            //等待清鱼,改用时间限制
            while (GameMain.Singleton.NumFishAlive != 0)
            {
                yield return(0);
            }

            EndPrelude();
        }
Пример #6
0
    public IEnumerator _Coro_Transiting()
    {
        //设置开始位置
        for (int i = 0; i != EmitDatas.Length; ++i)
        {
            EmitDatas[i].TsShoalOfFish.localPosition = EmitDatas[i].TsPosStart[GameMain.Singleton.ScreenNumUsing - 1].localPosition;
        }

        if (IsDepthAdvanceAuto)
        {
            for (int i = 0; i != EmitDatas.Length; ++i)
            {
                float   depth = EmitDatas[i].TsShoalOfFish.GetChild(0).localPosition.z;
                Vector3 posTmp;
                foreach (Transform t in EmitDatas[i].TsShoalOfFish)
                {
                    posTmp          = t.localPosition;
                    posTmp.z        = depth;
                    depth          -= Defines.OffsetAdv_FishGlobleDepth;
                    t.localPosition = posTmp;
                }
            }
        }
        //开始移动
        Transform ts;

        while (true)
        {
            int nullNum = 0;
            for (int i = 0; i != EmitDatas.Length; ++i)
            {
                if (EmitDatas[i].TsShoalOfFish == null)
                {
                    ++nullNum;
                    continue;
                }

                ts           = EmitDatas[i].TsShoalOfFish;
                ts.position += ts.right * Speed * Time.deltaTime;
                if ((ts.right.x > 0F && ts.position.x > GameMain.Singleton.WorldDimension.xMax) ||//向左并达到左边屏幕边
                    (ts.right.x <= 0F && ts.position.x < GameMain.Singleton.WorldDimension.x))   //向右移动并达到右边屏幕边
                {
                    List <Fish> fishToClear = new List <Fish>();

                    foreach (Transform tChild in EmitDatas[i].TsShoalOfFish)
                    {
                        Fish f = tChild.GetComponent <Fish>();
                        if (f != null && f.Attackable)
                        {
                            fishToClear.Add(f);
                        }
                    }
                    foreach (Fish f in fishToClear)
                    {
                        f.Clear();
                    }

                    Destroy(EmitDatas[i].TsShoalOfFish.gameObject);
                    EmitDatas[i].TsShoalOfFish = null;
                }
            }



            if (nullNum == EmitDatas.Length)
            {
                EndPrelude();
            }

            yield return(0);
        }
    }