Exemplo n.º 1
0
    /// <summary>
    /// <see cref="Info"/>를 바탕으로 Unity 공간에 3D 오브젝트를 생성하고 GameObj 멤버에 그 참조를 할당하는 코루틴.
    /// </summary>
    private IEnumerator CreateObject()
    {
        // 초기 포지션 설정
        Vector3 unityPosition = GpsCalulator.CoordinateDifference(ClientInfoObj.StartingLatitude, ClientInfoObj.StartingLongitude, ClientInfoObj.StartingAltitude,
                                                                  Info.GpsInfo[0], Info.GpsInfo[1], Info.GpsInfo[2]);

        GameObj      = createObject(Info.typeName, unityPosition);
        GameObj.name = Info.typeName;
        // 타입 지정
        ObjectType = ArObjectType.Ar3dObject;
        // 3D object의 DataContainer에 값 패싱
        GameObj.AddComponent <DataContainer>().AdNum = Info.ObjectNumber;
        GameObj.GetComponent <DataContainer>().CreatedCameraPosition =
            new Vector3(ClientInfoObj.MainCamera.transform.position.x, ClientInfoObj.MainCamera.transform.position.y, ClientInfoObj.MainCamera.transform.position.z);
        GameObj.GetComponent <DataContainer>().ObjectType = ArObjectType.Ar3dObject;

        // GPS 정보를 사용하기 위해 GPS 초기화가 안된 경우 대기.
        if (Application.platform == RuntimePlatform.Android)
        {
            yield return(new WaitUntil(() => ClientInfoObj.OriginalValuesAreSet));
        }

        unityPosition.y = 0; // 고도 사용 안함.

        GameObj.transform.position    = unityPosition;
        GameObj.transform.eulerAngles = new Vector3(0, Info.Bearing, 0);
        GameObj.transform.RotateAround(ClientInfoObj.MainCamera.transform.position, new Vector3(0.0f, 1.0f, 0.0f), -ClientInfoObj.CorrectedBearingOffset); // 카메라 포지션 기준 회전
    }
Exemplo n.º 2
0
        public void Switch(ContentRef <Scene> nextScene, float duration, ColorRgba color, Easing easing = Easing.Linear)
        {
            if (!isSwitching)
            {
                isSwitching = true;

                var faderOut = GameObj.AddComponent <ColorFader>();
                faderOut.FadeOut(duration / 2f, color, easing);

                var faderIn = new GameObject("ColorFader").AddComponent <ColorFader>();
                faderIn.FadeIn(duration / 2f, color, easing);

                faderOut.Faded += delegate
                {
                    if (nextScene != null)
                    {
                        nextScene.Res.AddObject(faderIn.GameObj);

                        Scene.SwitchTo(nextScene);
                        isSwitching = false;

                        faderIn.Faded += delegate
                        {
                            faderIn.GameObj.DisposeLater();
                        };
                    }
                };
            }
        }
Exemplo n.º 3
0
    /// <summary>
    /// <see cref="Info"/>를 바탕으로 Unity 공간에 Plane 오브젝트를 생성하고 GameObj 멤버에 그 참조를 할당하는 코루틴.
    /// </summary>
    private IEnumerator CreateObject()
    {
        ObjectType   = ArObjectType.AdPlane; // 타입 지정
        GameObj      = GameObject.CreatePrimitive(PrimitiveType.Plane);
        GameObj.name = Info.Name;
        // Plane object의 DataContainer에 값 패싱
        GameObj.AddComponent <DataContainer>().BannerUrl             = Info.BannerUrl; // URL 정보를 담을 DataContainer Component추가
        GameObj.GetComponent <DataContainer>().AdNum                 = Info.AdNumber;
        GameObj.GetComponent <DataContainer>().CreatedCameraPosition =
            new Vector3(ClientInfoObj.MainCamera.transform.position.x, ClientInfoObj.MainCamera.transform.position.y, ClientInfoObj.MainCamera.transform.position.z);
        GameObj.GetComponent <DataContainer>().ObjectType = ArObjectType.AdPlane;

        // GPS 정보를 사용하기 위해 GPS 초기화가 안된 경우 대기.
        if (Application.platform == RuntimePlatform.Android)
        {
            yield return(new WaitUntil(() => ClientInfoObj.OriginalValuesAreSet));
        }

        // 초기 포지션 설정
        Vector3 unityPosition = GpsCalulator.CoordinateDifference(ClientInfoObj.StartingLatitude, ClientInfoObj.StartingLongitude, ClientInfoObj.StartingAltitude,
                                                                  Info.GpsInfo[0], Info.GpsInfo[1], Info.GpsInfo[2]);

        unityPosition.y = 0; // 고도 사용 안함.

        GameObj.transform.localScale  = new Vector3(Info.Width, Info.Height, Info.Height);
        GameObj.transform.position    = unityPosition;
        GameObj.transform.eulerAngles = new Vector3(90.0f, Info.Bearing - 90.0f, 90.0f);
        GameObj.transform.RotateAround(ClientInfoObj.MainCamera.transform.position, new Vector3(0.0f, 1.0f, 0.0f), ClientInfoObj.CorrectedBearingOffset); // 카메라 포지션 기준 회전
        // GameOBJ.transform.rotation = Quaternion.Euler(90.0f, -90.0f, 90.0f);
        // 모든 plane은 new Vector3(90.0f, -90.0f, 90.0f); 만큼 회전해야함
    }
        void ICmpCollisionListener.OnCollisionBegin(Component sender, CollisionEventArgs args)
        {
            if (args.CollideWith.ContainsTag() && args.CollideWith.HasID(Tag.ID.DOOR))
            {
                GameManager.GoToNextScene();
            }

            if (args.CollideWith.ContainsTag() && args.CollideWith.HasID(Tag.ID.MAINAREA))
            {
                GameManager.EnteredMainArea = true;
                Game.Write("You have entered main area");
            }

            if (args.CollideWith.ContainsTag() && args.CollideWith.HasID(Tag.ID.APPLE))
            {
                Game.Write("Your a WINNER :P");
                GameManager.PlaySFX(GameManager.SoundType.eatApple);
                if (Scene.Name != "Nightmare")
                {
                    if (GameManager.File.Res.Restarts == true)
                    {
                        Scene.Reload();
                    }
                    if (GameManager.File.Res.Invincible == false)
                    {
                        if (GameManager.File.Res.Restarts == false)
                        {
                            GameManager.ApplesEaten++;
                            GameManager.EndScene();
                        }
                        else
                        {
                            Scene.Reload();
                        }
                    }
                }
                else
                {
                    GameManager.GoToNextScene();
                }
            }

            if (args.CollideWith.ContainsTag() && args.CollideWith.HasID(Tag.ID.WATER))
            {
                GameManager.SetGameState(GameManager.GAMESTATE.LOST);
                if (Puddle != null)
                {
                    var p = Puddle.Res.Instantiate(GameObj.Transform.Pos, 0, 2);
                    Scene.AddObject(p);
                    GameObj.GetComponent <RigidBody>().LinearVelocity = Vector2.Zero;
                    GameObj.GetComponent <SpriteRenderer>().ColorTint = ColorRgba.TransparentWhite;
                    GameManager.PlaySFX(GameManager.SoundType.drown);
                    GameObj.AddComponent <ImminantEnd>();
                }
            }
        }