/// <summary>
    /// Instanzieert die Würfel und speichert sie inklusive eigener Kamera in dcam-Liste ab
    /// </summary>
    /// <param name="typ"></param>
    /// <param name="position"></param>
    /// <param name="anzahl"></param>
    protected virtual void InstantiateDice(WürfelTyp typ, Vector3 position, int anzahl)
    {
        if (anzahl > 0)
        {
            DiceWithCam dCam;
            CreateParentGameObject();

            for (int count = 0; count < anzahl; count++)
            {
                //Erzeuge jeweils neue Kamera mit Würfel
                dCam        = new DiceWithCam(typ);
                position.y += count;

                SetParentGameObject(dCam);

                switch (typ)
                {
                case WürfelTyp.w6:
                    if (count % 2 == 0)
                    {
                        dCam.dice = Instantiate(W6preFabBlack, position, Quaternion.identity) as GameObject;
                    }
                    else
                    {
                        dCam.dice = Instantiate(W6preFabBlue, position, Quaternion.identity) as GameObject;
                    }

                    dCam.dice.name = "W6_" + count;
                    break;

                case WürfelTyp.w10:
                    if (count % 2 == 0)
                    {
                        dCam.dice = Instantiate(W10preFabBlack, position, Quaternion.identity) as GameObject;
                    }
                    else
                    {
                        dCam.dice = Instantiate(W10preFabBlue, position, Quaternion.identity) as GameObject;
                    }
                    dCam.dice.name = "W10_" + count;
                    break;

                case WürfelTyp.w20:
                    if (count % 2 == 0)
                    {
                        dCam.dice = Instantiate(W20preFabBlack, position, Quaternion.identity) as GameObject;
                    }
                    else
                    {
                        dCam.dice = Instantiate(W20preFabBlue, position, Quaternion.identity) as GameObject;
                    }
                    dCam.dice.name = "W20_" + count;
                    break;

                default:
                    break;
                }

                //Beschleunige und rotiere den Würfel
                RotateAndAccelerate(dCam.dice);

                //Positioniere die Kamera auf Würfel
                PositionCam(dCam);

                //füge den Würfel mit Kamera der UpdateListe hinzu
                createdDiceWithCam.Add(dCam);

                //Zähle aktuelle Wüfel nach oben
                countAllDice++;
            }
        }
    }
 //Erzeuge den Würfel immer
 public DiceWithCam(WürfelTyp _type)
 {
     dice = new GameObject("Würfel_" + _type.ToString());
     cam  = new GameObject("WürfelCamera");
 }
Exemplo n.º 3
0
    override protected void InstantiateDice(WürfelTyp typ, Vector3 position, int anzahl)
    {
        ToolboxDice diceVars = ToolboxDice.Instance;

        if (anzahl > 0)
        {
            DiceWithCam dCam;
            CreateParentGameObject();

            for (int count = 0; count < anzahl; count++)
            {
                //Erzeuge jeweils neue Kamera mit Würfel
                dCam        = new DiceWithCam(typ);
                position.y += count;

                SetParentGameObject(dCam);

                switch (typ)
                {
                case WürfelTyp.w6:
                    if (count % 2 == 0)
                    {
                        dCam.dice = PhotonNetwork.Instantiate(diceVars.colorDice_d6, position, Quaternion.identity, 0);
                    }
                    else
                    {
                        dCam.dice = PhotonNetwork.Instantiate("d6black", position, Quaternion.identity, 0);
                    }

                    dCam.dice.name = "W6_" + count;
                    break;

                case WürfelTyp.w10:
                    if (count % 2 == 0)
                    {
                        dCam.dice = PhotonNetwork.Instantiate(diceVars.colorDice_d10, position, Quaternion.identity, 0);
                    }
                    else
                    {
                        dCam.dice = PhotonNetwork.Instantiate("d10black", position, Quaternion.identity, 0);
                    }
                    dCam.dice.name = "W10_" + count;
                    break;

                case WürfelTyp.w20:
                    if (count % 2 == 0)
                    {
                        dCam.dice = PhotonNetwork.Instantiate(diceVars.colorDice_d20, position, Quaternion.identity, 0);
                    }
                    else
                    {
                        dCam.dice = PhotonNetwork.Instantiate("d20black", position, Quaternion.identity, 0);
                    }
                    dCam.dice.name = "W20_" + count;
                    break;

                default:
                    break;
                }

                //Beschleunige und rotiere den Würfel
                RotateAndAccelerate(dCam.dice);

                //Positioniere die Kamera auf Würfel
                PositionCam(dCam);

                //füge den Würfel mit Kamera der UpdateListe hinzu
                createdDiceWithCam.Add(dCam);

                //Zähle aktuelle Wüfel nach oben
                countAllDice++;
            }
        }
    }