Esempio n. 1
0
    // Use this for initialization
    void Start()
    {
        //フレームレート
        Application.targetFrameRate = 60;

        //マウスカーソルの非表示
        Cursor.visible = false;

        //魚の生成
        for (int k = 0; k < 3; k++)
        {
            for (int j = 0; j < WorldData.Fish.Count; j++)
            {
                GameObject Flock = Instantiate(FlockPrefab);

                for (int i = 0; i < WorldData.FishNum; i++)
                {
                    GameObject Boid = Instantiate(WorldData.Fish[j].Prefab);
                    Boid.transform.SetParent(Flock.transform);

                    Boid b = Boid.GetComponent <Boid>();
                    b.SetMaxSpeed(WorldData.Fish[j].MaxSpeed);
                    b.SetWeights(WorldData.Fish[j].Weights);
                    b.SetDesiredSeparate(WorldData.Fish[j].DesiredSeparate);
                    b.SetNeighborDist(WorldData.Fish[j].NeighborDist);
                    b.SetField(Field);

                    fish Fish = Boid.GetComponent <fish>();
                    Fish.SetfinSpeed(Random.Range(0.5f, 1.0f));
                    Fish.SetCycleOffset(Random.Range(0.1f, 1.0f));
                    Fish.SetMaterialFin(WorldData.Fish[j].FinColor);
                    Fish.SetMaterialBody(WorldData.Fish[j].BodyColor);

                    Transform FishBody = Boid.GetComponent <Transform>();
                    FishBody.localScale = new Vector3(1, 1, 1) * Random.Range(3.0f, 7.0f);

                    Vector3 fp = Field.GetPosition();

                    FishBody.localPosition = new Vector3(0, 0, 0);

                    Flock.GetComponent <Flock>().AddBoid(Boid);
                }

                Flocks.Add(Flock.GetComponent <Flock>());
            }
        }

        IEnumerator StandByCoRoutine = WaitLeapHandCoRoutine();

        StartCoroutine(StandByCoRoutine);
    }
Esempio n. 2
0
    void ReSpawn(Direction _Direction)
    {
        this.Acceleration = new Vector3(0, 0, 0);
        this.Velocity     = new Vector3(0, 0, 0);
        //出現位置の決定
        //フェードイン
        //ベクトルの決定

        Vector3 Pos       = Field.GetPosition();
        Vector3 AddVector = new Vector3(0, 0, 0);

        //DeSpawnした位置
        //switch (_Direction)
        //{
        //    case Direction.TOP:
        //        Transform.position = new Vector3(
        //            Random.Range(Pos.x - Field.GetWidth() / 2, Pos.x + Field.GetWidth() / 2),
        //            Pos.y - Field.GetHeight() / 2,
        //            Random.Range(Pos.z - Field.GetDepth() / 2, Pos.z + Field.GetDepth() / 2)
        //        );
        //        AddVector = new Vector3(
        //            0.0f, Random.Range(0.1f, 0.5f), 0.0f
        //        );
        //        break;

        //    case Direction.BOTTOM:
        //        Transform.position = new Vector3(
        //            Random.Range(Pos.x - Field.GetWidth() / 2, Pos.x + Field.GetWidth() / 2),
        //            Pos.y + Field.GetHeight() / 2,
        //            Random.Range(Pos.z - Field.GetDepth() / 2, Pos.z + Field.GetDepth() / 2)
        //        );
        //        AddVector = new Vector3(
        //            0.0f, -Random.Range(0.1f, 0.5f), 0.0f
        //        );
        //        break;

        //    case Direction.LEFT:
        //        Transform.position = new Vector3(
        //            Pos.x + Field.GetWidth() / 2,
        //            Random.Range(Pos.y - Field.GetHeight() / 2, Pos.y + Field.GetHeight() / 2),
        //            Random.Range(Pos.z - Field.GetDepth() / 2, Pos.z + Field.GetDepth() / 2)
        //        );
        //        AddVector = new Vector3(
        //            Random.Range(0.1f, 0.5f), 0.0f, 0.0f
        //        );
        //        break;

        //    case Direction.RIGHT:
        //        Transform.position = new Vector3(
        //            Pos.x - Field.GetWidth() / 2,
        //            Random.Range(Pos.y - Field.GetHeight() / 2, Pos.y + Field.GetHeight() / 2),
        //            Random.Range(Pos.z - Field.GetDepth() / 2, Pos.z + Field.GetDepth() / 2)
        //        );
        //        AddVector = new Vector3(
        //            -Random.Range(0.1f, 0.5f), 0.0f, 0.0f
        //        );
        //        break;

        //    case Direction.FRONT:
        //        Transform.position = new Vector3(
        //            Random.Range(Pos.x - Field.GetWidth() / 2, Pos.x + Field.GetWidth() / 2),
        //            Random.Range(Pos.y - Field.GetHeight() / 2, Pos.y + Field.GetHeight() / 2),
        //            Pos.z - Field.GetDepth() / 2
        //        );
        //        AddVector = new Vector3(
        //            0.0f, 0.0f, Random.Range(0.1f, 0.5f)
        //        );
        //        break;

        //    case Direction.BACK:
        //        Transform.position = new Vector3(
        //            Random.Range(Pos.x - Field.GetWidth() / 2, Pos.x + Field.GetWidth() / 2),
        //            Random.Range(Pos.y - Field.GetHeight() / 2, Pos.y + Field.GetHeight() / 2),
        //            Pos.z + Field.GetDepth() / 2
        //        );
        //        AddVector = new Vector3(
        //            0.0f, 0.0f, -Random.Range(0.1f, 0.5f)
        //        );
        //        break;

        //    case Direction.NULL:
        //        Transform.position = new Vector3(
        //            Random.Range(Pos.x - Field.GetWidth() / 2, Pos.x + Field.GetWidth() / 2),
        //            Random.Range(Pos.y - Field.GetHeight() / 2, Pos.y + Field.GetHeight() / 2),
        //            Random.Range(Pos.z - Field.GetDepth() / 2, Pos.z + Field.GetDepth() / 2)
        //        );
        //        AddVector = new Vector3(
        //            Random.Range(-0.5f, 0.5f), Random.Range(-0.5f, 0.5f), Random.Range(-0.5f, 0.5f)
        //        );
        //        break;
        //}


        Transform.position = new Vector3(
            Random.Range(Pos.x - Field.GetWidth() / 4, Pos.x + Field.GetWidth() / 4),
            Random.Range(Pos.y - Field.GetHeight() / 4, Pos.y + Field.GetHeight() / 4),
            Pos.z + Field.GetDepth() / 2
            );
        AddVector = new Vector3(
            0.0f, 0.0f, -Random.Range(0.1f, 0.5f)
            );

        FadeIn();
        ApplyForce(AddVector);
    }