// --------- Finger taps
    void FingerGestures_OnFingerTap( int fingerIndex, Vector2 fingerPos, int tapCount )
    {
        GameObject selection=PickObject(fingerPos);
        if(!enableTouchesFlag || selection==null )
            return;
        //	Debug.Log("in finger tap...");

        if(selection.name=="pg_olly" && jumpCount==0){
            int _tickle = Random.Range(1,4);
            soundManager.currentClips=new System.Collections.Generic.List<UnityEngine.AudioClip>();
            soundManager.playInstructionSound(new string[]{PG_Constants._soundclipPath + PG_Constants._tickle + string.Format("olly_tap_{0}" , _tickle)});

            if(ollyAnimationsSR.ollyState != ollyAnimationStates.olly_tickle) {
                PG_OllyAnimations.changeTexture = true;
            }
            ollyAnimationsSR.ollyState      = ollyAnimationStates.olly_tickle;
           	return;
        }else if(selection.name=="bubble_referent" || selection.name=="cross_tick_sign" || selection.name=="referent_hint" || selection.name=="referent_shape"){
             soundManager.currentClips=new System.Collections.Generic.List<UnityEngine.AudioClip>();
             soundManager.playInstructionSound(questionInstructionVO);

        }
        else if(selection.name=="pg_icky"){
            int _tickle = Random.Range(1,5);
            soundManager.currentClips = new System.Collections.Generic.List<UnityEngine.AudioClip>();
            soundManager.playInstructionSound(new string[]{PG_Constants._soundclipPath + PG_Constants._tickle + string.Format("icky_tickle_{0}" , _tickle)});

            if(ickyAnimationsSR.ickyState != ickyAnimStates.icky_tickle) {
                PG_IckyAnimations.changeTexture = true;
            }
            ickyAnimationsSR.ickyState      = ickyAnimStates.icky_tickle;
           	return;
        }

        if (selection!=null){
            shapeStatController=selection.GetComponent<PG_ShapeStatController>();
            //StopAllCoroutines();
        }
        if(shapeStatController!=null && shapeStatController.getAnswerShape() && dragFingerIndex==-1){
            dragFingerIndex=fingerIndex;
            decideForTappedDraggedShape(selection);

            if((int)currentMode == (int)GameModes.mode_counting){
            countModeShapeNumber++;
            GameObject countingNumber = GameObject.Instantiate(GO_countingNumber) as GameObject;
                countingNumber.transform.parent = camera.transform;
            if(countingNumber!=null)
            countingPOPUPController 	= countingNumber.GetComponent<PG_CountingPopUpController>();
            if(countingPOPUPController!=null){
                    countingPOPUPController.showCountingNumber(countModeShapeNumber);
                }
            string	shapeClipName = null;
            string shapeName	  = pgDataManager.getQuestionTitle();
            if(countModeShapeNumber==1)
            shapeClipName = "word_"+ shapeName.ToLower();
            else shapeClipName = "word_"+shapeName.ToLower()+"s";
            soundManager.currentClips = new System.Collections.Generic.List<UnityEngine.AudioClip>();
            soundManager.playInstructionSound(new string[]{PG_Constants._soundclipPath+ PG_Constants._counting + string.Format("number_{0}",countModeShapeNumber),
            PG_Constants._soundclipPath+ PG_Constants._basicShapes + shapeClipName});

            }
            else{
                soundManager.currentClips = new System.Collections.Generic.List<UnityEngine.AudioClip>();
                soundManager.playSucess();
            }
            //StartCoroutine(playQuestionInstructionVO(10F));

        }
        else if(shapeStatController!=null && !shapeStatController.getAnswerShape() && dragFingerIndex==-1){

                    shapeStatController.shapeWrongTapAnimation();  // start wrong animation with VO
                    totalWrongAttempts++;
                    //StartCoroutine(playQuestionInstructionVO(5F));
                   if(ollyAnimationsSR.ollyState!=ollyAnimationStates.olly_wrongAnswer){
                    PG_OllyAnimations.changeTexture = true;
                    ollyAnimationsSR.ollyLastStat = ollyAnimationsSR.ollyState;
                    }
                    ollyAnimationsSR.ollyState = ollyAnimationStates.olly_wrongAnswer;
                    soundManager.currentClips = new System.Collections.Generic.List<UnityEngine.AudioClip>();
                    soundManager.playWrongSound();
                    cross_tick_sign.transform.renderer.material.mainTexture=Resources.Load(PG_Constants._wrongTick) as Texture;
                    cross_tick_sign.transform.renderer.enabled=true;
                    StartCoroutine(unhideCrossSign(0.5F));
                    if(dragFingerIndex==fingerIndex && isRightShapeDragged && answerShapeDrag !=null){
                    decideForTappedDraggedShape(answerShapeDrag);

        }

        //				shapeStatController.shapeWrongTapAnimation();  // start wrong animation with VO
        //			    totalWrongAttempts++;
        //				//StartCoroutine(playQuestionInstructionVO(5F));
        //			 if(ollyAnimationsSR.ollyState!=ollyAnimationStates.olly_wrongAnswer){
        //				PG_OllyAnimations.changeTexture = true;
        //				ollyAnimationsSR.ollyLastStat = ollyAnimationsSR.ollyState;
        //				}
        //			ollyAnimationsSR.ollyState = ollyAnimationStates.olly_wrongAnswer;
        //			soundManager.currentClips = new System.Collections.Generic.List<UnityEngine.AudioClip>();
        //			soundManager.playWrongSound();
        //			cross_tick_sign.transform.renderer.material.mainTexture=Resources.Load(PG_Constants._wrongTick) as Texture;
        //			cross_tick_sign.transform.renderer.enabled=true;
        //			//StartCoroutine(unhideCrossSign(0.5F));
        }
    }
    // ----- Decide if tapped/dragged shape is correct?, play respective animations and decide to load next question or next level?
    private void decideForTappedDraggedShape( GameObject selection)
    {
        //Debug.Log("Decide for dragged shape");
        ArrayList responseList=new ArrayList();
        bool allShapesOnCurrentScreenPlayed;

        if(selection!=null)
         {
            //isUserPlayedTheQuestion = true;
            totalAttempts++;
            shapeStatController=selection.GetComponent<PG_ShapeStatController>();

            if(shapeStatController!=null && shapeStatController.getAnswerShape())
             {
                hideShadow(selection);
                jumpCount++;
            if(jumpCount==1)
                shapeStatController.isFirstShape = true;
            else shapeStatController.isFirstShape = false;
                cross_tick_sign.transform.renderer.material.mainTexture=Resources.Load(PG_Constants._correctTick) as Texture;
                cross_tick_sign.transform.renderer.enabled=true;
                enableTouchesFlag = false;

                totalCorrects++;
                shapesTappedIndex++;
                if(gameMode==(int)GameModes.mode_counting)
                    responseList=islandControllerSR.ReplaceEmptyLandMassesWithFilledOne(shapesControllerSR.getQSpriteIndices().Count);
                else
                    responseList=islandControllerSR.ReplaceEmptyLandMassesWithFilledOne(pgDataManager.getAnswersListCount());

                if(responseList.Count>=2)
                allShapesOnCurrentScreenPlayed=(bool)responseList[1];
                else allShapesOnCurrentScreenPlayed=false;
                //shapesControllerSR.shapeCorrectTapAnimation(selection,(GameObject)responseList[0]);

                shapeStatController.isLastShape = allShapesOnCurrentScreenPlayed;
                shapeStatController.shapeCorrectTapAnimation((GameObject)responseList[0]);

                StartCoroutine(hideReferentBubble(0.2F));
                if(allShapesOnCurrentScreenPlayed){
                 AGGameState.incrementStarCount(); // increment stars
                 enableTouchesFlag = false;
                 StartCoroutine(ollyPondCrossAnimation(1.8F));

                }

            }

        }

        isUserPlayedTheQuestion =false;
    }
    // ------ Finger drag begin
    void FingerGestures_OnFingerDragBegin( int fingerIndex, Vector2 fingerPos, Vector2 startPos )
    {
        GameObject selection = PickObject(fingerPos);

        if(!enableTouchesFlag || selection==null )
            return;
        Debug.Log("in drag begin...");

        if (selection!=null){
            shapeStatController=selection.GetComponent<PG_ShapeStatController>();
            isUserPlayedTheQuestion = true;
            StopAllCoroutines();
        }
        if(shapeStatController!=null && shapeStatController.getAnswerShape() && dragFingerIndex==-1){
                dragFingerIndex=fingerIndex;
                answerShapeDrag=selection;
                isRightShapeDragged=true;
                hideShadow(selection);

            if((int)currentMode == (int)GameModes.mode_counting){
            countModeShapeNumber++;
            GameObject countingNumber = GameObject.Instantiate(GO_countingNumber) as GameObject;
                countingNumber.transform.parent = camera.transform;
            if(countingNumber!=null)
            countingPOPUPController 	= countingNumber.GetComponent<PG_CountingPopUpController>();
            if(countingPOPUPController!=null){
               countingPOPUPController.showCountingNumber(countModeShapeNumber);
            }
            string	shapeClipName = null;
            string shapeName	  = pgDataManager.getQuestionTitle();
            if(countModeShapeNumber==1)
            shapeClipName = "word_"+ shapeName.ToLower();
            else shapeClipName = "word_"+shapeName.ToLower()+"s";
            soundManager.currentClips = new System.Collections.Generic.List<UnityEngine.AudioClip>();
            soundManager.playInstructionSound(new string[]{PG_Constants._soundclipPath+ PG_Constants._counting + string.Format("number_{0}",countModeShapeNumber),
            PG_Constants._soundclipPath+ PG_Constants._basicShapes + shapeClipName});

            }
            else{
                soundManager.currentClips = new System.Collections.Generic.List<UnityEngine.AudioClip>();
                soundManager.playSucess();
            }
            StartCoroutine(playQuestionInstructionVO(5F));

        }
        else if(shapeStatController!=null && !shapeStatController.getAnswerShape() && dragFingerIndex==-1){
                    shapeStatController.shapeWrongTapAnimation();  // start wrong animation with VO
                    PG_OllyAnimations.changeTexture = true;
                    totalWrongAttempts++;
                    StartCoroutine(playQuestionInstructionVO(5F));
                   if(ollyAnimationsSR.ollyState!=ollyAnimationStates.olly_wrongAnswer){
                    ollyAnimationsSR.ollyLastStat = ollyAnimationsSR.ollyState;
                    }
                    ollyAnimationsSR.ollyState = ollyAnimationStates.olly_wrongAnswer;
                    soundManager.currentClips = new System.Collections.Generic.List<UnityEngine.AudioClip>();
                    soundManager.playWrongSound();
            cross_tick_sign.transform.renderer.material.mainTexture=Resources.Load(PG_Constants._wrongTick) as Texture;
                    cross_tick_sign.transform.renderer.enabled=true;
                    StartCoroutine(unhideCrossSign(0.5F));
        if(dragFingerIndex==fingerIndex && isRightShapeDragged && answerShapeDrag !=null){
                decideForTappedDraggedShape(answerShapeDrag);

        }
        }
    }
