예제 #1
0
            protected override void Execute(ConfuserContext context, ProtectionParameters parameters)
            {
                if (!parameters.Targets.Any())
                {
                    return;
                }

                Mode         mode = parameters.GetParameter(context, context.CurrentModule, "mode", Mode.Normal);
                IModeHandler modeHandler;

                switch (mode)
                {
                case Mode.Normal:
                    modeHandler = new NormalMode();
                    break;

                case Mode.JIT:
                    modeHandler = new JITMode();
                    break;

                default:
                    throw new UnreachableException();
                }
                modeHandler.HandleInject((AntiTamperProtection)Parent, context, parameters);
                context.Annotations.Set(context.CurrentModule, HandlerKey, modeHandler);
            }
예제 #2
0
    public Peeker()
    {
        PEEKING = new PeekMode(this);
        NORMAL  = new NormalMode(this);

        // Start with a normal mode
        _state = NORMAL;
    }
예제 #3
0
    private void OnConfigLoaded()
    {
        Debug.Log("config loaded");
        Game = (NormalMode)GameModeBase.CreateGameMode("Normal");
        Game.Init();
        Game.StartGame();

        Destroy(gameObject);
    }
예제 #4
0
        protected override void OnLateUpdate(float deltaTime)
        {
            // Used in PuppetMasterModes
            forceActive = state != State.Puppet;

            if (!puppetMaster.isAlive)
            {
                return;
            }

            // Normal mode switching
            if (masterProps.normalMode != lastNormalMode)
            {
                if (lastNormalMode == NormalMode.Unmapped)
                {
                    foreach (Muscle m in puppetMaster.muscles)
                    {
                        m.state.mappingWeightMlp = 1f;
                    }
                }

                if (lastNormalMode == NormalMode.Kinematic)
                {
                    if (puppetMaster.mode == PuppetMaster.Mode.Kinematic)
                    {
                        puppetMaster.mode = PuppetMaster.Mode.Active;
                    }
                }

                lastNormalMode = masterProps.normalMode;
            }

            // Normal modes
            switch (masterProps.normalMode)
            {
            case NormalMode.Unmapped:
                if (puppetMaster.isActive)
                {
                    bool to = puppetMaster.pinWeight < 1f;

                    for (int i = 0; i < puppetMaster.muscles.Length; i++)
                    {
                        BlendMuscleMapping(i, ref to, deltaTime);
                    }
                }
                break;

            case NormalMode.Kinematic:
                if (SetKinematic())
                {
                    puppetMaster.mode = PuppetMaster.Mode.Kinematic;
                }
                break;

            default: break;
            }
        }
예제 #5
0
 public override void LoadState()
 {
     base.LoadState();
     normalMode       = (NormalMode)LoadInt("normalMode");
     placementMode    = (PlacementMode)LoadInt("placementMode");
     appendMode       = (AppendMode)LoadInt("appendMode");
     offset           = LoadFloat("offset");
     surfaceLayerMask = LoadInt("surfaceLayerMask", ~0);
 }
예제 #6
0
 public void method_11()
 {
     foreach (Control control in this.panel1.Controls)
     {
         control.Dispose();
     }
     this.panel1.Controls.Clear();
     NormalMode normalMode = new NormalMode();
     normalMode.TopLevel = false;
     normalMode.FormBorderStyle = FormBorderStyle.None;
     normalMode.Visible = true;
     this.panel1.Controls.Add(normalMode);
 }
예제 #7
0
 public void method_11()
 {
     foreach (Control control in this.panel1.Controls)
     {
         control.Dispose();
     }
     this.panel1.Controls.Clear();
     NormalMode mode = new NormalMode {
         TopLevel = false,
         FormBorderStyle = FormBorderStyle.None,
         Visible = true
     };
     this.panel1.Controls.Add(mode);
 }
예제 #8
0
 private void Start()
 {
     nm = GetComponent <NormalMode>();
     cm = GetComponent <ChaosMode>();
     if (!chaos)
     {
         cm.enabled = false;
         nm.enabled = true;
     }
     else
     {
         cm.enabled = true;
         nm.enabled = false;
     }
 }
예제 #9
0
파일: MainWindow.cs 프로젝트: Sobiech/zut
        private void InitializeEnvir()
        {
            Console.SetOut(new ConsoleWriter(logger));

            Console.WriteLine("Inicjalizacja aplikacji");
            drawableBitmaps = new Dictionary <int, Bitmap>();

            selectedColor = Color.Black;
            penSize       = 4;

            DrawableMode = new NormalMode();

            InitializePen();
            InitializeGraphics();
        }
