コード例 #1
0
    IEnumerator GameOverProcess()
    {
        planStage = PlanStage.GameOver;
        CameraShaking.instance.SwitchEffect(CameraEffect.None);
        //GameOverUI.SetActive (true);
        //scoreText.text = DataManager.instance.GetCurrentScore ()+"";
        if (drillMachine.GetRemainHP() > 0)
        {
            //gameoverText.text = "DONE";
            //ambientSound.Stop();
            //ambientSound.PlayOneShot(drillstop, 1);
            ambSound.StopAmbient();
            ambSound.PlayOneShot(1, 1);
            HintCtrl.instance.UpdateHintText("End of path reached");
        }
        else
        {
            //gameoverText.text = "BROKEN";
            //ambientSound.Stop();
            //ambientSound.PlayOneShot(drillbroken, 1);
            ambSound.StopAmbient();
            ambSound.PlayOneShot(2, 1);
            HintCtrl.instance.UpdateHintText("Bit wore out");
        }
        //DrillUI.SetActive (false);
        yield return(new WaitForSeconds(3));

        EndingFadeBlack.FadeIn();
    }
コード例 #2
0
    public void StartGame()
    {
        planStage = PlanStage.Planning;
        TimeUI.SetActive(true);
        HintBox.SetActive(true);
        InvokeRepeating("UpdateHintDisp", 0, 4);
        //plan prepare ambient sound
        //ambientSound.clip = standby;
        //ambientSound.Play ();
        //the total score of current level
        Transform layers         = GameObject.Find("/Layers").transform;
        int       scoreEntityNum = 0;

        foreach (Transform child in layers)
        {
            float layerScore = child.GetComponent <LayerProperty>().GetScoreFactor();
            if (layerScore > 0)
            {
                totalScore += layerScore;
                scoreEntityNum++;
            }
        }
        DataManager.instance.SetAvgScore(totalScore / scoreEntityNum);
        totalScore *= (3f / 4f);
        //totalScore += 1000;	//total score of stage 2
        DataManager.instance.SetTotalScore(totalScore);                 //save a copy to total score in DataManager
        DataManager.instance.score = 0;
    }
コード例 #3
0
 public void StartTutorial()
 {
     Debug.Log("start tutorial");
     if (planStage == PlanStage.Intro)
     {
         planStage = PlanStage.Tutorial;
         TutorialControl.instance.gameObject.SetActive(true);
     }
 }
コード例 #4
0
    IEnumerator PauseDrillImp(float duration)
    {
        planStage = PlanStage.DrillingPause;
        ambSound.StopAmbient();
        CameraShaking.instance.SwitchEffect(CameraEffect.None);
        yield return(new WaitForSeconds(duration));

        planStage = PlanStage.Drilling;
        ambSound.PlayAmbientLoop(2);
    }
コード例 #5
0
 public void StartDrillPhase()
 {
     planStage = PlanStage.Drilling;
     scoreDisp.gameObject.SetActive(true);
     HPBar.SetActive(true);
     CameraShaking.instance.SwitchEffect(CameraEffect.Shake);
     ambSound.PlayAmbientLoop(2);
     DepthMeterCtrl.instance.SetScaledDepth(0);
     //ambientSound.clip = drilling;
     //ambientSound.Play ();
 }
コード例 #6
0
    public void StartIntro()
    {
        planStage = PlanStage.Intro;
        GeologistUICtrl.instance.StartIntro();

        //put sample points on stage
        object[] samples = DataManager.instance.GetCollectedSamples();
        int      i       = 0;

        foreach (CoreSample sample in samples)
        {
            i++;
            GameObject point = Instantiate(CoreSamplePoints, sample.position, Quaternion.identity) as GameObject;
            point.GetComponentInChildren <TextMesh>().text = i + "";
        }
    }
コード例 #7
0
 //fade in fade out and display small battery animation
 void StartDrillingStage()
 {
     BlackFadeInOut.FadeIn();
     planStage = PlanStage.Loading;
 }
