Пример #1
0
        private void Start()
        {
            if (HeadCamera != null && TopCamera != null)
            {
                HeadCamera.enabled = true;
                TopCamera.enabled  = false;
            }

            knownActions.Add("Strafe");
            knownActions.Add("Vertical");
            knownActions.Add("Horizontal");
            knownActions.Add("Action");
            knownActions.Add("");

            RotateTo(m_CurrentDirection, false);

            MapGenerator.getInstance().Initialize();

            new Thread(o =>
            {
                var player = new Player();
                player.Start();
                while (true)
                {
                    player.Tick();
                    Thread.Sleep(1);
                }
            }).Start();
        }
Пример #2
0
        private Color GetCellColor(Vector2 location)
        {
            var mapGenerator = MapGenerator.getInstance();

            Color result          = new Color(0, 0, 0, 0);
            int   highestPriority = int.MinValue;

            var mapBlock = mapGenerator.GetBlockAtLocation(location);

            if (mapBlock == null)
            {
                return(result);
            }

            foreach (var gameObject in mapBlock.GameObjects)
            {
                var component = gameObject.GetComponent <Map.AbstractGameObjectController>();
                if (component != null && component.MinimapColorPriority > highestPriority)
                {
                    result          = component.MinimapColor;
                    result.a        = 1.0f;
                    highestPriority = component.MinimapColorPriority;
                }
            }

            return(result);
        }
Пример #3
0
        void OnGUI()
        {
            if (!MapGenerator.getInstance().IsMapLoaded)
            {
                return;
            }

            float Size = SmallSize;

            if (UseLarge)
            {
                Size = LargeSize;
            }

            _frameRect = new Rect(0, 0, Screen.height * Size / 100.0f, Screen.height * Size / 100.0f);
            _cellSize  = Mathf.Min(_frameRect.xMax / Columns, _frameRect.yMax / Rows);

            if (_quads == null)
            {
                _quads = new Dictionary <Vector2, Texture2D>();
                for (var j = 0; j < Rows; j++)
                {
                    for (var i = 0; i < Columns; i++)
                    {
                        _quads.Add(new Vector2(i, j), new Texture2D(1, 1));
                    }
                }
            }

            if (_backgroundQuad == null)
            {
                _backgroundQuad = new Texture2D(1, 1);
                _backgroundQuad.SetPixel(0, 0, new Color(0, 0, 0, 0.4f));
                _backgroundQuad.Apply();
            }
            DrawQuad(_frameRect, _backgroundQuad);

            if (_border == null)
            {
                _border = new Texture2D(1, 1);
                _border.SetPixel(0, 0, new Color(0.8f, 0.46f, 0.0f));
                _border.Apply();
            }
            DrawQuad(new Rect(0, _frameRect.xMax, _frameRect.xMax + 6, 4), _border);
            DrawQuad(new Rect(_frameRect.xMax, 0, 4, _frameRect.xMax), _border);

            if (_playerQuad == null)
            {
                _playerQuad = new Texture2D(1, 1);
                _playerQuad.SetPixel(0, 0, Color.red);
                _playerQuad.Apply();
            }

            foreach (var cell in Cells)
            {
                if (!visited.Contains(cell))
                {
                    continue;
                }
                var quad = _quads[cell];
                quad.SetPixel(0, 0, GetCellColor(cell));
                quad.Apply();

                DrawCell(cell, quad);
            }

            DrawCell(PlayerLocation, _playerQuad);
        }