Ejemplo n.º 1
0
 private Color PlayerCircleColor(ColorType colorType)
 {
     // if Player is white, his color is displayed transparent instead
     return(colorType == ColorType.DefaultColor
         ? defaultColor
         : ColorConversion.GetColorFromType(colorType));
 }
Ejemplo n.º 2
0
        private void TryBounce(Collision2D other)
        {
            foreach (var contact in other.contacts)
            {
                if (Vector2.Dot(contact.normal, direction) <= -.5f)
                {
                    FlipDirection();
                    bounceSource.PlayRandomPitch(.1f);
                }
                else
                {
                    smallBounceSource.PlayRandomPitch(.25f);
                }

                var block     = contact.collider.GetComponent <Block>();
                var particles = Instantiate(bounceParticle, contact.point,
                                            Quaternion.LookRotation(Vector3.forward, contact.normal));
                if (block)
                {
                    var main = particles.GetComponent <ParticleSystem>().main;
                    main.startColor = ColorConversion.GetColorFromType(block.GetColorType());
                    var interactable = block.GetComponent <IInteractable>();
                    interactable?.Interact(this);
                }

                Dash(contact.normal);
            }
        }