예제 #10
0
        public override void DrawInspector()
        {
            if (editor.is2D)
            {
                EditorGUILayout.LabelField("Normal editing unavailable in 2D Mode", EditorStyles.centeredGreyMiniLabel);
                return;
            }
            normalMode = (NormalMode)EditorGUILayout.EnumPopup("Normal Mode", normalMode);

            int setNormals = EditorGUILayout.Popup(0, new string[] { "Normal Operations", "Flip", "Look At Camera", "Align with Camera", "Calculate", "Left", "Right", "Up", "Down", "Forward", "Back", "Look At Avg. Center", "Perpendicular to Spline" });

            if (setNormals > 0)
            {
                SetNormals(setNormals);
            }
        }
예제 #11
0
        void DrawWindows(EditorWindow editor)
        {
            foreach (var node in AllNodes.OrderBy(n => n.Position.y))
            {
                node.DrawGUI();
            }

            if (NextMouseMode != null)
            {
                CurrentMouseMode?.End(Event.current.mousePosition);
                CurrentMouseMode = NextMouseMode;
                NextMouseMode    = null;
                CurrentMouseMode?.Start(Event.current.mousePosition);
            }

            if (CurrentMouseMode == null)
            {
                NextMouseMode = new NormalMode(this);
            }

            if (CurrentMouseMode != null)
            {
                CurrentMouseMode.Update(Event.current.mousePosition);
            }

//            Rect test = new Rect(DrawRect);
//            test.center += PannedOffset;
//            GUI.color = Color.red;
//            GUI.Box(test, GUIContent.none);
//            GUI.color = Color.blue;
//            Rect koza = new Rect(PhysicalRect);
//            GUI.Box(koza, GUIContent.none);
//            GUI.color = Color.white;

            //if (Event.current.type == EventType.MouseMove
            //|| (Event.current.type == EventType.Ignore && Event.current.rawType == EventType.MouseMove))
            {
                //if (DrawRect.Contains(Event.current.mousePosition))

//                DrawPos(Event.current.mousePosition);
//
//                WantsRepaint = true;
            }
        }
예제 #12
0
        public SurfaceMesh(Mesh mesh, Vector3 position, Vector3 rotation, NormalMode normalMode)
        {
            this.normalMode = normalMode;

            vertices = mesh.getVertices();
            for (int i = 0; i < vertices.Length; i++)
            {
                vertices[i] = Matrix4.Translate(position) * Matrix4.Rotate(rotation) * vertices[i];
            }

            faces = mesh.getFaces();

            triangles = new Triangle[faces.GetLength(0)];
            for (int i = 0; i < triangles.Length; i++)
            {
                triangles[i] = new Triangle(vertices[faces[i, 0]], vertices[faces[i, 1]], vertices[faces[i, 2]]);
            }

            if (normalMode == NormalMode.PER_VERTEX)
            {
                vertexNormals = new Vector3[vertices.Length];
                for (int i = 0; i < vertices.Length; i++)
                {
                    vertexNormals[i] = Vector3.Zero;
                }
                for (int i = 0; i < triangles.Length; i++)
                {
                    for (int j = 0; j < 3; j++)
                    {
                        vertexNormals[faces[i, j]] = vertexNormals[faces[i, j]] + triangles[i].Normal;
                    }
                }
                for (int i = 0; i < vertices.Length; i++)
                {
                    vertexNormals[i] = vertexNormals[i].normalized();
                }
            }
            else
            {
                vertexNormals = null;
            }
        }
