Ejemplo n.º 1
0
 public void Initialize(Spline startSpline, float startPercentage, CLIENTSTATE startState)
 {
     spline      = startSpline;
     clientState = startState;
     percentage  = startPercentage;
     GetComponent <Animator>().SetBool("IsWalking", clientState == CLIENTSTATE.WALKING);
 }
Ejemplo n.º 2
0
    private IEnumerator GoShopping()
    {
        yield return(new WaitForSeconds(Random.Range(minShoppingDuration, maxShoppingDuration)));

        // Reset walking
        percentage  = 0;
        ClientState = CLIENTSTATE.WALKING;
        GetComponent <Animator>().SetBool("IsWalking", true);
    }
Ejemplo n.º 3
0
 private void OnTriggerExit(Collider other)
 {
     if (other.transform.CompareTag("Player"))
     {
         Debug.Log("Player est parti, je remarche");
         GetComponent <Animator>().SetBool("IsWalking", true);
         clientState = CLIENTSTATE.WALKING;
         speed       = walkingSpeed;
     }
 }
Ejemplo n.º 4
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.transform.CompareTag("Shop"))
        {
            // Get the next shop to go to
            spline = other.GetComponent <Shop>().GetExitPath();
        }

        if (other.transform.CompareTag("Player"))
        {
            if (clientState != CLIENTSTATE.FREEZE)
            {
                Debug.Log("Player me bloque, je m'arrête");
                clientState = CLIENTSTATE.FREEZE;
                GetComponent <Animator>().SetBool("IsWalking", false);
                speed = 0;
            }
        }
    }
Ejemplo n.º 5
0
    private void SpawnClients()
    {
        for (int i = 0; i < clientsNumber; i++)
        {
            GameObject clientPrefab = clientPrefabs[Random.Range(0, clientPrefabs.Length)];
            GameObject myShop       = shops[Random.Range(0, shops.Length)];
            //CLIENTSTATE myState = (CLIENTSTATE)Random.Range(0, 2);
            CLIENTSTATE myState = CLIENTSTATE.WALKING;

            float  myStartPercentage = 1f;
            Spline mySpline          = null;

            mySpline          = myShop.GetComponent <Shop>().GetExitPath();
            myStartPercentage = Random.Range(0f, 1f);

            GameObject client = Instantiate(clientPrefab, mySpline.GetPosition(myStartPercentage), Quaternion.LookRotation(mySpline.GetDirection(myStartPercentage)));

            client.GetComponent <Client>().SetConstants(speed, minShoppingDuration, maxShoppingDuration);
            client.GetComponent <Client>().Initialize(mySpline, myStartPercentage, myState);
        }
    }
Ejemplo n.º 6
0
    private void Update()
    {
        if (clientState == CLIENTSTATE.WALKING)
        {
            /* UPDATE PERCENTAGE */

            percentage = Mathf.Min(percentage + (speed * Time.deltaTime) / spline.Length, 1);

            /* UPDATE TRANSFORM */

            Vector3 position = spline.GetPosition(percentage);
            transform.position = StickToTheGround(position);
            transform.rotation = Quaternion.LookRotation(spline.GetDirection(percentage));

            /* SHOPPING CONDITION */

            if (percentage == 1)
            {
                GetComponent <Animator>().SetBool("IsWalking", false);
                ClientState = CLIENTSTATE.SHOPPING;
                StartCoroutine("GoShopping");
            }
        }
    }