Ejemplo n.º 1
0
        protected virtual void Update()
        {
            cooldown -= Time.deltaTime;

            if (cooldown <= 0.0f)
            {
                cooldown = DelayPerHeal;

                if (destructible == null)
                {
                    destructible = GetComponent <Destroyable>();
                }

                if (snapshot.AlphaWidth == destructible.AlphaWidth && snapshot.AlphaHeight == destructible.AlphaHeight)
                {
                    destructible.BeginAlphaModifications();
                    {
                        for (var y = snapshot.AlphaHeight - 1; y >= 0; y--)
                        {
                            for (var x = snapshot.AlphaWidth - 1; x >= 0; x--)
                            {
                                var index    = x + y * snapshot.AlphaWidth;
                                var oldAlpha = destructible.AlphaData[index];
                                var newAlpha = snapshot.AlphaData[index];

                                if (oldAlpha != newAlpha)
                                {
                                    newAlpha = (byte)Mathf.MoveTowards(oldAlpha, newAlpha, HealAmount);

                                    destructible.WriteAlpha(x, y, newAlpha);
                                }
                            }
                        }
                    }
                    destructible.EndAlphaModifications();
                }
            }
        }