예제 #13
0
        public void CreateCore(IMotionUtil motionUtil, params string[] lines)
        {
            _textView = CreateTextView(lines);
            _textView.Caret.MoveTo(new SnapshotPoint(_textView.TextSnapshot, 0));
            _unnamedRegister = Vim.RegisterMap.GetRegister(RegisterName.Unnamed);
            _factory = new MockRepository(MockBehavior.Strict);
            _incrementalSearch = MockObjectFactory.CreateIncrementalSearch(factory: _factory);
            _commandUtil = _factory.Create<ICommandUtil>();

            _globalSettings = Vim.GlobalSettings;

            var vimTextBuffer = Vim.CreateVimTextBuffer(_textView.TextBuffer);
            var vimBufferData = CreateVimBufferData(vimTextBuffer, _textView);
            var operations = CommonOperationsFactory.GetCommonOperations(vimBufferData);
            motionUtil = motionUtil ?? new MotionUtil(vimBufferData, operations);
            var lineChangeTracker = new LineChangeTracker(vimBufferData);

            var capture = new MotionCapture(vimBufferData, _incrementalSearch.Object);
            var runner = new CommandRunner(
                _textView,
                Vim.RegisterMap,
                capture,
                vimBufferData.LocalSettings,
                _commandUtil.Object,
                vimBufferData.StatusUtil,
                VisualKind.Character,
                KeyRemapMode.Normal);
            _modeRaw = new NormalMode(
                vimBufferData,
                operations,
                motionUtil,
                runner,
                capture);
            _mode = _modeRaw;
            _mode.OnEnter(ModeArgument.None);
        }
예제 #14
0
        public override void DrawInspector()
        {
            placementMode = (PlacementMode)EditorGUILayout.EnumPopup("Placement Mode", placementMode);
            if (placementMode != PlacementMode.Insert)
            {
                normalMode = (NormalMode)EditorGUILayout.EnumPopup("Normal Mode", normalMode);
                appendMode = (AppendMode)EditorGUILayout.EnumPopup("Append To", appendMode);
            }
            string offsetLabel = "Grid Offset";

            if (placementMode == PlacementMode.CameraPlane)
            {
                offsetLabel = "Far Plane";
            }
            if (placementMode == PlacementMode.Surface)
            {
                offsetLabel = "Surface Offset";
            }
            offset = EditorGUILayout.FloatField(offsetLabel, offset);
            if (placementMode == PlacementMode.Surface)
            {
                surfaceLayerMask = DreamteckEditorGUI.LayermaskField("Surface Mask", surfaceLayerMask);
            }
        }
예제 #15
0
    public static float [,] GenerateNoiseMap(int mapWidth, int mapHeight, int seed, float scale, int octaves, float persistance, float lacunarity, Vector2 offset, NormalMode normal)
    {
        float[,] noiseMap = new float[mapWidth, mapHeight];

        System.Random prng          = new System.Random(seed);
        Vector2[]     octaveOffsets = new Vector2[octaves];

        float MaxAllowedHeight = 0;
        float amplitude        = 1;
        float frequency        = 1;

        for (int i = 0; i < octaves; i++)
        {
            float offsetX = prng.Next(-100000, 100000) + offset.x;
            float offsetY = prng.Next(-100000, 100000) - offset.y;
            octaveOffsets[i] = new Vector2(offsetX, offsetY);

            MaxAllowedHeight += amplitude;
            amplitude        *= persistance;
        }

        if (scale <= 0)
        {
            scale = 0.0001f;
        }

        float maxNoiseHeight = float.MinValue;
        float minNoiseHeight = float.MaxValue;

        float halfWidth  = mapWidth / 2f;
        float halfHeight = mapHeight / 2f;

        for (int y = 0; y < mapHeight; y++)
        {
            for (int x = 0; x < mapWidth; x++)
            {
                amplitude = 1;
                frequency = 1;
                float noiseHeight = 0;

                for (int i = 0; i < octaves; i++)
                {
                    float samplex = (x - halfWidth + octaveOffsets[i].x) / scale * frequency;
                    float sampley = (y - halfHeight + octaveOffsets[i].y) / scale * frequency;

                    float perlinValue = Mathf.PerlinNoise(samplex, sampley) * 2 - 1;
                    noiseHeight += perlinValue * amplitude;

                    amplitude *= persistance;
                    frequency *= lacunarity;
                }

                if (noiseHeight > maxNoiseHeight)
                {
                    maxNoiseHeight = noiseHeight;
                }

                else if (noiseHeight < minNoiseHeight)
                {
                    minNoiseHeight = noiseHeight;
                }

                noiseMap[x, y] = noiseHeight;
            }
        }

        for (int y = 0; y < mapHeight; y++)
        {
            for (int x = 0; x < mapWidth; x++)
            {
                if (normal == NormalMode.Local)
                {
                    noiseMap[x, y] = Mathf.InverseLerp(minNoiseHeight, maxNoiseHeight, noiseMap[x, y]);
                }
                else
                {
                    float normalHeight = (noiseMap[x, y] + 1) / (MaxAllowedHeight);
                    noiseMap[x, y] = Mathf.Clamp(normalHeight, 0, int.MaxValue);
                }
            }
        }

        return(noiseMap);
    }
