Exemplo n.º 1
0
    // Start is called before the first frame update
    void Start()
    {
        //Gör det lättare att ändra färg
        skin      = gameObject.GetComponentInChildren <SkinnedMeshRenderer>().materials[0];
        component = gameObject.GetComponentInChildren <SkinnedMeshRenderer>().materials[2];
        armor     = gameObject.GetComponentInChildren <SkinnedMeshRenderer>().materials[3];
        limb      = gameObject.GetComponentInChildren <SkinnedMeshRenderer>().materials[4];

        colors          = new Color[] { Color.red, Color.white, Color.yellow, Color.black, Color.blue, Color.clear, Color.cyan, Color.gray, Color.green, Color.grey, Color.magenta };
        skin.color      = colors[Random.Range(0, colors.Length)];
        armor.color     = colors[Random.Range(0, colors.Length)];
        component.color = colors[Random.Range(0, colors.Length)];
        limb.color      = colors[Random.Range(0, colors.Length)];

        UpdateBoxColors();

        //RotateToCamera();

        toChange     = ThingToChange.armorColor;
        isChangeable = true;

        axisValue = Input.GetAxisRaw(playerNr + "JoyVertical");

        lblReady = Instantiate(lblReady);
        readyPos = new Vector3(55, 240, -1);
        //readyPos.x -= 0.11f;
        //readyPos.y += 0.47f;

        lblReady.transform.position = readyPos;
        //lblReady.transform.Rotate(0, 180, 0);
        lblReady.transform.localScale = new Vector3(1, 1, 1);
        lblReady.transform.SetParent(transform.parent.transform, false);
        RectTransform rt = (RectTransform)lblReady.transform;

        rt.sizeDelta = new Vector2(300, 80);

        lblReady.SetActive(false);

        oldVerticalAxis = Input.GetAxisRaw(playerNr + "JoyVertical");

        UpdateHighlightBox();
    }
Exemplo n.º 2
0
 private void SwitchToChange(int modifier)
 {
     if (modifier > 0)
     {
         toChange--;
     }
     else
     {
         toChange++;
     }
     if (toChange > ThingToChange.rotate)
     {
         toChange = ThingToChange.armorColor;
     }
     else if (toChange < ThingToChange.armorColor)
     {
         toChange = ThingToChange.rotate;
     }
     UpdateHighlightBox();
 }
Exemplo n.º 3
0
    private void Update()
    {
        if (!isReady)
        {
            if (Input.GetButtonDown(playerNr + "L1"))
            {
                AlterCharacter(-1);
            }
            else if (Input.GetButtonDown(playerNr + "R1"))
            {
                AlterCharacter(1);
            }

            changeTimer -= Time.deltaTime;
            if (changeTimer <= 0)
            {
                isChangeable = true;
            }

            if (isChangeable)
            {
                verticalAxis = Input.GetAxisRaw(playerNr + "JoyVertical");
                //Debug.Log("VerticalAxis: " + verticalAxis);
                if (verticalAxis == 1)
                {
                    oldVerticalAxis = verticalAxis;
                    SwitchToChange(1);
                    isChangeable = false;
                    changeTimer  = resetTime;
                }
                else if (verticalAxis == -1)
                {
                    oldVerticalAxis = verticalAxis;
                    SwitchToChange(-1);
                    isChangeable = false;
                    changeTimer  = resetTime;
                }
            }
            if (Input.GetButtonDown(playerNr + "B"))
            {
                connectScript.DisconnectPlayer(playerNr, occupiedSlot, gameObject);
                Destroy(gameObject.transform.parent.transform.gameObject);
            }
        }


        if (Input.GetButtonDown(playerNr + "A"))
        {
            if (!isReady)
            {
                isReady = true;
                GetComponent <PlayerScript>().CreateCharacter(playerNr, limb, skin, armor, component, "James");
                RotateToCamera();
                lblReady.SetActive(true);
                setUpBoxScript.NoneActive();
            }
        }

        if (Input.GetButtonDown(playerNr + "B")) //Om spelaren klickar på bakåt knappen
        {
            if (isReady)                         //Om spelaren är redo ska den tas bort från ScoreScript och sättas som oredo
            {
                isReady = false;
                lblReady.SetActive(false);
                foreach (PlayerScript playerScript in ScoreScript.scoreScript.playerScripts)
                {
                    if (playerScript.playerNr == playerNr)
                    {
                        ScoreScript.scoreScript.playerScripts.Remove(playerScript);
                        break;
                    }
                }
                toChange = ThingToChange.armorColor;
                UpdateHighlightBox();
            }
        }
        UpdateBoxColors();
    }