示例#4
0
    // ----- Decide if tapped/dragged shape is correct?, play respective animations and decide to load next question or next level?

    private void decideForTappedDraggedShape(GameObject selection)
    {
        //Debug.Log("Decide for dragged shape");
        ArrayList responseList = new ArrayList();
        bool      allShapesOnCurrentScreenPlayed;


        if (selection != null)
        {
            //isUserPlayedTheQuestion = true;
            totalAttempts++;
            shapeStatController = selection.GetComponent <PG_ShapeStatController>();

            if (shapeStatController != null && shapeStatController.getAnswerShape())
            {
                hideShadow(selection);
                jumpCount++;
                if (jumpCount == 1)
                {
                    shapeStatController.isFirstShape = true;
                }
                else
                {
                    shapeStatController.isFirstShape = false;
                }
                cross_tick_sign.transform.renderer.material.mainTexture = Resources.Load(PG_Constants._correctTick) as Texture;
                cross_tick_sign.transform.renderer.enabled = true;
                enableTouchesFlag = false;

                totalCorrects++;
                shapesTappedIndex++;
                if (gameMode == (int)GameModes.mode_counting)
                {
                    responseList = islandControllerSR.ReplaceEmptyLandMassesWithFilledOne(shapesControllerSR.getQSpriteIndices().Count);
                }
                else
                {
                    responseList = islandControllerSR.ReplaceEmptyLandMassesWithFilledOne(pgDataManager.getAnswersListCount());
                }

                if (responseList.Count >= 2)
                {
                    allShapesOnCurrentScreenPlayed = (bool)responseList[1];
                }
                else
                {
                    allShapesOnCurrentScreenPlayed = false;
                }
                //shapesControllerSR.shapeCorrectTapAnimation(selection,(GameObject)responseList[0]);

                shapeStatController.isLastShape = allShapesOnCurrentScreenPlayed;
                shapeStatController.shapeCorrectTapAnimation((GameObject)responseList[0]);


                StartCoroutine(hideReferentBubble(0.2F));
                if (allShapesOnCurrentScreenPlayed)
                {
                    AGGameState.incrementStarCount();              // increment stars
                    enableTouchesFlag = false;
                    StartCoroutine(ollyPondCrossAnimation(1.8F));
                }
            }
        }

        isUserPlayedTheQuestion = false;
    }
