Пример #1
0
        public void UpdateAlphaWithScene(MultiplayerLayeredCharacterScene scene)
        {
            if (scene == null)
                throw new ArgumentNullException ("scene");

            if (!FadeAlpha)
                return;

            nfloat closestHeroDistance = nfloat.MaxValue;

            // See if there are any heroes nearby.
            var ourPosition = Position;
            foreach (SKNode hero in scene.Heroes) {
                var theirPos = hero.Position;
                var distance = GraphicsUtilities.DistanceBetweenCGPoints(ourPosition, theirPos);
                closestHeroDistance = (nfloat)Math.Min (distance, closestHeroDistance);
            }

            if (closestHeroDistance > OpaqueDistance) {
                // No heroes nearby.
                Alpha = 1;
            } else {
                // Adjust the alpha based on how close the hero is.
                var ratio = closestHeroDistance / OpaqueDistance;
                Alpha = 0.1f + ratio * ratio * 0.9f;
            }
        }
Пример #2
0
        public void AddToScene(MultiplayerLayeredCharacterScene scene)
        {
            if (scene == null)
                throw new ArgumentNullException ("scene");

            scene.AddNode (this, WorldLayer.Character);
            scene.AddNode (ShadowBlob, WorldLayer.BelowCharacter);
        }