예제 #1
0
        void Awake()
        {
            stonePool = GOPool.Create(25)
                        .Grow(true)
                        .Parent(GO.Create("StonePool"))
                        .Fill(prefabStone.gameObject);

            splashPool = GOPool.Create(50)
                         .Grow(true)
                         .Parent(GO.Create("SplashPool"))
                         .Fill(prefabSplash.gameObject)
                         .SetOnSpawn(splash => {
                splash.GetComponent <SkippingSplash>()
                .onAnimDone.AddListener(OnSplashAnimDone);
            });

            anims = ObjectPool <StoneSkipAnim> .Create(20)
                    .Grow(false)
                    .Fill(i => {
                return(new StoneSkipAnim {
                    skipCoords = new Vector3[numSkipsPerThrow],
                    splashes = new SkippingSplash[numSkipsPerThrow]
                });
            })
                    .SetOnDespawn(OnDespawnAnim);

            playTimes = new float[numSkipsPerThrow];
            // Calculate duration time per frame
            CalcPlayTimes(numSkipsPerThrow, ref playTimes);

            // get child objects from throwingStones. Pool them and refill
            // with as many as there are child objects.
        }
예제 #2
0
        public void Ready(Messenger msg)
        {
            Assert.AreEqual(cam.orthographicSize, 11f,
                            "Camera should have an orthographic size " +
                            "of 11 due to the import settings of the " +
                            "graphics.");

            float colliderHeight = cam.orthographicSize * 2f;
            float colliderWidth  = colliderHeight * cam.aspect + boundsWidth;

            panning = GO.Create("CameraPanning")
                      .AddComponent <CameraPanning>(cp => { cp
                                                            .Init(new CameraPanningConfig {
                    camera       = cam,
                    tapThreshold = 1.5f,
                    scale        = new Vector3(colliderWidth,
                                               colliderHeight,
                                               0f),
                    inertiaDuration = 2f
                }); })
                      .SetLayer("Default")
                      .SetParent(transform)
                      .SetLocalPosition(new Vector3(0f, 0f, cam.transform.position.z + 1f))
                      .GetComponent <CameraPanning>();

            dayStart   = dayNightCycle.keys[1].time;
            nightStart = dayNightCycle.keys[2].time;

            msg.Dispatch(new MCameraReady {
                camera = cam
            });

            msg.Dispatch(new MAddUpdateHandler(this));
        }
예제 #3
0
 private void AddVoxelSelector()
 {
     selector = GO.Create()
                .SetName("VoxelSelector")
                .SetParent(transform)
                .AddComponent <VoxelSelector>((vs) => {
         vs.Create(ChunkManager.blockSize);
     })
                .gameObject
                .GetComponent <VoxelSelector>();
 }
예제 #4
0
    void Awake()
    {
        //  Callbacks.OnSelectionData += OnSelectionData;

        GO.Create()
        .SetName("BlockManager")
        .AddComponent <BlockManager>((bm) => {
            blockManager = bm;
            bm.Init();
        });

        //  Vector3 v3 = Vector3.zero;
        //  Point3 p3 = Point3.ToWorldBlockCoord(v3).
    }
예제 #5
0
        private void Awake()
        {
            if (numAudioSources <= 0)
            {
                numAudioSources = 1;
            }

            audioSources = new AudioSource[numAudioSources];
            for (int i = 0; i < numAudioSources; i++)
            {
                audioSources[i] = GO
                                  .Create("AudioSource_" + i)
                                  .SetParent(transform, false)
                                  .AddComponent <AudioSource>(OnInitAudioSource)
                                  .GetComponent <AudioSource>();
            }
        }
예제 #6
0
        private void SetupCamera(Camera cam)
        {
            Vector3 pos = new Vector3(
                transform.position.x,
                cam.transform.position.y,
                cam.transform.position.z + 10);

            audioSources = new AudioSource[numAudioSources];
            for (int i = 0; i < numAudioSources; i++)
            {
                audioSources[i] = GO
                                  .Create("AudioSource_" + i)
                                  .SetParent(transform, false)
                                  .SetPosition(pos)
                                  .AddComponent <AudioSource>(OnInitAudioSource)
                                  .GetComponent <AudioSource>();
            }

            GetOrderer(playOrder).Sort(sequence);
        }
예제 #7
0
    private void PlaceBlock(Point3 worldCoord, int hash, BlockInfo info)
    {
        Vector3 wCoord = worldCoord.ToVector3();

        wCoord += Vector3.one * 0.5f;

        GameObject container = null;

        // Put code below in an event handler for OnFoundSurface??
        if (!chunks.ContainsKey(hash))
        {
            container = GO.Create()
                        .SetName(hash.ToString())
                        .SetParent(transform)
                        .gameObject;
            chunks.Add(hash, container);
        }
        chunks.TryGetValue(hash, out container);

        Mesh mesh = Resources.Load("Meshes/Dev/" + info.meshName) as Mesh;

        if (mesh == null)
        {
            mesh = voxelMesh;
        }

        GO.Create()
        .SetParent(container.transform)
        .SetMesh(mesh)
        .SetName(Name(worldCoord))
        .SetMaterial(voxelMat)
        .ReceiveShadows(true)
        .CastShadows(ShadowCastingMode.On)
        .AddBoxCollider(Vector3.one * ChunkManager.blockSize)
        .SetPosition(wCoord)
        .SetRotation(info.rotation, true);
    }