示例#5
0
    // ------ Finger drag begin
    void FingerGestures_OnFingerDragBegin(int fingerIndex, Vector2 fingerPos, Vector2 startPos)
    {
        GameObject selection = PickObject(fingerPos);

        if (!enableTouchesFlag || selection == null)
        {
            return;
        }
        Debug.Log("in drag begin...");

        if (selection != null)
        {
            shapeStatController     = selection.GetComponent <PG_ShapeStatController>();
            isUserPlayedTheQuestion = true;
            StopAllCoroutines();
        }
        if (shapeStatController != null && shapeStatController.getAnswerShape() && dragFingerIndex == -1)
        {
            dragFingerIndex     = fingerIndex;
            answerShapeDrag     = selection;
            isRightShapeDragged = true;
            hideShadow(selection);

            if ((int)currentMode == (int)GameModes.mode_counting)
            {
                countModeShapeNumber++;
                GameObject countingNumber = GameObject.Instantiate(GO_countingNumber) as GameObject;
                countingNumber.transform.parent = camera.transform;
                if (countingNumber != null)
                {
                    countingPOPUPController = countingNumber.GetComponent <PG_CountingPopUpController>();
                }
                if (countingPOPUPController != null)
                {
                    countingPOPUPController.showCountingNumber(countModeShapeNumber);
                }
                string shapeClipName = null;
                string shapeName     = pgDataManager.getQuestionTitle();
                if (countModeShapeNumber == 1)
                {
                    shapeClipName = "word_" + shapeName.ToLower();
                }
                else
                {
                    shapeClipName = "word_" + shapeName.ToLower() + "s";
                }
                soundManager.currentClips = new System.Collections.Generic.List <UnityEngine.AudioClip>();
                soundManager.playInstructionSound(new string[] { PG_Constants._soundclipPath + PG_Constants._counting + string.Format("number_{0}", countModeShapeNumber),
                                                                 PG_Constants._soundclipPath + PG_Constants._basicShapes + shapeClipName });
            }
            else
            {
                soundManager.currentClips = new System.Collections.Generic.List <UnityEngine.AudioClip>();
                soundManager.playSucess();
            }
            StartCoroutine(playQuestionInstructionVO(5F));
        }
        else if (shapeStatController != null && !shapeStatController.getAnswerShape() && dragFingerIndex == -1)
        {
            shapeStatController.shapeWrongTapAnimation();                              // start wrong animation with VO
            PG_OllyAnimations.changeTexture = true;
            totalWrongAttempts++;
            StartCoroutine(playQuestionInstructionVO(5F));
            if (ollyAnimationsSR.ollyState != ollyAnimationStates.olly_wrongAnswer)
            {
                ollyAnimationsSR.ollyLastStat = ollyAnimationsSR.ollyState;
            }
            ollyAnimationsSR.ollyState = ollyAnimationStates.olly_wrongAnswer;
            soundManager.currentClips  = new System.Collections.Generic.List <UnityEngine.AudioClip>();
            soundManager.playWrongSound();
            cross_tick_sign.transform.renderer.material.mainTexture = Resources.Load(PG_Constants._wrongTick) as Texture;
            cross_tick_sign.transform.renderer.enabled = true;
            StartCoroutine(unhideCrossSign(0.5F));
            if (dragFingerIndex == fingerIndex && isRightShapeDragged && answerShapeDrag != null)
            {
                decideForTappedDraggedShape(answerShapeDrag);
            }
        }
    }
