void Awake()
 {
     if (AutomaticMovement.instance == null)
     {
         AutomaticMovement.instance = this;
     }
     else
     {
         Destroy(this.gameObject);
     }
 }    // end to awake
    void Start()
    {
        player = GameObject.FindGameObjectWithTag(TagManager.PLAYER);
        mainCamera = GameObject.FindGameObjectWithTag(TagManager.MAIN_CAMERA);
        cameraControl = mainCamera.GetComponent<Camera_Escape>();
        hudLogic = GameObject.FindGameObjectWithTag(TagManager.GAME_CONTROLLER).GetComponent<ReplacementHUDLogic>();
        playerMovement = player.GetComponent<PLayerMovement>();
        playerAutomaticMovement = player.GetComponent<AutomaticMovement>();

        rotationSpeed = 6f;
        inTrigger = false;
    }
Esempio n. 3
0
 void Awake()
 {
     enterObElementTag      = new List <GameObject>();
     this.automaticMovement = this.GetComponent <AutomaticMovement>();
 }
Esempio n. 4
0
 // Use this for initialization
 void Awake()
 {
     escapeCamera = gameObject;
     automaticMovementPlayer = player.GetComponent<AutomaticMovement>();
     StartCoroutine(wait());
 }
    void Update()
    {
        if (stream2 != null)
        {
            if (stream2.IsOpen)
            {
                personFloor = GameObject.FindWithTag("Player").GetComponent <PlayerScript>().currentFloor;

                GameObject        chosenElevator = elevators[GetNearestElevator(personFloor)];
                AutomaticMovement chosen         = chosenElevator.GetComponent <AutomaticMovement>();

                if (personRequest && !isFull && personRequestDirection == chosen.isUp)
                {
                    chosen.enabled = false;

                    chosenElevator.transform.position = Vector3.MoveTowards(chosenElevator.transform.position, chosen.wp[personFloor - 1].transform.position, Time.deltaTime * speed);
                }
                if (personDelivered)
                {
                    GetComponent <AutomaticMovement>().enabled = true;
                }

                if (Input.GetKey("x"))
                {
                    personRequest = !personRequest;
                }
                if (Input.GetKey(KeyCode.UpArrow))
                {
                    personRequestDirection = 1;
                }
                if (Input.GetKey(KeyCode.DownArrow))
                {
                    personRequestDirection = 0;
                }

                try
                {
                    Debug.Log("random");

                    ////Data to Arduino (inside)
                    Debug.Log(stream2.ReadLine());
                    if (chosen.current == 1 && chosen.isUp == 1)
                    {
                        stream2.Write("a");
                    }
                    if (chosen.current == 2 && chosen.isUp == 1)
                    {
                        stream2.Write("b");
                    }
                    if (chosen.current == 2 && chosen.isUp == 2)
                    {
                        stream2.Write("c");
                    }
                    if (chosen.current == 3 && chosen.isUp == 1)
                    {
                        stream2.Write("d");
                    }
                    if (chosen.current == 3 && chosen.isUp == 2)
                    {
                        stream2.Write("e");
                    }
                    if (chosen.current == 4 && chosen.isUp == 1)
                    {
                        stream2.Write("f");
                    }
                    if (chosen.current == 4 && chosen.isUp == 2)
                    {
                        stream2.Write("g");
                    }
                    if (chosen.current == 5 && chosen.isUp == 2)
                    {
                        stream2.Write("h");
                    }

                    ////Data from Arduino (inside)
                    //string value = stream.ReadLine();
                    //if (value == "12")
                    //{
                    //    data = 12;
                    //    Debug.Log("UPDOWN");
                    //}
                    //if (value == "1")
                    //{
                    //    data = 1;
                    //    Debug.Log("UP");
                    //}
                    //if (value == "2")
                    //{
                    //    data = 2;
                    //    Debug.Log("DOWN");
                    //}

                    ////Data from Arduino (outside)
                    //string value2 = stream2.ReadLine();
                    //if (value2 == "!")
                    //{
                    //    data = 0;
                    //}
                    //if (value2 == "<")
                    //{
                    //    data = 1;
                    //}
                    //if (value2 == ">")
                    //{
                    //    data = 2;
                    //}
                }
                catch (System.Exception)
                {
                    Debug.Log("Error");
                }
            }
        }
    }