Exemplo n.º 1
0
        public TerrainCastHit Initialize(RaycastHit2D hit, ControllerSide fromSide = ControllerSide.All,
                                         HedgehogController controller             = null, Vector2 start = default(Vector2), Vector2 end = default(Vector2))
        {
            Start        = start;
            End          = end;
            Hit          = hit;
            Side         = fromSide;
            Controller   = controller;
            NormalAngle  = DMath.Modp(DMath.Angle(hit.normal), DMath.DoublePi);
            SurfaceAngle = DMath.Modp(NormalAngle - DMath.HalfPi, DMath.DoublePi);

            if (!hit)
            {
                return(this);
            }

            Transform = hit.transform;
            Collider  = hit.collider;

            return(this);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Sets the palette to the specified index.
        /// </summary>
        /// <param name="index">The specified index.</param>
        public void SetPalette(int index)
        {
            // If the number is out of bounds just mod it
            index = DMath.Modp(index, PaletteCount);

            for (var i = 0; i < ColorsPerPalette; ++i)
            {
                var absolute = i + index * ColorsPerPalette;
                if (!IgnoreTransparent || AllColors[absolute].a != 0.0f)
                {
#if UNITY_EDITOR
                    PaletteMaterial.SetColor(ColorTo + (i + 1), AllColors[absolute]);
#else
                    PaletteMaterial.SetColor(ColorToIDs[i], AllColors[absolute]);
#endif
                }
            }

            CurrentIndex = index;
            OnPaletteChange.Invoke();
        }
Exemplo n.º 3
0
 public virtual void SetSprite(int index)
 {
     SpriteRenderer.sprite = Sprites[CurrentIndex = DMath.Modp(index, SpriteCount)];
 }