示例#6
0
    // --------- Finger taps
    void FingerGestures_OnFingerTap(int fingerIndex, Vector2 fingerPos, int tapCount)
    {
        GameObject selection = PickObject(fingerPos);

        if (!enableTouchesFlag || selection == null)
        {
            return;
        }
        //	Debug.Log("in finger tap...");


        if (selection.name == "pg_olly" && jumpCount == 0)
        {
            int _tickle = Random.Range(1, 4);
            soundManager.currentClips = new System.Collections.Generic.List <UnityEngine.AudioClip>();
            soundManager.playInstructionSound(new string[] { PG_Constants._soundclipPath + PG_Constants._tickle + string.Format("olly_tap_{0}", _tickle) });

            if (ollyAnimationsSR.ollyState != ollyAnimationStates.olly_tickle)
            {
                PG_OllyAnimations.changeTexture = true;
            }
            ollyAnimationsSR.ollyState = ollyAnimationStates.olly_tickle;
            return;
        }
        else if (selection.name == "bubble_referent" || selection.name == "cross_tick_sign" || selection.name == "referent_hint" || selection.name == "referent_shape")
        {
            soundManager.currentClips = new System.Collections.Generic.List <UnityEngine.AudioClip>();
            soundManager.playInstructionSound(questionInstructionVO);
        }
        else if (selection.name == "pg_icky")
        {
            int _tickle = Random.Range(1, 5);
            soundManager.currentClips = new System.Collections.Generic.List <UnityEngine.AudioClip>();
            soundManager.playInstructionSound(new string[] { PG_Constants._soundclipPath + PG_Constants._tickle + string.Format("icky_tickle_{0}", _tickle) });

            if (ickyAnimationsSR.ickyState != ickyAnimStates.icky_tickle)
            {
                PG_IckyAnimations.changeTexture = true;
            }
            ickyAnimationsSR.ickyState = ickyAnimStates.icky_tickle;
            return;
        }

        if (selection != null)
        {
            shapeStatController = selection.GetComponent <PG_ShapeStatController>();
            //StopAllCoroutines();
        }
        if (shapeStatController != null && shapeStatController.getAnswerShape() && dragFingerIndex == -1)
        {
            dragFingerIndex = fingerIndex;
            decideForTappedDraggedShape(selection);

            if ((int)currentMode == (int)GameModes.mode_counting)
            {
                countModeShapeNumber++;
                GameObject countingNumber = GameObject.Instantiate(GO_countingNumber) as GameObject;
                countingNumber.transform.parent = camera.transform;
                if (countingNumber != null)
                {
                    countingPOPUPController = countingNumber.GetComponent <PG_CountingPopUpController>();
                }
                if (countingPOPUPController != null)
                {
                    countingPOPUPController.showCountingNumber(countModeShapeNumber);
                }
                string shapeClipName = null;
                string shapeName     = pgDataManager.getQuestionTitle();
                if (countModeShapeNumber == 1)
                {
                    shapeClipName = "word_" + shapeName.ToLower();
                }
                else
                {
                    shapeClipName = "word_" + shapeName.ToLower() + "s";
                }
                soundManager.currentClips = new System.Collections.Generic.List <UnityEngine.AudioClip>();
                soundManager.playInstructionSound(new string[] { PG_Constants._soundclipPath + PG_Constants._counting + string.Format("number_{0}", countModeShapeNumber),
                                                                 PG_Constants._soundclipPath + PG_Constants._basicShapes + shapeClipName });
            }
            else
            {
                soundManager.currentClips = new System.Collections.Generic.List <UnityEngine.AudioClip>();
                soundManager.playSucess();
            }
            //StartCoroutine(playQuestionInstructionVO(10F));
        }
        else if (shapeStatController != null && !shapeStatController.getAnswerShape() && dragFingerIndex == -1)
        {
            shapeStatController.shapeWrongTapAnimation();                              // start wrong animation with VO
            totalWrongAttempts++;
            //StartCoroutine(playQuestionInstructionVO(5F));
            if (ollyAnimationsSR.ollyState != ollyAnimationStates.olly_wrongAnswer)
            {
                PG_OllyAnimations.changeTexture = true;
                ollyAnimationsSR.ollyLastStat   = ollyAnimationsSR.ollyState;
            }
            ollyAnimationsSR.ollyState = ollyAnimationStates.olly_wrongAnswer;
            soundManager.currentClips  = new System.Collections.Generic.List <UnityEngine.AudioClip>();
            soundManager.playWrongSound();
            cross_tick_sign.transform.renderer.material.mainTexture = Resources.Load(PG_Constants._wrongTick) as Texture;
            cross_tick_sign.transform.renderer.enabled = true;
            StartCoroutine(unhideCrossSign(0.5F));
            if (dragFingerIndex == fingerIndex && isRightShapeDragged && answerShapeDrag != null)
            {
                decideForTappedDraggedShape(answerShapeDrag);
            }


//				shapeStatController.shapeWrongTapAnimation();  // start wrong animation with VO
//			    totalWrongAttempts++;
//				//StartCoroutine(playQuestionInstructionVO(5F));
//			 if(ollyAnimationsSR.ollyState!=ollyAnimationStates.olly_wrongAnswer){
//				PG_OllyAnimations.changeTexture = true;
//				ollyAnimationsSR.ollyLastStat = ollyAnimationsSR.ollyState;
//				}
//			ollyAnimationsSR.ollyState = ollyAnimationStates.olly_wrongAnswer;
//			soundManager.currentClips = new System.Collections.Generic.List<UnityEngine.AudioClip>();
//			soundManager.playWrongSound();
//			cross_tick_sign.transform.renderer.material.mainTexture=Resources.Load(PG_Constants._wrongTick) as Texture;
//			cross_tick_sign.transform.renderer.enabled=true;
//			//StartCoroutine(unhideCrossSign(0.5F));
        }
    }
    // Place sprites in the scene
    private void placeSpritesInScene()
    {
        // ------- Get the first shape container
        shapeContainer_1=GameObject.FindGameObjectWithTag("pg_shapes_container_1");

        // ------- Get the second shape container
        shapeContainer_2=GameObject.FindGameObjectWithTag("pg_shapes_container_2");
        transform.localScale=new Vector3(1.0F,1.0F,1.0F);
        shapesCountForContainer_1=0;
        shapesCountForContainer_2=0;
        shapeConainer1QuickSand =0;
        shapeConainer2QuickSand=0;
        xPositon=100F;
        xPosition_2=100F;
        int shapesCount=qSpriteIndices.Count;

        //	print("Shapes Count:  "+shapesCount);
        for(int i=0;i<shapesCount;i++)
        {
            int qIndex=(int)qSpriteIndices[i];
            GameObject sObject=Instantiate(shapesToDisplay[qIndex]) as GameObject;
            shapesToShowOnScreen.Add(sObject);
            if(checkIfAnswer(qIndex)){
                int childCount=0;

                Transform [] childs = sObject.GetComponentsInChildren<Transform>();
                Transform firstChild = childs[1];

                GameObject shape = firstChild.gameObject;
                shapeStatController=shape.GetComponent<PG_ShapeStatController>();
                shapeStatController.setAnswerShape(true);

            }

        if(shapesCount>4){
            if(i<=shapesCount/2-1){
                    sObject.transform.parent=shapeContainer_1.transform;
                    sObject.transform.localPosition=new Vector3(xPositon,0F, -sObject.transform.localPosition.z);
                    xPositon+=incrementInXIndex;
                    shapesCountForContainer_1++;
            }

            else if(i>shapesCount/2-1){
                    sObject.transform.parent=shapeContainer_2.transform;
                    sObject.transform.localPosition=new Vector3(xPosition_2,0F, -sObject.transform.localPosition.z);
                    xPosition_2+=incrementInXIndex;
                    shapesCountForContainer_2++;
            }
        }
        else{
                    sObject.transform.parent=shapeContainer_1.transform;
                    sObject.transform.localPosition=new Vector3(xPositon,0F, -sObject.transform.localPosition.z);
                    xPositon+=incrementInXIndex;
                    shapesCountForContainer_1++;
        }

        }

            float contentWidth_1 =shapesCountForContainer_1*200.0f/ 2.0f;
            float contentWidth_2 =shapesCountForContainer_2*200.0f/ 2.0f;
            shapeContainer_1.transform.localPosition=new Vector3(-contentWidth_1 , 80F , -shapeContainer_1.transform.localPosition.z);

        if(shapesCountForContainer_1 > 0 && shapesCountForContainer_2 > 0)
        {
            //print ("inside ....");
            //transform.localScale=new Vector3(0.7F,0.7F,1F);
            //shapeContainer_1.transform.localScale=new Vector3(0.9F,0.9F,1F);
            //shapeContainer_2.transform.localScale=new Vector3(0.9F,0.9F,1F);
            shapeContainer_2.transform.localPosition=new Vector3(-contentWidth_2 , -80F , -shapeContainer_2.transform.localPosition.z);
        }
        else
        {
            Vector3 pos=shapeContainer_1.transform.position;
            pos.y -= 80F;
            shapeContainer_1.transform.transform.position=pos;
        }
    }
