예제 #1
0
    public override Vector2 UpdatePos(Vector2 pos)
    {
        shakeValue += shakeSpeed * Time.deltaTime;
        var shakeNoise = VectorUtils.Do(shakeValue, (f) => Mathf.PerlinNoise(f, 0));

        shakeNoise = VectorUtils.Do(shakeNoise, (f) => 2 * f - 1);
        shakeNoise = VectorUtils.Multiply(shakeNoise, shakePower);
        return(pos + shakeNoise);
    }
예제 #2
0
    public Vector2 UpdatePos(Vector2 pos)
    {
        var offset = data.range;
        var c      = VectorUtils.Do(data.originDeg, f => Mathf.Sin(f * Mathf.Deg2Rad));

        c               = VectorUtils.Do(c, f => f * 2 - 1);
        offset          = VectorUtils.Multiply(offset, c);
        pos            += offset;
        data.originDeg += data.speedDeg * Time.deltaTime;
        return(pos);
    }
예제 #3
0
    public void AdjustEqual()
    {
        Rect    r     = SubSpriteBounds(gameObject);
        Rect    or    = SubSpriteBounds(otherGo);
        Vector2 scale = VectorUtils.Do(or.size, r.size, (f1, f2) => f1 / f2);
        Func <Vector3, Func <Vector2, Vector2>, Vector3> v223 = (v3, a) => VectorUtils.V23(a(VectorUtils.V32(v3)), v3.z);

        transform.localScale = v223(transform.localScale, s => VectorUtils.Multiply(s, scale));
        r = SubSpriteBounds(gameObject);
        Vector2 offset = or.center - r.center;

        transform.position += VectorUtils.V23(offset);
    }
예제 #4
0
    public static RedLightPlayerController Create(PlayerController player, Vector2 _pos)
    {
        SinMove sm = new SinMove(player.rdLtSinMovDt);

        sm.data.originDeg = VectorUtils.Do(Vector2.zero, f => UnityEngine.Random.value * 360);
        var rdLtCtrl = new RedLightPlayerController();

        rdLtCtrl.playerPosQueue     = player.playerPosDisQueue;
        rdLtCtrl.sinMove            = sm;
        rdLtCtrl.distanceSpeedCurve = player.rdLtDisSpdCv;
        rdLtCtrl.rlCtrl             = RedLightController.Create(player, _pos);
        player.StartCoroutine(rdLtCtrl.FollowCor());
        return(rdLtCtrl);
    }
예제 #5
0
        public TileMap(Rect edge, Vector2 originPos, float tileStep, T initValue)
        {
            Debug.Assert(edge.Contains(originPos));
            this.originPos = originPos;
            this.tileStep  = tileStep;
            Func <Vector2, Vector2> getSize = (dir) => {
                return(VectorUtils.Do(dir + new Vector2(1, 1) * 0.5f * tileStep, (f) => Mathf.Floor(f / tileStep)));
            };
            Vector2 minSize = getSize(originPos - edge.min);
            Vector2 maxSize = getSize(edge.max - originPos);
            Vector2 sumSize = minSize + maxSize + new Vector2(1, 1);

            sizeX   = (int)sumSize.x;
            sizeY   = (int)sumSize.y;
            originX = (int)minSize.x;
            originY = (int)minSize.y;
            map     = new List <T>(sizeX * sizeY);
            for (int i = 0; i < sizeX * sizeY; i++)
            {
                map.Add(initValue);
            }
        }
예제 #6
0
 public override void Register(MonoBehaviour mb)
 {
     base.Register(mb);
     shakeValue = VectorUtils.Do(shakeSpeed, (f) => Random.value * f);
 }
예제 #7
0
 public static ClassRef <Color> SRGBToLiner(ClassRef <Color> srgb)
 {
     return(new ClassRef <Color>((c) => srgb.set(VectorUtils.Do(c, f => Mathf.Pow(f, 1 / 2.2f))), () => VectorUtils.Do(srgb.get(), f => Mathf.Pow(f, 2.2f))));
 }
예제 #8
0
    public Rect SubSpriteBounds(GameObject go)
    {
        SpriteRenderer[] renderers = go.GetComponentsInChildren <SpriteRenderer>();
        Vector2          min       = getPoint(renderers, b => b.min, new Vector2(1, 1) * float.MaxValue, (v1, v2) => VectorUtils.Do(v1, v2, Mathf.Min));
        Vector2          max       = getPoint(renderers, b => b.max, new Vector2(1, 1) * float.MinValue, (v1, v2) => VectorUtils.Do(v1, v2, Mathf.Max));

        return(new Rect(min, max - min));
    }
예제 #9
0
        private Vector2 GetTileIndex(Vector2 pos)
        {
            var dir = pos - originPos + new Vector2(1, 1) * 0.5f * tileStep;

            return(VectorUtils.Do(dir, (f) => Mathf.Floor(f / tileStep)) + new Vector2(originX, originY));
        }
예제 #10
0
 private Vector2 getRandomPosInEdge()
 {
     return(VectorUtils.Do(VectorUtils.Do(Vector2.zero, (f) => UnityEngine.Random.value), edge.min, edge.max, (r, min, max) => Mathf.Lerp(min, max, r)));
 }