Exemple #1
0
    //Randomly select one error and activate it on selected player in parameter
    void CallProblemsEvent(GamerScript gamerScript)
    {
        int eventTypeNumber = Random.Range(0, 4); //we coded 5 differents type of event

        if (gamerScript.errorType == -1)
        {
            gamerScript.Event(eventTypeNumber); //others things like animation and inventory are handled with animation....
        }
    }
Exemple #2
0
    // Update is called once per frame
    void Update()
    {
        if (currentGamer != null)
        {
            GamerScript gs        = (currentGamer.GetComponent(typeof(GamerScript)) as GamerScript);
            int         errorType = gs.errorType;
            if (errorType >= 0 && isRepairPossible)
            {
                if (Inventory.getIndex(Inventory.currentItem()) == errorType && Inventory.getInventoryQuantity(Inventory.currentItem()) > 0)
                {
                    if (infoText != null)
                    {
                        infoText.gameObject.SetActive(true);
                    }

                    if (Input.GetKey(KeyCode.Joystick1Button1) || Input.GetKey("space"))
                    {
                        gs.Repairing(true);
                        animator.SetBool("IsRepairing", true);
                    }
                    else
                    {
                        gs.Repairing(false);
                        animator.SetBool("IsRepairing", false);
                    }
                }
                else
                {
                    gs.Repairing(false);
                    animator.SetBool("IsRepairing", false);
                    if (infoText != null)
                    {
                        infoText.gameObject.SetActive(false);
                    }
                }
            }
            else
            {
                gs.Repairing(false);
                animator.SetBool("IsRepairing", false);
                if (infoText != null)
                {
                    infoText.gameObject.SetActive(false);
                }
            }
        }
    }