コード例 #1
0
ファイル: ScreenshotHandler.cs プロジェクト: sshuyii/Karara
    public void TakeScreenshot()
    {
        if (isTaken)
        {
            return;
        }

        isTaken = true;
        //shutterSound.Play();
        AudioManager.PlayAudio(AudioType.Photo_Shutter);


        //hide notice bubble
        int repeatCondition = 0;

        if (!FinalCameraController.isTutorial)
        {
            FinalCameraController.Hide(Notice);
        }
        if (!AdsController.IsThisAdOk())
        {
            repeatCondition = 2;
        }

        if (!AdsController.IsThisPoseOk() && !FinalCameraController.isTutorial)
        {
            repeatCondition = 1;
        }

        InstagramController.RepeatPostureOrBG(repeatCondition);

        TakeScreenshot(width, height);



        InstagramController.takenNum++;

        FinalCameraController.entryTime += 1;

        StartCoroutine(ExampleCoroutine());


        //re-arrange children object, so the latest is displayed as the first
        //for (int i = 0; i < InstagramController.postList.Count; i++)
        //{
        //    InstagramController.postList[i].transform.SetSiblingIndex(i);
        //}


        //AdsController.UseAdAndPose();
    }
コード例 #2
0
    public void TakeScreenshot()
    {
        if (isTaken)
        {
            print("taking photo disabled");
            return;
        }
        print("taking photo enabled");
        isTaken = true;
        shutterSound.Play();
        //hide notice bubble
        if (!FinalCameraController.isTutorial)
        {
            FinalCameraController.Hide(Notice);
        }

        //if the background is already used
        if (!InstagramController.AdAlreadyTakenList[InstagramController.currentBackground] && !FinalCameraController.isTutorial)
        {
            FinalCameraController.Show(Notice);
            Notice.gameObject.GetComponentInChildren <TextMeshProUGUI>().text = "no same background";
            isTaken = false;
            return;
        }
        InstagramController.usedAdsList.Add(photoBackground.GetComponent <Image>().sprite.name);


        TakeScreenshot(width, height);

        //don't take the picture in the first half of the tutorial
        if (FinalCameraController.isTutorial && FinalCameraController.TutorialManager.tutorialNumber < 9)
        {
            flash         = true;
            myFlash.alpha = 1;
            return;
        }
        else if (!usedPostures.ContainsKey(CalculateInventory.posNum.ToString()))//没用过这个姿势
        {
            InstagramController.takenNum++;
            //instantiate new post object
            toothpastePost = Instantiate(InstagramController.PosturePostPrefabNew, new Vector3(0, 0, 0), Quaternion.identity);
            //set parent(probably a better way to do
            toothpastePost.transform.SetParent(InstagramController.postParent.transform);
            toothpastePost.transform.localScale = Vector3.one;
            //move to the first of the list
            InstagramController.postList.Insert(0, toothpastePost);

            toothpastePost.GetComponent <EntryTime>().time = FinalCameraController.entryTime;

            FinalCameraController.entryTime += 1;

            //if in the tutorial and taking the photo for the second time
            if (FinalCameraController.isTutorial && FinalCameraController.TutorialManager.tutorialNumber == 13)
            {
                FinalCameraController.TutorialManager.tutorialNumber = 14;
            }
        }



        StartCoroutine(ExampleCoroutine());


        //re-arrange children object, so the latest is displayed as the first
        for (int i = 0; i < InstagramController.postList.Count; i++)
        {
            InstagramController.postList[i].transform.SetSiblingIndex(i);
        }



//        coroutine = screenShotCoroutine();
//        StartCoroutine(coroutine);

        //myScreenshot = Resources.Load<Texture2D>("Screenshots/CameraScreenshot");

        //print(myScreenshot.name + "aaaaaaaa");

//        TexToPng(CropImage());

//        for (int i = 0; i < instagramController.postList.Count; i++)
//        {
//            instagramController.postList[i].transform.SetSiblingIndex(i);
//            print(i + "dddd");
//            print(instagramController.postList[i].transform.name + instagramController.postList[i].transform.GetSiblingIndex());
//        }
    }