コード例 #8
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetButtonDown("Shelf_Right") || Input.GetButtonDown("Shelf_Left"))
        {
            SoundFXCtrl.instance.PlaySound(13, 1);
        }

        switch (planStage)
        {
        case PlanStage.Intro:
            if (Input.GetButtonDown("NextStage"))
            {
                GeologistUICtrl.instance.StopIntro();
            }
            break;

        case PlanStage.Tutorial:
            float horiAxisT = Input.GetAxis("Horizontal_Planpath");
            float vertAxisT = Input.GetAxis("Verticle_Planpath");

            if (TutorialControl.instance.GetCurrentIndex() != 0)
            {
                horiAxisT = 0;
                vertAxisT = 0;
            }

            if (TutorialControl.instance.GetCurrentIndex() != 5)
            {
                pencAnim.SetInteger("drawing", 0);
                if (linePoints.Count == 0)                      //choosing horizontal location mode
                {
                    if (horiAxisT < 0)
                    {
                        OilRig.position = Vector3.MoveTowards(OilRig.position, horizontalLeftBoundary, horiPlanSpeed * Time.deltaTime * Mathf.Abs(horiAxisT));
                    }
                    else if (horiAxisT > 0)
                    {
                        OilRig.position = Vector3.MoveTowards(OilRig.position, horizontalRightBoundary, horiPlanSpeed * Time.deltaTime * horiAxisT);
                    }
                    if (vertAxisT < -0.2f)
                    {
                        linePoints.Add(drawPointer.position);
                        pickPointDelay = DetectDelay;
                    }
                }
                else                                                            //free drawing mode
                {
                    if (Input.GetButton("Erase_Planpath") && TutorialControl.instance.GetCurrentIndex() == 3)
                    {
                        drawPointer.collider2D.enabled = true;
                        pencAnim.SetInteger("drawing", 2);
                        if (linePoints.Count > 0)
                        {
                            Vector3 moveTarget = linePoints[linePoints.Count - 1];
                            if (drawPointer.position != moveTarget)
                            {
                                Vector3 dir = moveTarget - drawPointer.position;
                                dir.z = 0;
                                drawPointer.rotation = Quaternion.LookRotation(Vector3.forward, dir);
                                drawPointer.position = Vector3.MoveTowards(drawPointer.position, moveTarget, 5 * speed * Time.deltaTime);
                                ambSound.PlayAmbientLoop(1);
                            }
                            else
                            {
                                linePoints.RemoveAt(linePoints.Count - 1);
                                ambSound.StopAmbient();
                            }
                        }
                    }
                    else
                    {
                        drawPointer.collider2D.enabled = false;
                        pencAnim.SetInteger("drawing", 1);
                        Vector3 targetDir = Vector3.zero;
                        if (linePoints.Count > 2)
                        {
                            targetDir.x = horiAxisT;
                        }
                        targetDir.y           = vertAxisT;
                        targetDir             = targetDir.normalized;
                        drawPointer.position -= drawPointer.up * speed * Time.deltaTime * Mathf.Clamp01(Vector3.Dot(targetDir, -drawPointer.up));
                        if (targetDir != drawPointer.up)
                        {
                            Vector3 dir = Vector3.RotateTowards(drawPointer.up, -targetDir, turnspeed * Time.deltaTime, 0);
                            dir.z = 0;
                            //drawPointer.up = dir;
                            drawPointer.rotation = Quaternion.LookRotation(Vector3.forward, dir);
                        }
                        Vector3 drawPosition = drawPointer.position;
                        if (drawPosition.y > groundlevel)
                        {
                            drawPosition.y = groundlevel;
                        }
                        if (drawPosition.y < bottomlevel)
                        {
                            drawPosition.y = bottomlevel;
                        }
                        if (drawPosition.x < horizontalLeftBoundary.x)
                        {
                            drawPosition.x = horizontalLeftBoundary.x;
                        }
                        if (drawPosition.x > horizontalRightBoundary.x)
                        {
                            drawPosition.x = horizontalRightBoundary.x;
                        }
                        drawPointer.position = drawPosition;

                        if (pickPointDelay > 0)
                        {
                            pickPointDelay -= Time.deltaTime;
                        }
                        else
                        {
                            pickPointDelay = DetectDelay;
                            if (linePoints[linePoints.Count - 1] != drawPosition)
                            {
                                linePoints.Add(drawPosition);
                                ambSound.PlayAmbientLoop(0);
                            }
                            else
                            {
                                ambSound.StopAmbient();
                            }
                        }

                        if (Input.GetButtonDown("PlaceMarker_Planpath") && TutorialControl.instance.GetCurrentIndex() == 1)
                        {
                            if (DataManager.instance.CheckLayerReveal(DataManager.instance.DetectLayerAtPosition(drawPosition)))
                            {
                                if (MarkerNum > 0)
                                {
                                    MarkerNum--;
                                    GameObject newmarker = Instantiate(marker, drawPosition, Quaternion.identity) as GameObject;
                                    newmarker.transform.parent = CurMarkers.transform;
                                    ambSound.PlayOneShot(3, 1);
                                }
                            }
                            else
                            {
                                informBox.DispInform("You can only put markers on places you have revealed", 2);
                                SoundFXCtrl.instance.PlaySound(6, 1);
                            }
                        }
                    }
                    if (linePoints.Count > 0)
                    {
                        trailPath.SetVertexCount(linePoints.Count);
                        lineLength = 0;
                        trailPath.SetPosition(0, linePoints[0]);
                        for (int i = 1; i < linePoints.Count; i++)
                        {
                            lineLength += (linePoints[i] - linePoints[i - 1]).magnitude;
                            trailPath.SetPosition(i, linePoints[i]);
                        }
                        lineMat.SetTextureScale("_MainTex", new Vector2(lineLength / 0.3f, 1));
                        offset -= Time.deltaTime * 1.5f;
                        lineMat.SetTextureOffset("_MainTex", new Vector2(offset, 1));
                    }
                }

                DepthMeterCtrl.instance.SetScaledDepth(1f - (drawPointer.position.y - bottomlevel) / (groundlevel - bottomlevel));
            }

            switch (TutorialControl.instance.GetCurrentIndex())
            {
            case 0:
                if (linePoints.Count > 10)
                {
                    TutorialControl.instance.DisplayNext();
                    if (!sendBtnLight1)
                    {
                        sendBtnLight1 = true;
                        SendData.SendToArduinoTutorial('e');
                    }
                }
                break;

            case 1:
                if (Input.GetButtonDown("PlaceMarker_Planpath"))
                {
                    TutorialControl.instance.DisplayNext();
                }
                break;

            case 3:
                if (linePoints.Count == 0)
                {
                    TutorialControl.instance.DisplayNext();
                    if (!sendBtnLight2)
                    {
                        sendBtnLight2 = true;
                        SendData.SendToArduinoTutorial('f');
                    }
                }
                break;

            case 4:
                if (Input.GetButtonDown("StartDrill_Planpath"))
                {
                    TutorialControl.instance.DisplayNext();
                }
                break;

            case 5:
                if (Input.GetButtonDown("Shelf_Right") || Input.GetButtonDown("Shelf_Left"))
                {
                    TutorialControl.instance.DisplayNext();
                    StartGame();
                    TutorialControl.instance.TotalFadeOut();
                }
                break;

            default:
                if (Input.GetButtonDown("StartDrill_Planpath") || Input.GetButtonDown("Erase_Planpath") ||
                    Input.GetButtonDown("PlaceMarker_Planpath") || horiAxisT != 0 || vertAxisT != 0)
                {
                    if (TutorialControl.instance.DisplayNext())
                    {
                        StartGame();
                        TutorialControl.instance.TotalFadeOut();
                    }
                }
                break;
            }

            if (Input.GetButtonDown("NextStage"))
            {
                StartGame();
                TutorialControl.instance.TotalFadeOut();
                if (!sendBtnLight1)
                {
                    sendBtnLight1 = true;
                    SendData.SendToArduinoTutorial('e');
                }
                if (!sendBtnLight2)
                {
                    sendBtnLight2 = true;
                    SendData.SendToArduinoTutorial('f');
                }
            }

            break;

        case PlanStage.Planning:
            float horiAxis = Input.GetAxis("Horizontal_Planpath");
            float vertAxis = Input.GetAxis("Verticle_Planpath");
            pencAnim.SetInteger("drawing", 0);
            if (linePoints.Count == 0)                  //choosing horizontal location mode
            {
                if (horiAxis < 0)
                {
                    OilRig.position = Vector3.MoveTowards(OilRig.position, horizontalLeftBoundary, horiPlanSpeed * Time.deltaTime * Mathf.Abs(horiAxis));
                }
                else if (horiAxis > 0)
                {
                    OilRig.position = Vector3.MoveTowards(OilRig.position, horizontalRightBoundary, horiPlanSpeed * Time.deltaTime * horiAxis);
                }
                if (vertAxis < -0.2f)
                {
                    linePoints.Add(drawPointer.position);
                    pickPointDelay = DetectDelay;
                }
            }
            else                                                        //free drawing mode
            {
                if (Input.GetButton("Erase_Planpath"))
                {
                    drawPointer.collider2D.enabled = true;
                    pencAnim.SetInteger("drawing", 2);
                    if (linePoints.Count > 0)
                    {
                        Vector3 moveTarget = linePoints[linePoints.Count - 1];
                        if (drawPointer.position != moveTarget)
                        {
                            Vector3 dir = moveTarget - drawPointer.position;
                            dir.z = 0;
                            drawPointer.rotation = Quaternion.LookRotation(Vector3.forward, dir);
                            drawPointer.position = Vector3.MoveTowards(drawPointer.position, moveTarget, 5 * speed * Time.deltaTime);
                            ambSound.PlayAmbientLoop(1);
                        }
                        else
                        {
                            linePoints.RemoveAt(linePoints.Count - 1);
                            ambSound.StopAmbient();
                        }
                    }
                }
                else
                {
                    drawPointer.collider2D.enabled = false;
                    pencAnim.SetInteger("drawing", 1);
                    Vector3 targetDir = Vector3.zero;
                    if (linePoints.Count > 2)
                    {
                        targetDir.x = horiAxis;
                    }
                    targetDir.y           = vertAxis;
                    targetDir             = targetDir.normalized;
                    drawPointer.position -= drawPointer.up * speed * Time.deltaTime * Mathf.Clamp01(Vector3.Dot(targetDir, -drawPointer.up));
                    if (targetDir != drawPointer.up)
                    {
                        Vector3 dir = Vector3.RotateTowards(drawPointer.up, -targetDir, turnspeed * Time.deltaTime, 0);
                        dir.z = 0;
                        //drawPointer.up = dir;
                        drawPointer.rotation = Quaternion.LookRotation(Vector3.forward, dir);
                    }
                    Vector3 drawPosition = drawPointer.position;
                    if (drawPosition.y > groundlevel)
                    {
                        drawPosition.y = groundlevel;
                    }
                    if (drawPosition.y < bottomlevel)
                    {
                        drawPosition.y = bottomlevel;
                    }
                    if (drawPosition.x < horizontalLeftBoundary.x)
                    {
                        drawPosition.x = horizontalLeftBoundary.x;
                    }
                    if (drawPosition.x > horizontalRightBoundary.x)
                    {
                        drawPosition.x = horizontalRightBoundary.x;
                    }
                    drawPointer.position = drawPosition;

                    if (pickPointDelay > 0)
                    {
                        pickPointDelay -= Time.deltaTime;
                    }
                    else
                    {
                        pickPointDelay = DetectDelay;
                        if (linePoints[linePoints.Count - 1] != drawPosition)
                        {
                            linePoints.Add(drawPosition);
                            ambSound.PlayAmbientLoop(0);
                        }
                        else
                        {
                            ambSound.StopAmbient();
                        }
                    }

                    if (Input.GetButtonDown("PlaceMarker_Planpath"))
                    {
                        if (DataManager.instance.CheckLayerReveal(DataManager.instance.DetectLayerAtPosition(drawPosition)))
                        {
                            if (MarkerNum > 0)
                            {
                                MarkerNum--;
                                GameObject newmarker = Instantiate(marker, drawPosition, Quaternion.identity) as GameObject;
                                newmarker.transform.parent = CurMarkers.transform;
                                ambSound.PlayOneShot(3, 1);
                            }
                        }
                        else
                        {
                            informBox.DispInform("You can only put markers on places you have revealed", 2);
                            SoundFXCtrl.instance.PlaySound(6, 1);
                        }
                    }
                }
                if (linePoints.Count > 0)
                {
                    trailPath.SetVertexCount(linePoints.Count);
                    lineLength = 0;
                    trailPath.SetPosition(0, linePoints[0]);
                    for (int i = 1; i < linePoints.Count; i++)
                    {
                        lineLength += (linePoints[i] - linePoints[i - 1]).magnitude;
                        trailPath.SetPosition(i, linePoints[i]);
                    }
                    lineMat.SetTextureScale("_MainTex", new Vector2(lineLength / 0.3f, 1));
                    offset -= Time.deltaTime * 1.5f;
                    lineMat.SetTextureOffset("_MainTex", new Vector2(offset, 1));
                }
            }

            DepthMeterCtrl.instance.SetScaledDepth(1f - (drawPointer.position.y - bottomlevel) / (groundlevel - bottomlevel));

            if (Input.GetButtonDown("StartDrill_Planpath"))
            {
                ambSound.StopAmbient();
                if (MarkerNum < 5)
                {
                    if (MarkerNum == 0)
                    {
                        optionBox.DispOptionBox("Are you sure to start drilling?");
                    }
                    else
                    {
                        optionBox.DispOptionBox("You have not used all five markers, Are you sure to start drilling?");
                    }
                    planStage = PlanStage.BeforeDrill;
                    ambSound.PlayOneShot(3, 1);
                }
                else
                {
                    informBox.DispInform("Remember to place markers on places you want to collect resources", 2);
                    SoundFXCtrl.instance.PlaySound(6, 1);
                }
            }
            markerCountDisp.text = MarkerNum + " / " + 5;
            break;

        case PlanStage.BeforeDrill:
            float holsel = Input.GetAxis("Horizontal_Planpath");
            if (holsel < 0)
            {
                if (optionBox.ChangeSelection(0))
                {
                    ambSound.PlayOneShot(3, 1);
                }
            }
            else if (holsel > 0)
            {
                if (optionBox.ChangeSelection(1))
                {
                    ambSound.PlayOneShot(3, 1);
                }
            }
            if (Input.GetButtonDown("StartDrill_Planpath"))
            {
                switch (optionBox.GetCurrentSelection())
                {
                case 0:
                    SoundFXCtrl.instance.PlaySound(11, 1);
                    StartDrillingStage();
                    break;

                case 1:
                    SoundFXCtrl.instance.PlaySound(12, 1);
                    planStage = PlanStage.Planning;
                    break;
                }
                optionBox.CloseOptionBox();
                //ambSound.PlayOneShot(3, 1);
            }
            break;

        case PlanStage.Drilling:

            if (curMoveTarget < linePoints.Count)
            {
                Vector3 target = linePoints[curMoveTarget];
                target.z = Drill.position.z;
                if (Drill.position != target)
                {
                    Vector3 dir = Drill.position - target;
                    dir.z = 0;

                    if (dir.magnitude > 0.01f)
                    {
                        drillObject.rotation = Quaternion.LookRotation(Vector3.forward, dir);
                    }
                    //Drill.up = dir;

                    Drill.position = Vector3.MoveTowards(Drill.position, target, drillMachine.GetMoveSpeed() * Time.deltaTime);
                }
                else
                {
                    curMoveTarget++;
                }

                //update trail of drill
                if (pickPointDelay > 0)
                {
                    pickPointDelay -= Time.deltaTime;
                }
                else
                {
                    pickPointDelay = DetectDelay;
                    if (drillObject.position.y < groundlevel)
                    {
                        drillTrailPoints.Add(Drill.position);
                        drillTrail.SetVertexCount(drillTrailPoints.Count);
                        drillTrail.SetPosition(drillTrailPoints.Count - 1, drillObject.position);
                    }
                }
            }
            else
            {
                GameOver();
            }


            //hpDisp.text = (int)DrillMachine.instance.GetRemainHP()+"";

            float scoreFactor = DataManager.instance.GetCurrentScore() / totalScore;
            //Vector3 batteryLevelScale = BatteryLevel.localScale;
            //batteryLevelScale.x = Mathf.Clamp01(scoreFactor);
            //BatteryLevel.localScale = batteryLevelScale;
            //BatteryFillmentSprite.color = Color.Lerp(Color.red, Color.green, scoreFactor);
            //BatteryCtrl.UpdateCurrentLevel(Mathf.Clamp01(scoreFactor));
            batteryCtrl.UpdateCurrentLevel(Mathf.Clamp01(scoreFactor));
            currentFinal = Mathf.MoveTowards(currentFinal, scoreFactor, transitSpeed);
            int finalScore = (int)(currentFinal * 7000000);
            scoreDisp.text = string.Format("{0:n0}", finalScore) + " kWh";
            //scoreDisp.text = string.Format("{0:0.0}", scoreFactor*100)+"%";
            DepthMeterCtrl.instance.SetScaledDepth(1f - (Drill.position.y - bottomlevel) / (groundlevel - bottomlevel));

            break;
        }
    }
コード例 #9
0
 void Awake()
 {
     instance  = this;
     planStage = PlanStage.Loading;
 }