示例#8
0
    // Place sprites in the scene
    private void placeSpritesInScene()
    {
        // ------- Get the first shape container
        shapeContainer_1 = GameObject.FindGameObjectWithTag("pg_shapes_container_1");

        // ------- Get the second shape container
        shapeContainer_2          = GameObject.FindGameObjectWithTag("pg_shapes_container_2");
        transform.localScale      = new Vector3(1.0F, 1.0F, 1.0F);
        shapesCountForContainer_1 = 0;
        shapesCountForContainer_2 = 0;
        shapeConainer1QuickSand   = 0;
        shapeConainer2QuickSand   = 0;
        xPositon    = 100F;
        xPosition_2 = 100F;
        int shapesCount = qSpriteIndices.Count;

        //	print("Shapes Count:  "+shapesCount);
        for (int i = 0; i < shapesCount; i++)
        {
            int        qIndex  = (int)qSpriteIndices[i];
            GameObject sObject = Instantiate(shapesToDisplay[qIndex]) as GameObject;
            shapesToShowOnScreen.Add(sObject);
            if (checkIfAnswer(qIndex))
            {
                int childCount = 0;

                Transform [] childs     = sObject.GetComponentsInChildren <Transform>();
                Transform    firstChild = childs[1];

                GameObject shape = firstChild.gameObject;
                shapeStatController = shape.GetComponent <PG_ShapeStatController>();
                shapeStatController.setAnswerShape(true);
            }


            if (shapesCount > 4)
            {
                if (i <= shapesCount / 2 - 1)
                {
                    sObject.transform.parent        = shapeContainer_1.transform;
                    sObject.transform.localPosition = new Vector3(xPositon, 0F, -sObject.transform.localPosition.z);
                    xPositon += incrementInXIndex;
                    shapesCountForContainer_1++;
                }

                else if (i > shapesCount / 2 - 1)
                {
                    sObject.transform.parent        = shapeContainer_2.transform;
                    sObject.transform.localPosition = new Vector3(xPosition_2, 0F, -sObject.transform.localPosition.z);
                    xPosition_2 += incrementInXIndex;
                    shapesCountForContainer_2++;
                }
            }
            else
            {
                sObject.transform.parent        = shapeContainer_1.transform;
                sObject.transform.localPosition = new Vector3(xPositon, 0F, -sObject.transform.localPosition.z);
                xPositon += incrementInXIndex;
                shapesCountForContainer_1++;
            }
        }

        float contentWidth_1 = shapesCountForContainer_1 * 200.0f / 2.0f;
        float contentWidth_2 = shapesCountForContainer_2 * 200.0f / 2.0f;

        shapeContainer_1.transform.localPosition = new Vector3(-contentWidth_1, 80F, -shapeContainer_1.transform.localPosition.z);



        if (shapesCountForContainer_1 > 0 && shapesCountForContainer_2 > 0)
        {
            //print ("inside ....");
            //transform.localScale=new Vector3(0.7F,0.7F,1F);
            //shapeContainer_1.transform.localScale=new Vector3(0.9F,0.9F,1F);
            //shapeContainer_2.transform.localScale=new Vector3(0.9F,0.9F,1F);
            shapeContainer_2.transform.localPosition = new Vector3(-contentWidth_2, -80F, -shapeContainer_2.transform.localPosition.z);
        }
        else
        {
            Vector3 pos = shapeContainer_1.transform.position;
            pos.y -= 80F;
            shapeContainer_1.transform.transform.position = pos;
        }
    }