Пример #1
0
    // Update is called once per frame
    void Update()
    {
        // Don't update if the game is over
        if (!CustomerSpawn.GameIsOver())
        {
            // Decrease timer at rate determined by customer satisfaction
            timer -= Time.deltaTime * anger;

            // When timer elapses, customer leaves and deducts points in dissatisfaction
            if (timer <= 0.0)
            {
                if (anger == 1.0)
                {
                    P1Movement.ScorePenalty(BASE_PENALTY * numIngredients);
                    P2Movement.ScorePenalty(BASE_PENALTY * numIngredients);
                }

                // Determine which player(s) deserve(s) the penalty
                else
                {
                    if (aScale > 0)
                    {
                        P1Movement.ScorePenalty(BASE_PENALTY * numIngredients * 2);
                    }
                    else if (aScale < 0)
                    {
                        P2Movement.ScorePenalty(BASE_PENALTY * numIngredients * 2);
                    }
                    else
                    {
                        P1Movement.ScorePenalty(BASE_PENALTY * numIngredients * 2);
                        P2Movement.ScorePenalty(BASE_PENALTY * numIngredients * 2);
                    }
                }
                CustomerSpawn.SetOccupied(custID, false);
                Destroy(gameObject);
            }
        }
    }
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(this);
     }
     input = new InputMaster();
     //getting input
     if (useKeyBoard)
     {
         input.Player1.Movement.performed += P1Movement => movement = P1Movement.ReadValue <Vector2>();
     }
     else
     {
         input.Player1.Movement.performed += P1Movement => Move1(P1Movement.ReadValue <Vector2>());
     }
     // input.Player1.Interact.started += ctx => StartCoroutine(Interact());
 }