コード例 #1
0
        void Update()
        {
            //_bg.graphics.CompositingMode = CompositingMode.SourceOver;
            _bg.Clear(Color.FromArgb(255, Color.Black));

            var localPos = _bg.InverseTransformPoint(_mainTarget.x, _mainTarget.y);

            float localX = localPos.x + MyGame.HALF_SCREEN_WIDTH;
            float localY = localPos.y + MyGame.HALF_SCREEN_HEIGHT;

            _bg.graphics.CompositingMode = CompositingMode.SourceCopy;
            _lightSprite.SetXY(localX, localY);
            _bg.DrawSprite(_lightSprite);

            DrawLight(Input.mouseX, Input.mouseY);
            //DrawLight(localX, localY);

            localPos = _bg.InverseTransformPoint(2792, 3995);
            DrawLight(localPos.x + MyGame.HALF_SCREEN_WIDTH, localPos.y + MyGame.HALF_SCREEN_HEIGHT);

            //_bg.graphics.DrawImage(_lightAlpha, Input.mouseX, Input.mouseY);

            if (Input.GetKeyDown(Key.V))
            {
                hatchIndex = GeneralTools.GetCircularArrayIndex(hatchIndex - 1, _hatchStyles.Length);
                SetBrushes(_hatchStyles[hatchIndex]);
                Console.WriteLine(_hatchStyles[hatchIndex]);
            }
            else if (Input.GetKeyDown(Key.B))
            {
                hatchIndex = GeneralTools.GetCircularArrayIndex(hatchIndex + 1, _hatchStyles.Length);
                SetBrushes(_hatchStyles[hatchIndex]);
                Console.WriteLine(_hatchStyles[hatchIndex]);
            }
        }
コード例 #2
0
        private IEnumerator FollowPathRoutine()
        {
            if (_path.Length == 0)
            {
                yield break;
            }

            SetXY(_path[0].x, _path[0].y);

            while (Enabled || !Destroyed)
            {
                for (int i = 0; i < _path.Length; i++)
                {
                    var startPoint    = _path[i];
                    int endPointIndex = GeneralTools.GetCircularArrayIndex(i + 1, _path.Length);
                    var endPoint      = _path[endPointIndex];

                    var   distPoint     = endPoint - startPoint;
                    var   distPointNorm = distPoint.Normalized;
                    float distPointMag  = distPoint.Magnitude;

                    Vector2 nextPos = startPoint;
                    float   nextDist;

                    do
                    {
                        nextPos += distPointNorm * _pointSpeed * Time.delta;

                        CanvasDebugger2.Instance.DrawEllipse(nextPos.x, nextPos.y, 100, 100, Color.Cyan);

                        yield return(null);

                        var nextTornadoDist = nextPos - _pos;
                        var nextTornadoNorm = nextTornadoDist.Normalized;

                        var nextTornadoPos = nextTornadoNorm * _speed * Time.delta;

                        Translate(nextTornadoPos.x, nextTornadoPos.y);

                        nextDist = (nextPos - startPoint).Magnitude;
                    } while (nextDist < distPointMag);
                }
            }
        }