Ejemplo n.º 1
0
    public override IEnumerator SlowUpdate()
    {
        if (IsServer)
        {
            leftWrist  = GameObject.FindGameObjectWithTag("wristLeft").transform;
            rightWrist = GameObject.FindGameObjectWithTag("wristRight").transform;

            holdingLeft  = leftWrist.GetComponent <HoldingScript>();
            holdingRight = rightWrist.GetComponent <HoldingScript>();

            leftTarget  = GameObject.FindGameObjectWithTag("leftTarget").transform;
            rightTarget = GameObject.FindGameObjectWithTag("rightTarget").transform;


            chef       = GameObject.FindGameObjectWithTag("chef");
            chefScript = chef.GetComponent <ChefScript>();

            leftIsHolding  = false;
            rightIsHolding = false;

            StartCoroutine(CheckBothHolding());
        }
        if (IsClient)
        {
            yield return(new WaitForSeconds(MyCore.MasterTimer * 5f));

            leftTarget  = GameObject.FindGameObjectWithTag("leftTarget").transform;
            rightTarget = GameObject.FindGameObjectWithTag("rightTarget").transform;


            chef       = GameObject.FindGameObjectWithTag("chef");
            chefScript = chef.GetComponent <ChefScript>();
        }
        //while (IsServer)
        //{
        //gripDistSqr = gripDist * gripDist;

        /*
         * if ((leftWrist.position - leftGrip.position).sqrMagnitude < gripDistSqr && holdingLeft.isHolding)
         * {
         *  Debug.DrawLine(leftGrip.position, leftWrist.position, Color.green);
         * }
         * if ((rightWrist.position - rightGrip.position).sqrMagnitude < gripDistSqr && holdingRight.isHolding)
         * {
         *  Debug.DrawLine(rightGrip.position, rightWrist.position, Color.green);
         * }
         *
         * bothHolding = ((leftWrist.position - leftGrip.position).sqrMagnitude < gripDistSqr && holdingLeft.isHolding) &&
         *              ((rightWrist.position - rightGrip.position).sqrMagnitude < gripDistSqr && holdingRight.isHolding);
         */
        //SendUpdate("D", bothHolding.ToString());

        //if (bothHolding)
        //  this.transform.position = (leftWrist.position + rightWrist.position) * 0.5f;

        yield return(new WaitForSeconds(MyCore.MasterTimer));    //potentially slower
        //}
    }
Ejemplo n.º 2
0
 void OnCollisionEnter2D(Collision2D coll)
 {
     if (coll.gameObject.CompareTag("Ingredient"))
     {
         int ingredientType = ChefScript.findIngredientType(coll.gameObject.name);
         Destroy(coll.gameObject);
         addToStack(ingredientType);
     }
 }
Ejemplo n.º 3
0
 // Use this for initialization
 void Start()
 {
     Time.timeScale     = 1;
     timer              = GetComponentInParent <Timer>();
     stack              = FindObjectOfType <Stack>();
     chef               = FindObjectOfType <ChefScript> ();
     enemy              = FindObjectOfType <EnemyScript> ();
     round              = 1;
     paused             = false;
     roundSwitchPromter = "";
 }
Ejemplo n.º 4
0
    public override IEnumerator SlowUpdate()
    {
        if (IsLocalPlayer)
        {
            yield return(new WaitUntil(() => isLeft || isRight));

            if (isLeft)
            {
                StartCoroutine(LeftHand());
            }
            if (isRight)
            {
                StartCoroutine(RightHand());
            }

            yield return(new WaitForSeconds(0.4f));


            Camera.main.transform.position = camPositionClient;
            Camera.main.transform.LookAt(camTargetClient);

            mask = LayerMask.GetMask("Kitchen");
        }
        if (IsServer)
        {
            chef       = GameObject.FindGameObjectWithTag("chef");
            chefScript = chef.GetComponent <ChefScript>();

            camPos = chefScript.cameraPosition;
            SendUpdate("CAMPOS", chefScript.cameraPosition.position.ToString("F4"));
            camTargetLeft = chefScript.cameraTargetL;
            SendUpdate("CAMTAR", chefScript.cameraTargetL.position.ToString("F4"));
            camTargetRight = chefScript.cameraTargetR;



            leftTarget  = chefScript.leftChefTransform;
            rightTarget = chefScript.rightChefTransform;

            StartCoroutine(CombineDualHold());

            handHeightLeft = 0f;
        }
        //while (IsLocalPlayer)
        //{


        yield return(new WaitForSeconds(MyCore.MasterTimer));    //potentially slower
        // }
    }
    /// <summary>
    /// Called once on startup
    /// </summary>
    private void Start()
    {
        // get the Chef corresponding to this player
        Chef = LicenseToGrillController.Instance.Chefs[GetPlayerIndex()];
        Chef.gameObject.SetActive(true);

        // set appearance of items which change colour based on player
        Chef.ChoppingBoardColour.color = ColourFetcher.GetColour(GetPlayerIndex());
        Chef.SelectionHandColour.color = ColourFetcher.GetColour(GetPlayerIndex());

        // create order list
        _customerHandler = new CustomerHandler();
        Chef.DisplayOrders(_customerHandler.GetNextOrders(5));

        // assign callbacks for when the selection hand enters a trigger, and when an action is complete
        Chef.AddItemSelectionCallbacks(TriggerEntered_, TriggerExited_);
        Chef.AssignActionCallback(UpdateAction_);

        // store position of the sauce bottles
        _saucesYPosition   = Chef.SauceBottles[0].localPosition.y;
        _saucePlatformSize = Chef.SaucePlatform.transform.localScale;
    }