예제 #16
0
        public void CreateCore(IMotionUtil motionUtil, params string[] lines)
        {
            _textView = CreateTextView(lines);
            _textView.Caret.MoveTo(new SnapshotPoint(_textView.TextSnapshot, 0));
            _unnamedRegister = Vim.RegisterMap.GetRegister(RegisterName.Unnamed);
            _factory = new MockRepository(MockBehavior.Strict);
            _incrementalSearch = MockObjectFactory.CreateIncrementalSearch(factory: _factory);
            _commandUtil = _factory.Create<ICommandUtil>();
            _displayWindowBroker = _factory.Create<IDisplayWindowBroker>(MockBehavior.Strict);
            _displayWindowBroker.SetupGet(x => x.IsCompletionActive).Returns(false);
            _displayWindowBroker.SetupGet(x => x.IsSignatureHelpActive).Returns(false);
            _displayWindowBroker.SetupGet(x => x.IsSmartTagSessionActive).Returns(false);

            _globalSettings = Vim.GlobalSettings;

            var vimTextBuffer = Vim.CreateVimTextBuffer(_textView.TextBuffer);
            var vimBufferData = CreateVimBufferData(vimTextBuffer, _textView);
            var operations = CommonOperationsFactory.GetCommonOperations(vimBufferData);
            motionUtil = motionUtil ?? new MotionUtil(vimBufferData);

            var capture = new MotionCapture(vimBufferData, _incrementalSearch.Object);
            var runner = new CommandRunner(
                _textView,
                Vim.RegisterMap,
                capture,
                _commandUtil.Object,
                vimBufferData.StatusUtil,
                VisualKind.Character);
            _modeRaw = new NormalMode(
                vimBufferData,
                operations,
                motionUtil,
                _displayWindowBroker.Object,
                runner,
                capture);
            _mode = _modeRaw;
            _mode.OnEnter(ModeArgument.None);
        }
예제 #17
0
        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (this.Manager.KeyPressed(Keys.M))
            {
                switch (fDrawMode)
                {
                case DrawMode.Grid:
                    CurrentDrawMode = DrawMode.Solid;
                    break;

                case DrawMode.Solid:
                    CurrentDrawMode = DrawMode.WireFrame;
                    break;

                case DrawMode.WireFrame:
                    CurrentDrawMode = DrawMode.Grid;
                    break;
                }
            }
            else if (this.Manager.KeyPressed(Keys.C))
            {
                switch (fColorMode)
                {
                case ColorMode.Points:
                    CurrentColorMode = ColorMode.SkyBlue;
                    break;

                case ColorMode.SkyBlue:
                    CurrentColorMode = ColorMode.Points;
                    break;
                }
            }
            else if (this.Manager.KeyPressed(Keys.N))
            {
                switch (fNormalMode)
                {
                case NormalMode.Crazy:
                    CurrentNormalMode = NormalMode.Standard;
                    break;

                case NormalMode.Standard:
                    CurrentNormalMode = NormalMode.Crazy;
                    break;
                }
            }

            fCamera.Update(gameTime);

            double seconds = gameTime.TotalGameTime.TotalSeconds;

            if (!fHalted)
            {
                fUpdateDiagram = true;
            }

            fUpdateDiagram = fUpdateDiagram || fUpdatePlane;
            fUpdateColors  = fUpdateColors || fUpdateDiagram;
            fUpdateNormals = fUpdateNormals || fUpdateDiagram;

            if (fUpdatePlane)
            {
                SetPlane();
            }
            int max = fPlane.Segments;

            if (fUpdateDiagram)
            {
                fUpdateDiagram = false;
                for (int x = 0; x <= max; x++)
                {
                    float nX = 2.0f * (float)x / max - 1.0f;// -1 to +1
                    for (int z = 0; z <= max; z++)
                    {
                        float  nZ = 2.0f * (float)z / max - 1.0f;
                        double r  = Math.Sqrt(nX * nX + nZ * nZ);
                        // function
                        double y = nX * Math.Cos(r * 7.0f - seconds * 4.2f) +
                                   nZ * Math.Sin((r - 0.5) * 10.0f - seconds * 1.9f);

                        float height = 200.0f * (float)y;
                        fPlane.SetHeight(x, z, height);
                    }
                }
            }
            if (fUpdateColors)
            {
                SetColors();
            }
            if (fUpdateNormals)
            {
                switch (fNormalMode)
                {
                case NormalMode.Crazy:
                    for (int x = 0; x <= max; x++)
                    {
                        float nX = 2.0f * (float)x / max - 1.0f;    // -1 to +1
                        for (int z = 0; z <= max; z++)
                        {
                            float nZ = 2.0f * (float)z / max - 1.0f;
                            // function
                            double r = Math.Sqrt(nX * nX + nZ * nZ);
                            VertexPositionNormalColor p = fPlane.GetPoint(x, z);
                            p.Normal = Vector3.Normalize(new Vector3(
                                                             Convert.ToSingle(Math.Cos(r * 1.0f + 0.5f - seconds * 0.1f)),
                                                             Convert.ToSingle(Math.Cos(r * 2.0f + 2.1f - seconds * 0.2f)),
                                                             Convert.ToSingle(Math.Cos(r * 5.1f * seconds))));
                            fPlane.SetPoint(x, z, p);
                        }
                    }
                    break;

                case NormalMode.Standard:
                    fPlane.GenerateNormals();
                    break;
                }
            }

            base.Update(gameTime);
        }