コード例 #3
0
ファイル: DoInventory.cs プロジェクト: sshuyii/subwayGame
    public void AddClothToInventory()
    {
        if (FinalCameraController.isSwipping == false)
        {
            WasherController = GetComponentInParent <WasherController>();

            if (CalculateInventory.occupiedI < 6)
            {
                //print("pressed");
                //get the machine this cloth belongs to
                //if all clothes in the machine are taken, close door
                WasherController.clothNum--; //洗衣机里的衣服少一

                //如果洗衣机里没衣服了,那么直接关上
                if (WasherController.clothNum == 0)
                {
                    print("should close machine door");
                    StartCoroutine(WasherController.MachineFold());
                    WasherController.DoorImage.sprite = WasherController.AllMachines.closedDoor;
                }



                selfButton    = GetComponent <Button>();
                currentSprite = selfButton.image.sprite;
                print("currentSpriteName = " + currentSprite.name);

                Sprite buttonSprite = currentSprite;
                print("SpriteName = " + currentSprite.name);

                print("occupiedI = " + CalculateInventory.occupiedI);

                int firstEmptyInventory = new int();
                //这里应该找到第一个空着的inventory位置
                for (int i = 0; i < CalculateInventory.inventory.Count; i++)
                {
                    if (CalculateInventory.inventory[i].CompareTag("Untagged"))
                    {
                        firstEmptyInventory = i;
                        break;
                    }
                }

                //inventory used to be buttons
                CalculateInventory.inventory[firstEmptyInventory].GetComponent <Image>().sprite = buttonSprite;
                CalculateInventory.inventory[firstEmptyInventory].tag = this.tag;
                CalculateInventory.occupiedI++;



                //for tutorial
                if (FinalCameraController.isTutorial) //打开了洗衣机的门,真的拿了衣服
                {
                    if (FinalCameraController.TutorialManager.tutorialNumber == 9 ||
                        FinalCameraController.TutorialManager.tutorialNumber == 11) //拿了第二件衣服
                    {
                        FinalCameraController.TutorialManager.tutorialNumber = 12;
                        //in tutorial, if click a cloth, cloth the entire ui interface
                        WasherController.clickMachine();
                        StartCoroutine(FinalCameraController.TutorialManager.AnimateText(
                                           FinalCameraController.TutorialManager.kararaText, "put on",
                                           true, FinalCameraController.TutorialManager.closet, new Vector2(-81, 37)));
                        FinalCameraController.TutorialManager.tutorialDialogueState =
                            TutorialManager.DialogueState.karara;
//                        FinalCameraController.clickKarara();
                        FinalCameraController.Hide(FinalCameraController.TutorialManager.arrowButton);
                    }
                }

                //image disappear
                selfButton.image.enabled = false;
                //selfButton.enabled = false;
            }

            else if (CalculateInventory.occupiedI > 5 && CalculateInventory.fulltemp == false)
            {
                FinalCameraController.Hide(WasherController.ClothUI);
                FinalCameraController.Show(CalculateInventory.InventoryFull);
                CalculateInventory.fulltemp = true;

                //close all machine doors
                WasherController.DoorImage.sprite = WasherController.AllMachines.closedDoor;
                StartCoroutine(WasherController.MachineFold());
            }
        }
    }
