コード例 #1
0
    void Update()
    {
        if (timeKeeperScript.GetStartFlag())
        {
            this.deltaS += Time.deltaTime;
            this.deltaM += Time.deltaTime;
            this.deltaL += Time.deltaTime;
            this.deltaR += Time.deltaTime;
        }

        //出現率が高い魚の生成
        if (this.deltaS > this.spawnSpan + Random.Range(-1, 1))
        {
            this.deltaS = 0;
            GameObject goS = Instantiate(fishStatusDatas[0].GetFishPrefabs()) as GameObject;
            goS.transform.position = RandomPos();
        }
        //出現率普通の魚の生成
        if (this.deltaM > this.spawnSpan * spanCoefficient + Random.Range(-1, 1))
        {
            this.deltaM = 0;
            GameObject goM = Instantiate(fishStatusDatas[1].GetFishPrefabs()) as GameObject;
            goM.transform.position = RandomPos();
        }
        //出現率が低い魚の生成
        if (this.deltaL > this.spawnSpan * spanCoefficient * spanCoefficient + Random.Range(-1, 1))
        {
            this.deltaL = 0;
            GameObject goL = Instantiate(fishStatusDatas[2].GetFishPrefabs()) as GameObject;
            goL.transform.position = RandomPos();
        }
        if (deltaR > redSpan && redCount < 3)
        {
            deltaR = 0;
            int random = Random.Range(0, randomMax);
            if (random == 0)
            {
                GameObject goR = Instantiate(fishStatusDatas[3].GetFishPrefabs()) as GameObject;
                goR.transform.position = RandomPos();
                redCount++;
            }
        }
    }
コード例 #2
0
    void Update()
    {
        //銛が動いていない&左クリックで処理 ゲームスタートで処理開始
        if (Input.GetMouseButtonDown(0) && !goFlag && !backFlag && timeKeeperScript.GetStartFlag())
        {
            //マウスの座標を保存
            endPos   = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            endPos.z = 0f;
            audioSource.PlayOneShot(throwing);

            //飛ばす方向に回転
            radius = GetRadius(startPos, endPos);
            transform.Rotate(new Vector3(0, 0, radius - 90));

            startTime = Time.time;
            goFlag    = true;
        }
        //クリックした地点に向かっているとき
        if (goFlag)
        {
            GetComponent <Collider2D>().enabled = true;
            //移動ベクトルの計算
            CalcVec(startPos, endPos, coefficient);
            //mousePosについたら処理
            if (fracJourney > 1)
            {
                goFlag      = false;
                backFlag    = true;
                startTime   = Time.time;
                fracJourney = 0;
            }
        }
        //スタート地点に戻るとき
        if (backFlag)
        {
            GetComponent <Collider2D>().enabled = false;
            CalcVec(endPos, startPos);
            if (fracJourney > 1)
            {
                backFlag = false;
                if (gameObject.transform.childCount > 0)
                {
                    evaTextScript.SetActiveAndObject(SetEvaText(transform.childCount));
                }

                //子を全部削除
                foreach (Transform child in gameObject.transform)
                {
                    calcPointScript.AddPoint(child.gameObject);
                    Destroy(child.gameObject);
                }
                //角度を元に戻す
                transform.Rotate(new Vector3(0, 0, 90 - radius));
                fracJourney = 0;
            }
        }
        if (goFlag || backFlag)
        {
            //移動処理
            _rb.MovePosition(vec);
        }
        //Debug.Log(mousePos);
    }