示例#1
0
 public void detectedMouseandMovetheSeletctedCar()
 {
     //continuly move if in belt
     if (myMap.isbeltOn() && isBelt())
     {
         if (beltMoveTime % 15 == 0)
         {
             determineMove(+1, 0);
         }
         beltMoveTime += 1;
     }// Otherwise use mouse to drag
     if (Input.GetMouseButton(0) && myGameManager.getSelectedCar() != null && myGameManager.getSelectedCar() == gameObject)
     {
         Vector3 curScreenPoint = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0);
         Vector3 curPosition    = Camera.main.ScreenToWorldPoint(curScreenPoint);
         //move the car to mouse's new position
         movetheSelectedCarOrTrain(curPosition);
     }
 }
示例#2
0
    void Update()
    {
        setdriverPosition();

        // Waiting for Game Finish
        if (finishGame)
        {
            setCarObjectStatus(false);
            return;
        }

        // Waiting for Store Finish
        if (!destroyStore)//Inside Store
        {
            return;
        }
        else
        {
            if (dialogueManager)
            {
                (dialogueManager.GetComponent("DialogueManager") as MonoBehaviour).enabled = true;
            }
            setCarObjectStatus(true);
        }



        // Waiting for Instruction Dialogue Finish
        if (myDia && !myDia.getFinishFlag())
        {
            return;
        }
        (mapManager.GetComponent("MapCreater") as MonoBehaviour).enabled = true;

        // Rotate Belt if need
        if (myMap.isbeltOn())
        {
            List <GameObject> belts = myMap.getBelts();
            for (int i = 0; i < belts.Count; i++)
            {
                // Image image1 = belts[i].transform.Find("image1").gameObject.GetComponent<Image>();
                // Image image2 = belts[i].transform.Find("image1").gameObject.GetComponent<Image>();
                SpriteRenderer spriteR = belts[i].GetComponent <SpriteRenderer>();
                if (!(beltShow % 20 == 0))
                {
                    spriteR.color = new Color(spriteR.color.r, spriteR.color.g, spriteR.color.b, 1f);
                    // image1.color = new Color(image1.color.r, image1.color.g, image1.color.b, 1f);
                    // image2.color = new Color(image2.color.r, image2.color.g, image2.color.b, 0f);
                }
                else
                {
                    spriteR.color = new Color(spriteR.color.r, spriteR.color.g, spriteR.color.b, 0f);
                    // image2.color = new Color(image2.color.r, image2.color.g, image2.color.b, 1f);
                    // image1.color = new Color(image1.color.r, image1.color.g, image1.color.b, 0f);
                }
            }
            beltShow += 1;
        }

        //Time Display
        currentTime -= 1 * Time.deltaTime;     // Time.deltaTime to make time be updated by second not by frame
        int seconds = (int)(currentTime % 60);
        int minutes = (int)(currentTime / 60);

        GameObject.Find("Canvas/timerText").GetComponent <Text>().text = string.Format("{0:0}:{1:00}", minutes, seconds);
        if (currentTime <= 0)
        {
            currentTime = 0;
        }
        if (currentTime == 0 && !finishGame)
        {
            finishGame = true;
            tip10.SetActive(false);
            blueCarBox.SetActive(false);
            EndGame();
            enabled = false;
        }
        //Tips Display
        GameObject.Find("Canvas/tipsText").GetComponent <Text>().text = "Tips:" + totalTips.ToString();

        if (currentTime < doubleTipsEndTime)
        {
            GameObject.Find("Main Camera").GetComponent <Camera>().backgroundColor = new Color(70f / 255f, 70f / 255f, 70f / 255f);
            duringDoubleTipsTime = false;
            doubleTipsPropButtion.SetActive(false);
        }
    }