コード例 #4
0
ファイル: TouchController.cs プロジェクト: sshuyii/subwayGame
    // Update is called once per frame
    void Update()
    {
//        print("cancelCloth = " + doubleTouch);
        for (var i = 0; i < Input.touchCount; ++i)
        {
            if (Input.GetTouch(i).phase == TouchPhase.Began)
            {
                if (Input.GetTouch(i).tapCount == 2)
                {
                    Debug.Log("Double Tap");
                    doubleTouch = true;
                }
            }
            else if (Input.GetTouch(i).phase == TouchPhase.Ended)
            {
                doubleTouch = false;
            }
        }


        if (Input.touchCount == 1)               // user is touching the screen with a single touch
        {
            touch = Input.GetTouch(0);           // get the touch
            if (touch.phase == TouchPhase.Began) //check for the first touch
            {
                fp = touch.position;
                lp = touch.position;

                startTime = Time.time;

                offsetX = camTransform.position.x - lp.x;

                myInputState = InputState.None;

                //for swipe screen
                isSwipable = true;
            }
            else if (touch.phase == TouchPhase.Moved) // update the last position based on where they moved
            {
                lp = touch.position;
//                print("lp = " + lp);

                if (Mathf.Abs(lp.y - fp.y) > dragDistance / 4 || Mathf.Abs(lp.x - fp.x) > dragDistance / 4)
                {
                    isSwiping = true;

                    //disable dialogue bubble if swiped
                    //important: don't disable if it shouldn't be disabled
                    //for example, in the middle of someone talking
                    if (FinalCameraController.isTutorial && !FinalCameraController.TutorialManager.stopDisappear &&
                        FinalCameraController.TutorialManager.tutorialNumber != 3 &&
                        FinalCameraController.TutorialManager.tutorialNumber != 0 &&
                        FinalCameraController.TutorialManager.tutorialNumber < 15)
                    {
                        FinalCameraController.Hide(FinalCameraController.TutorialManager.GestureCG);
                        FinalCameraController.TutorialManager.screamImage.enabled   = false;
                        FinalCameraController.TutorialManager.tutorialDialogueState =
                            TutorialManager.DialogueState.none;
                        print("disappear in the middle");
                    }
                }
                else
                {
                    isSwiping = false;
                }

                if (Mathf.Abs(lp.x - fp.x) > dragDistance || Mathf.Abs(lp.y - fp.y) > dragDistance)
                {
                }
                else
                {
                    //it is a long tap
                    if (Time.time - startTime > 0.8f)
                    {
                        isLongTap = true;
                    }
                    else
                    {
                        isLongTap = false;
                    }
                }
            }
            else if (touch.phase == TouchPhase.Ended) //check if the finger is removed from the screen
            {
//                if(FinalCameraController.isTutorial && FinalCameraController.myCameraState == FinalCameraController.CameraState.Subway)
//                {
//                    if(FinalCameraController.TutorialManager.tutorialNumber != 6 && FinalCameraController.TutorialManager.tutorialNumber != 7)
//                    {
//                        FinalCameraController.TutorialManager.tutorialDialogueState =
//                            TutorialManager.DialogueState.fish;
//                    }
//                }

                if (FinalCameraController.isTutorial && FinalCameraController.mySubwayState != FinalCameraController.SubwayState.One &&
                    FinalCameraController.TutorialManager.tutorialNumber == 1)
                {
                    FinalCameraController.Show(FinalCameraController.TutorialManager.GestureCG);
                    FinalCameraController.TutorialManager.screamImage.enabled = true;
                    FinalCameraController.TutorialManager.DoFishDialogue(true);
                }


                lp = touch.position;  //last touch position. Ommitted if you use list

                offsetX   = 0;
                isSwiping = false;

                //check if this is a fast swipe
                diffTime      = startTime - Time.time;
                swipeDistance = Vector2.Distance(fp, lp);
                swipeSpeed    = Mathf.Abs(swipeDistance / diffTime);//<<<<<<<<
//                print("diffTime =" + diffTime);
//                print("swipeSpeed =" + swipeSpeed);
                if (swipeSpeed > 500 && Mathf.Abs(diffTime) < 0.2f)
                {
                    isFastSwipe = true;
                }
                else
                {
                    isFastSwipe = false;
                }

                //Check if drag distance is greater than 20% of the screen height
                if (Mathf.Abs(lp.x - fp.x) > dragDistance || Mathf.Abs(lp.y - fp.y) > dragDistance)
                {//It's a drag
                 //check if the drag is vertical or horizontal
                    if (Mathf.Abs(lp.x - fp.x) > Mathf.Abs(lp.y - fp.y))
                    {                      //If the horizontal movement is greater than the vertical movement...
                        if ((lp.x > fp.x)) //If the movement was to the right)
                        {                  //Right swipe
                            Debug.Log("Right Swipe");
                            leftSwipe    = false;
                            myInputState = InputState.RightSwipe;
                        }
                        else
                        {   //Left swipe
                            Debug.Log("Left Swipe");
                            leftSwipe = true;

                            myInputState = InputState.LeftSwipe;
                        }
                    }
                    else
                    {                    //the vertical movement is greater than the horizontal movement
                        if (lp.y > fp.y) //If the movement was up
                        {                //Up swipe
                            Debug.Log("Up Swipe");
                        }
                        else
                        {   //Down swipe
                            Debug.Log("Down Swipe");
                        }
                    }
                }
                else
                {   //It's a tap as the drag distance is less than 20% of the screen height
                    Debug.Log("Tap");
                    myInputState = InputState.Tap;
                }
            }
        }
    }