protected VideoProcessor()
        {
            m_opencv = OpenCVController.GetSingletonInstance();
            viewer = new ImageViewer();
            vs = VisualData.GetSingleton();
            viewer.Show();
            this.ColorWriteBitmap = new WriteableBitmap(FrameWidth, FrameHeight, 96.0, 96.0,
                System.Windows.Media.PixelFormats.Bgr24, null);
            this.DepthWriteBitmap = new WriteableBitmap(FrameWidth, FrameHeight, 96.0, 96.0,
                System.Windows.Media.PixelFormats.Bgr24, null);
            this.WrtBMP_RightHandFront = new WriteableBitmap(handShapeWidth, handShapeHeight, 96.0, 96.0,
                System.Windows.Media.PixelFormats.Gray8, null);
            this.WrtBMP_LeftHandFront = new WriteableBitmap(handShapeWidth, handShapeHeight, 96.0, 96.0,
                System.Windows.Media.PixelFormats.Gray8, null);

            rightHandPosition = new System.Drawing.Point();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            IGH_Goo trailData   = null;
            IGH_Goo colorData   = null;
            bool    texture     = new bool();
            object  displayMode = null;

            VisualData visualData = new VisualData();

            if (!DA.GetData(0, ref trailData) || trailData == null)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "No Trail Data Detected, please connect Trail Data to enable the component");
                return;
            }
            DA.GetData(1, ref colorData);
            string dataType = trailData.GetType().Name.ToString();

            if (trailData.ToString() == "Culebra_GH.Data_Structures.TrailData")
            {
                TrailData td;
                bool      worked = trailData.CastTo(out td);
                if (worked)
                {
                    visualData.trailData = td;
                }
                else
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Could not convert trail data, ensure you have the correct inputs");
                    return;
                }
            }
            else
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Please input Trail Data Output value for Trail Data not a " + dataType);
                return;
            }
            if (colorData != null)
            {
                string colorType = colorData.GetType().Name.ToString();
                if (colorData.ToString() == "Culebra_GH.Data_Structures.ColorData")
                {
                    ColorData cd;
                    bool      worked = colorData.CastTo(out cd);
                    if (worked)
                    {
                        visualData.colorData = cd;
                    }
                    else
                    {
                        AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Could not convert color data, ensure you have the correct inputs");
                        return;
                    }
                }
                else
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Please input Trail Data Output value for Trail Data not a " + colorType);
                    return;
                }
            }
            else
            {
                ColorData color = new ColorData();
                color.colorDataType  = "Base";
                visualData.colorData = color;
            }
            if (!DA.GetData(2, ref texture))
            {
                return;
            }
            if (texture)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "WARNING USING TEXTURE CAN MAKE THE SIMULATION VERY UNSTABLE AND MAY CRASH WITHOUT WARNING, I RECOMMEND USING THE GH BUILT IN CLOUD DISPLAY FOR THE CREEPERS OUTPUT");
            }
            visualData.useTexture = texture;

            if (!DA.GetData(3, ref displayMode))
            {
                return;
            }
            string type2 = displayMode.GetType().Name.ToString();

            if (displayMode.GetType() != typeof(GH_Integer) && displayMode.GetType() != typeof(GH_Number))
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Please input a integer/float value for Display Mode not a " + type2);
                return;
            }
            else
            {
                if (displayMode.GetType() == typeof(GH_Integer))
                {
                    GH_Integer ghInt = (GH_Integer)displayMode;
                    visualData.displayMode = ghInt.Value;
                }
                else
                {
                    GH_Number ghNum = (GH_Number)displayMode;
                    visualData.displayMode = Convert.ToInt32(ghNum.Value);
                }
            }
            IGH_VisualData igh_Viz = new IGH_VisualData(visualData);

            DA.SetData(0, igh_Viz);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Constructs a new leaf node.
 /// </summary>
 /// <param name="visualData">visual data</param>
 public BFSLeaf(VisualData visualData)
 {
     this.visualData = visualData;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Creates a new BFSInnerNode.
 /// </summary>
 /// <param name="childMask">child-mask</param>
 /// <param name="childIndex">child-pointer</param>
 /// <param name="visualData">visual data</param>
 public BFSInnerNode(uint childMask, uint childIndex, VisualData visualData)
 {
     this.childMask = childMask;
     this.childIndex = childIndex;
     this.visualData = visualData;
 }
Ejemplo n.º 5
0
        public Game(Form1 f)
        {
            Worlds = new List <WorldConfig>()
            {
                new WorldConfig()
                {
                    Name      = "\"BOX\"",
                    Size      = new Size(15, 15),
                    TileWidth = 64,
                    Lives     = 5,
                    Couches   = new List <ObstacleConfig> ()
                    {
                        new ObstacleConfig {
                            Position = new Point(8, 2), Orientation = ObstacleOrientation.FrontDown
                        },
                        new ObstacleConfig {
                            Position = new Point(8, 14), Orientation = ObstacleOrientation.FrontUp
                        },
                        new ObstacleConfig {
                            Position = new Point(2, 8), Orientation = ObstacleOrientation.FrontRight
                        },
                        new ObstacleConfig {
                            Position = new Point(14, 8), Orientation = ObstacleOrientation.FrontLeft
                        }
                    },
                    Walls = new List <ObstacleConfig>()
                },
                new WorldConfig()
                {
                    Name      = "\"CORRIDOR\"",
                    Size      = new Size(20, 8),
                    TileWidth = 64,
                    Lives     = 5,
                    Couches   = new List <ObstacleConfig> ()
                    {
                        new ObstacleConfig
                        {
                            Position    = new Point(6, 4),
                            Orientation = ObstacleOrientation.FrontDown
                        },
                        new ObstacleConfig
                        {
                            Position    = new Point(15, 4),
                            Orientation = ObstacleOrientation.FrontDown
                        }
                    },
                    Walls = new List <ObstacleConfig>()
                },
                new WorldConfig()
                {
                    Name      = "\"ARENA\"",
                    Size      = new Size(15, 15),
                    TileWidth = 64,
                    Lives     = 3,
                    Couches   = new List <ObstacleConfig> (),
                    Walls     = new List <ObstacleConfig>()
                },
                new WorldConfig()
                {
                    Name      = "\"MAZE\"",
                    Size      = new Size(15, 10),
                    TileWidth = 64,
                    Lives     = 4,
                    Couches   = new List <ObstacleConfig>(),
                    Walls     = new List <ObstacleConfig>()
                    {
                        new ObstacleConfig()
                        {
                            Position = new Point(3, 3)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(3, 2)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(2, 3)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(2, 7)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(3, 7)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(2, 8)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(5, 5)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(5, 6)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(5, 7)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(5, 8)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(6, 5)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(6, 1)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(7, 5)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(8, 5)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(9, 5)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(10, 5)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(7, 8)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(8, 7)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(8, 8)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(9, 8)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(10, 8)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(5, 3)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(6, 3)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(7, 3)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(12, 4)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(12, 1)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(12, 3)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(13, 9)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(13, 8)
                        }
                    }
                },
                new WorldConfig()
                {
                    Name      = "\"TWO ROOMS\"",
                    Size      = new Size(13, 13),
                    TileWidth = 64,
                    Lives     = 4,
                    Couches   = new List <ObstacleConfig>()
                    {
                        new ObstacleConfig
                        {
                            Position    = new Point(2, 4),
                            Orientation = ObstacleOrientation.FrontRight
                        },
                        new ObstacleConfig
                        {
                            Position    = new Point(12, 10),
                            Orientation = ObstacleOrientation.FrontLeft
                        }
                    },
                    Walls = new List <ObstacleConfig>()
                    {
                        new ObstacleConfig()
                        {
                            Position = new Point(6, 1)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(6, 2)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(6, 3)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(6, 4)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(6, 9)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(6, 10)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(6, 11)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(6, 12)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(7, 1)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(7, 2)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(7, 3)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(7, 4)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(7, 9)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(7, 10)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(7, 11)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(7, 12)
                        }
                    }
                },
                new WorldConfig()
                {
                    Name      = "\"BOX IN A BOX\"",
                    Size      = new Size(16, 15),
                    TileWidth = 64,
                    Lives     = 4,
                    Couches   = new List <ObstacleConfig>()
                    {
                        new ObstacleConfig
                        {
                            Position    = new Point(6, 8),
                            Orientation = ObstacleOrientation.FrontRight
                        },
                        new ObstacleConfig
                        {
                            Position    = new Point(11, 8),
                            Orientation = ObstacleOrientation.FrontLeft
                        }
                    },
                    Walls = new List <ObstacleConfig>()
                    {
                        new ObstacleConfig()
                        {
                            Position = new Point(4, 9)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(4, 10)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(4, 11)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(4, 8)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(4, 7)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(4, 6)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(4, 5)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(4, 4)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(5, 4)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(6, 4)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(10, 4)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(11, 4)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(12, 4)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(12, 5)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(12, 6)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(12, 7)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(12, 8)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(12, 9)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(12, 10)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(12, 11)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(5, 11)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(6, 11)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(10, 11)
                        },
                        new ObstacleConfig()
                        {
                            Position = new Point(11, 11)
                        }
                    }
                }
            };

            #region game data
            _gameData    = new GameData();
            _dataManager = new DataManager(this);
            if (_gameData.TopPlayers != null && _gameData.TopPlayers.GetLength(0) != Worlds.Count)
            {
                _gameData.TopPlayers       = null;
                _gameData.LedearboardIndex = 0;
            }
            if (_gameData.TopPlayers != null)
            {
                var maxInd = 0;
                for (int i = 0; i < _gameData.LedearboardLength; i++)
                {
                    if (_gameData.TopPlayers[currentWorld][i].Score > _gameData.TopPlayers[currentWorld][maxInd].Score)
                    {
                        maxInd = i;
                    }
                }
                BestScore = _gameData.TopPlayers[currentWorld][maxInd].Score;
            }
            #endregion


            form  = f;
            State = GameState.Menu;
            VisualData.Load();
            currentWorld    = 1;
            _currentWorld   = new World(Worlds[currentWorld], this);
            controller      = new Controller(_currentWorld, this);
            _shopController = new ShopController(this);
            PlayerName      = "";
            gameHUD         = new HUD(this, form);



            GameLost += ShowGameLostDialog;
        }
        /// <summary>
        /// Визуализация датасета
        /// </summary>
        public void Visualis()
        {
            VisualData vd = new VisualData(this);

            vd.Show();
        }