예제 #18
0
        public void CreateCore(IMotionUtil motionUtil, params string[] lines)
        {
            _textView = EditorUtil.CreateTextView(lines);
            _textView.Caret.MoveTo(new SnapshotPoint(_textView.TextSnapshot, 0));
            _map = VimUtil.CreateRegisterMap(MockObjectFactory.CreateClipboardDevice().Object);
            _unnamedRegister = _map.GetRegister(RegisterName.Unnamed);
            _factory = new MockRepository(MockBehavior.Strict);
            _editorOperations = _factory.Create<IEditorOperations>(MockBehavior.Loose);
            _incrementalSearch = MockObjectFactory.CreateIncrementalSearch(factory: _factory);
            _jumpList = _factory.Create<IJumpList>(MockBehavior.Strict);
            _statusUtil = _factory.Create<IStatusUtil>(MockBehavior.Strict);
            _foldManager = _factory.Create<IFoldManager>(MockBehavior.Strict);
            _host = _factory.Create<IVimHost>(MockBehavior.Loose);
            _commandUtil = _factory.Create<ICommandUtil>();
            _displayWindowBroker = _factory.Create<IDisplayWindowBroker>(MockBehavior.Strict);
            _displayWindowBroker.SetupGet(x => x.IsCompletionActive).Returns(false);
            _displayWindowBroker.SetupGet(x => x.IsSignatureHelpActive).Returns(false);
            _displayWindowBroker.SetupGet(x => x.IsSmartTagSessionActive).Returns(false);
            _vimData = new VimData();

            _globalSettings = new Vim.GlobalSettings();
            _localSettings = new LocalSettings(_globalSettings, EditorUtil.GetEditorOptions(_textView), _textView);
            motionUtil = motionUtil ?? VimUtil.CreateTextViewMotionUtil(
                _textView,
                new MarkMap(new TrackingLineColumnService()),
                _localSettings);
            _buffer = MockObjectFactory.CreateVimBuffer(
                _textView,
                "test",
                MockObjectFactory.CreateVim(_map, host: _host.Object, vimData: _vimData).Object,
                _jumpList.Object,
                incrementalSearch: _incrementalSearch.Object,
                motionUtil: motionUtil,
                settings: _localSettings);
            _operations = _factory.Create<ICommonOperations>(MockBehavior.Strict);
            _operations.SetupGet(x => x.EditorOperations).Returns(_editorOperations.Object);
            _operations.SetupGet(x => x.TextView).Returns(_textView);

            var capture = new MotionCapture(
                _host.Object,
                _textView,
                _incrementalSearch.Object,
                new LocalSettings(new GlobalSettings(), EditorUtil.GetEditorOptions(_textView), _textView));
            var runner = new CommandRunner(_textView, _map, capture, _commandUtil.Object, _statusUtil.Object, VisualKind.Character);
            _modeRaw = new NormalMode(
                _buffer.Object,
                _operations.Object,
                _statusUtil.Object,
                _displayWindowBroker.Object,
                runner,
                capture);
            _mode = _modeRaw;
            _mode.OnEnter(ModeArgument.None);
        }