Exemplo n.º 1
0
        private List <ObjGroup> CreateRenderGameObjects()
        {
            Dictionary <ObjectGame.ObjcetIds, PlainBmpTexture> gameObjectsTextures =
                RenderObjects.RenderObjects.CreateGameObjectsTextures(new Size(20, 20), program);
            List <ObjGroup>   tempObjList = new List <ObjGroup>();
            List <ObjectGame> gameObjects = TheGameStatus.GameObjects;

            foreach (ObjectGame gameObject in gameObjects)
            {
                Vector             tempLoc;
                ObjGroupGameObject tempGroup = null;
                ObjGameObject      tempObjObject;
                switch (gameObject.TheObjectId)
                {
                case ObjectGame.ObjcetIds.Player:
                    tempGroup = new ObjGroupGameObjectPlayer(program)
                    {
                        TheObjectGame = gameObject
                    };
                    tempLoc       = new Vector(0.0f, 0.0f);
                    tempLoc      -= new Vector(gameObject.Diameter * 0.5f, gameObject.Diameter * 0.5f);
                    tempObjObject =
                        new ObjGameObject(ObjectPrimitives.CreateCube(new Vector3(tempLoc.X, 0, tempLoc.Y),
                                                                      new Vector3(tempLoc.X + gameObject.Diameter, gameObject.Diameter,
                                                                                  tempLoc.Y + gameObject.Diameter),
                                                                      true));
                    ObjMaterial tempMaterial = TheResourceManager.GetFromFile(program, "tileTestMike200x200.png");
                    tempObjObject.Material = tempMaterial;
                    tempGroup.AddObject(tempObjObject);
                    playerObjObject    = tempGroup;
                    tempGroup.Location = gameObject.Location;
                    break;

                case ObjectGame.ObjcetIds.Enemy:
                    tempGroup = new ObjGroupGameObjectEnemy(program)
                    {
                        TheObjectGame = gameObject
                    };
                    tempLoc       = new Vector(0.0f, 0.0f);
                    tempLoc      -= new Vector(gameObject.Diameter * 0.5f, gameObject.Diameter * 0.5f);
                    tempObjObject =
                        new ObjGameObject(ObjectPrimitives.CreateCube(new Vector3(tempLoc.X, 0, tempLoc.Y),
                                                                      new Vector3(tempLoc.X + gameObject.Diameter, gameObject.Diameter,
                                                                                  tempLoc.Y + gameObject.Diameter),
                                                                      true));
                    ObjMaterial tempMaterial1 = TheResourceManager.GetFromFile(program, "tileTestMike200x200.png");
                    tempObjObject.Material = tempMaterial1;
                    tempGroup.AddObject(tempObjObject);
                    tempGroup.Location = gameObject.Location;
                    break;

                case ObjectGame.ObjcetIds.Turret:

                    ObjGroup     tempGroup1 = ObjLoader.LoadObjFileToObjMesh(program, @"./Resources/Models/Turret1.obj");
                    ObjectTurret tempTurret = (ObjectTurret)gameObject;
                    tempGroup = new ObjGroupGameObjectTurret(tempGroup1)
                    {
                        Location      = gameObject.Location,
                        Scale         = Vector3.UnitScale * 0.3f,
                        TheObjectGame = tempTurret
                    };
                    //                        tempGroup.Orientation = tempTurret.Orientation;

                    break;

                default:
                    tempLoc       = new Vector(0.0f, 0.0f);
                    tempLoc      -= new Vector(gameObject.Diameter * 0.5f, gameObject.Diameter * 0.5f);
                    tempObjObject =
                        new ObjGameObject(ObjectPrimitives.CreateCube(new Vector3(tempLoc.X, 0, tempLoc.Y),
                                                                      new Vector3(tempLoc.X + gameObject.Diameter, gameObject.Diameter,
                                                                                  tempLoc.Y + gameObject.Diameter),
                                                                      true))
                    {
                        Material = gameObjectsTextures[gameObject.TheObjectId].Material
                    };

                    tempGroup.AddObject(tempObjObject);
                    tempGroup.TheObjectGame = gameObject;
                    break;
                }

                tempObjList.Add(tempGroup);
            }
            return(tempObjList);
        }
Exemplo n.º 2
0
        internal static GameStatus CreatTestGame()
        {
            GameStatus tempGameStatus = new GameStatus {
                TheMap = LoadMapObjectFromFile("test1")
            };
            //            GameStatus tempGameStatus = new GameStatus {TheMap = Map.Map.CreateTestMap()};
            ObjectPlayer tempPlayer = new ObjectPlayer(ObjectGame.ObjcetIds.Player)
            {
                Location = new Vector3(10.3f, 0.0f, 5.6f)
            };

            tempGameStatus.ThePlayer = tempPlayer;
            tempGameStatus.GameObjects.Add(tempPlayer);

            ObjectEnemy tempEnemy = new ObjectEnemy(ObjectGame.ObjcetIds.Enemy)
            {
                Location = new Vector3(15.0, 0.0, 20.0)
            };

            tempGameStatus.GameObjects.Add(tempEnemy);


            ObjectTurret tempTurret = new ObjectTurret(ObjectGame.ObjcetIds.Turret)
            {
                Location         = new Vector3(20.0f, 0.0f, 20.0f),
                Orientation      = new Vector3(0.0, 0.0f, 1.0),
                OrientationTower = 0.5f
//                OrientationTower = new Vector3(0.5, 0.0f, 0.5)
            };

            tempGameStatus.GameObjects.Add(tempTurret);


            tempTurret = new ObjectTurret(ObjectGame.ObjcetIds.Turret)
            {
                Location         = new Vector3(30.0f, 0.0f, 25.0f),
                Orientation      = new Vector3(0.0f, 0.0f, 1.0f),
                OrientationTower = 0.1f
//                OrientationTower = new Vector3(0.5f, 0.0f, 0.5f)
            };
            tempGameStatus.GameObjects.Add(tempTurret);

            tempTurret = new ObjectTurret(ObjectGame.ObjcetIds.Turret)
            {
                Location         = new Vector3(31, 0.0f, 22),
                Orientation      = new Vector3(0.0, 0.0f, 1.0),
                OrientationTower = 1.0f
//                OrientationTower = new Vector3(0.5, 0.0f, 0.5)
            };
            tempGameStatus.GameObjects.Add(tempTurret);

            tempTurret = new ObjectTurret(ObjectGame.ObjcetIds.Turret)
            {
                Location         = new Vector3(27, 0.0f, 18),
                Orientation      = new Vector3(0.0, 0.0f, 1.0),
                OrientationTower = 2.7f
//                OrientationTower = new Vector3(0.5, 0.0f, 0.5)
            };
            tempGameStatus.GameObjects.Add(tempTurret);

            return(tempGameStatus);
        }