Пример #1
0
 void OnAppearanceChanged(Die die, int newFaceCount, DesignAndColor newDesign)
 {
     this.die.designAndColor = newDesign;
     if (this.dieRenderer != null)
     {
         DiceRendererManager.Instance.DestroyDiceRenderer(this.dieRenderer);
         this.dieRenderer = null;
     }
     this.dieRenderer = DiceRendererManager.Instance.CreateDiceRenderer(newDesign);
     if (dieRenderer != null)
     {
         dieRenderImage.texture = dieRenderer.renderTexture;
     }
 }
Пример #2
0
 public Coroutine SetCurrentDesignAndColor(DesignAndColor design, System.Action <bool> callback)
 {
     return(StartCoroutine(SendMessageWithAckOrTimeoutCr(
                               new DieMessageSetDesignAndColor()
     {
         designAndColor = design
     },
                               DieMessageType.SetDesignAndColorAck,
                               3,
                               (ignore) =>
     {
         designAndColor = design;
         OnAppearanceChanged?.Invoke(this, faceCount, designAndColor);
         callback?.Invoke(true);
     },
                               () => callback?.Invoke(false),
                               () => callback?.Invoke(false))));
 }
Пример #3
0
    /// <summary>
    /// Creates a new die for the pool
    /// </sumary>
    PoolDie CreateDie(Central.IDie centralDie, uint deviceId = 0, int faceCount = 0, DesignAndColor design = DesignAndColor.Unknown)
    {
        var dieObj = new GameObject(name);

        dieObj.transform.SetParent(transform);
        Die die = dieObj.AddComponent <Die>();

        System.Action <Die.ConnectionState> setStateAction;
        System.Action <Die.LastError>       setLastErrorAction;
        die.Setup(centralDie.name, centralDie.address, deviceId, faceCount, design, out setStateAction, out setLastErrorAction);
        var ourDie = new PoolDie()
        {
            die        = die,
            centralDie = centralDie,
            setState   = setStateAction,
            setError   = setLastErrorAction,
        };

        dice.Add(ourDie);

        return(ourDie);
    }
Пример #4
0
        public void Setup(
            string name,
            string address,
            uint deviceId,
            int faceCount,
            DesignAndColor design,
            out System.Action <ConnectionState> outConnectionSetter,
            out System.Action <LastError> outLastErrorSetter)
        {
            bool appearanceChanged = faceCount != this.faceCount || design != this.designAndColor;

            this.name           = name;
            this.address        = address;
            this.deviceId       = deviceId;
            this.faceCount      = faceCount;
            this.designAndColor = design;
            if (appearanceChanged)
            {
                OnAppearanceChanged?.Invoke(this, faceCount, designAndColor);
            }
            outConnectionSetter = SetConnectionState;
            outLastErrorSetter  = SetLastError;
        }