Exemplo n.º 1
0
        /// <summary>
        /// Initialize scene
        /// </summary>
        protected override void CreateScene()
        {
            // Scene configuration
            RenderManager.BackgroundColor = new Color(255 / 255f, 255 / 255f, 192 / 255f);
            RenderManager.DebugLines      = false;
            PhysicsManager.Gravity3D      = new Vector3(0, -120, 0);

            // Camera
            FreeCamera mainCamera = new FreeCamera("MainCamera", new Vector3(-150, 80, 180), Vector3.Zero)
            {
                Speed = 100,
            };

            mainCamera.Entity.AddComponent(new CombineBehavior());
            mainCamera.Entity.AddComponent(new PickingBehavior());
            //mainCamera.Entity.AddComponent(new LaunchBehavior());
            EntityManager.Add(mainCamera.Entity);
            RenderManager.SetActiveCamera(mainCamera.Entity);

            // Room
            Entity stockRoom = new Entity("StockRoom")
                               .AddComponent(new Transform3D())
                               .AddComponent(new Model("Content/Models/stockRoomFull.wpk"))
                               .AddComponent(new MaterialsMap(new BasicMaterial("Content/Textures/roomTexture.wpk")))
                               .AddComponent(new ModelRenderer());

            EntityManager.Add(stockRoom);



            // Ground
            CreateStaticEntities();

            // Boxes
            CreateEmiterBox();

            //CreateBoxStack();

            //CreateBridge();

            // Help text
            CreateHelpText();

            this.AddSceneBehavior(new MySceneBehavior(), SceneBehavior.Order.PostUpdate);
        }
Exemplo n.º 2
0
        protected override void CreateScene()
        {
            ViewCamera camera = new ViewCamera("MainCamera", new Vector3(2, 1, 2), new Vector3(0, 1, 0));

            camera.BackgroundColor = Color.CornflowerBlue;
            EntityManager.Add(camera.Entity);

            Entity animatedModel = new Entity("Isis")
                                   .AddComponent(new Transform3D())
                                   .AddComponent(new BoxCollider())
                                   .AddComponent(new SkinnedModel("Content/isis.wpk"))
                                   .AddComponent(new MaterialsMap(new BasicMaterial("Content/isis-difuse.wpk")))
                                   .AddComponent(new Animation3D("Content/isis-animations.wpk"))
                                   .AddComponent(new SkinnedModelRenderer());

            anim = animatedModel.FindComponent <Animation3D>();
            EntityManager.Add(animatedModel);
        }
Exemplo n.º 3
0
        protected override void CreateScene()
        {
            var camera = new FreeCamera("MainCamera", new Vector3(0, 0, 2), Vector3.Zero);

            camera.BackgroundColor = Color.CornflowerBlue;
            EntityManager.Add(camera);

            Entity triangle = new Entity()
                              .AddComponent(new Transform3D())
                              //.AddComponent(new Spinner() { IncreaseZ = 0.5f })
                              .AddComponent(new MaterialsMap(new BasicMaterial(Color.White)
            {
                VertexColorEnabled = true
            }))
                              .AddComponent(new CustomGeometryRenderer());

            EntityManager.Add(triangle);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Creates Ground
        /// </summary>
        /// <param name="position">Ground Position</param>
        private void CreateGround(Vector3 position)
        {
            Entity primitive = new Entity("ground" + instance++)
                               .AddComponent(new Transform3D()
            {
                Position = position
            })
                               .AddComponent(new BoxCollider())
                               .AddComponent(Model.CreatePlane(Vector3.Up, 80))
                               .AddComponent(new RigidBody3D()
            {
                IsKinematic = true
            })
                               .AddComponent(new MaterialsMap())
                               .AddComponent(new ModelRenderer());

            EntityManager.Add(primitive);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Creates a Physical Ground
        /// </summary>
        /// <param name="position">Ground position</param>
        /// <param name="collisionGroup">Ground Collision Group</param>
        private void CreateGround(Vector3 position, Physic3DCollisionGroup collisionGroup)
        {
            Entity terrain = new Entity("terrain" + instance++)
                             .AddComponent(new Transform3D()
            {
                Position = position, Scale = new Vector3(4)
            })
                             .AddComponent(new MeshCollider())
                             .AddComponent(new Model("Content/terrain.wpk"))
                             .AddComponent(new RigidBody3D()
            {
                IsKinematic = true, CollisionGroup = collisionGroup, KineticFriction = 10, StaticFriction = 10
            })
                             .AddComponent(new MaterialsMap())
                             .AddComponent(new ModelRenderer());

            EntityManager.Add(terrain);
        }
Exemplo n.º 6
0
        protected override void CreateScene()
        {
            ViewCamera camera = new ViewCamera("Camera", new Vector3(0f, 0f, 5f), Vector3.Zero);

            RenderManager.SetActiveCamera(camera.Entity);

            EntityManager.Add(camera.Entity);

            CreateCube("Cube1", Vector3.Zero);
            CreateCube("Cube2", new Vector3(5f, 0f, 0f));
            CreateCube("Cube3", new Vector3(-5f, 0f, 0f));
            CreateCube("Cube4", new Vector3(5f, 0f, 5f));
            CreateCube("Cube5", new Vector3(-5f, 0f, 5f));
            CreateCube("Cube6", new Vector3(5f, 0f, -5f));
            CreateCube("Cube7", new Vector3(-5f, 0f, -5f));
            CreateCube("Cube8", new Vector3(0f, 0f, 5f));
            CreateCube("Cube9", new Vector3(0f, 0f, -5f));
        }
Exemplo n.º 7
0
        protected override void CreateScene()
        {
            var player = CreatePlayer();
            ThirdPersonCamera thirdPersonCamera = new ThirdPersonCamera("thirdPerson", player);

            RenderManager.SetActiveCamera(thirdPersonCamera.Entity);
            EntityManager.Add(thirdPersonCamera.Entity);


            CreateCube("Cube2", new Vector3(5f, 0f, 0f));
            CreateCube("Cube3", new Vector3(-5f, 0f, 0f));
            CreateCube("Cube4", new Vector3(5f, 0f, 5f));
            CreateCube("Cube5", new Vector3(-5f, 0f, 5f));
            CreateCube("Cube6", new Vector3(5f, 0f, -5f));
            CreateCube("Cube7", new Vector3(-5f, 0f, -5f));

            RenderManager.BackgroundColor = Color.CornflowerBlue;
        }
Exemplo n.º 8
0
        /// <summary>
        /// Creates a Box Ground
        /// </summary>
        private void CreateGround()
        {
            Entity ground = new Entity("ground")
                            .AddComponent(new Transform3D()
            {
                Position = new Vector3(0, -1, 0), Scale = new Vector3(20, 1, 20)
            })
                            .AddComponent(new BoxCollider())
                            .AddComponent(Model.CreateCube())
                            .AddComponent(new RigidBody3D()
            {
                IsKinematic = true
            })
                            .AddComponent(new MaterialsMap(new BasicMaterial(Color.Gray)))
                            .AddComponent(new ModelRenderer());

            EntityManager.Add(ground);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Creates the scene.
        /// </summary>
        /// <remarks>
        /// This method is called before all <see cref="T:WaveEngine.Framework.Entity" /> instances in this instance are initialized.
        /// </remarks>
        protected override void CreateScene()
        {
            Entity camera = new Entity()
                            .AddComponent(new Camera2D()
            {
                ClearFlags = ClearFlags.DepthAndStencil,
            });

            EntityManager.Add(camera);

            this.gameStorage = Catalog.GetItem <GameStorage>();

            this.CreateUI();

#if DEBUG
            this.AddSceneBehavior(new DebugSceneBehavior(), SceneBehavior.Order.PreUpdate);
#endif
        }
Exemplo n.º 10
0
        protected override void CreateScene()
        {
            this.CreateMaterials();

            this.camera = new ViewCamera("camera", new Vector3(0, 5, 13), new Vector3(0, 5, 0))
            {
                FieldOfView = 0.8f,
                NearPlane   = 0.1f
            };
            this.camera.Entity.AddComponent(this.skyboxMaps[this.currentEnv]);
            EntityManager.Add(camera);

            this.CreateVenus();

            this.CreateUI();

            this.UpdateMaterials();
        }
Exemplo n.º 11
0
        private void CreateSphere(string name, Vector3 position)
        {
            Entity primitive = new Entity(name)
                               .AddComponent(new Transform3D()
            {
                Position = position
            })
                               .AddComponent(new SphereCollider3D())
                               .AddComponent(Model.CreateSphere())
                               .AddComponent(new RigidBody3D())
                               .AddComponent(new MaterialsMap()
            {
                DefaultMaterialPath = WaveContent.Assets.basicMaterial
            })
                               .AddComponent(new ModelRenderer());

            EntityManager.Add(primitive);
        }
Exemplo n.º 12
0
        private void AchievementsByCodePanel()
        {
            var unlockAchievementlabel = new TextBlock()
            {
                Text  = "Enter achievement code:",
                Width = 200,
            };
            var unlockAchievementText = new TextBox()
            {
                Text   = string.Empty,
                Height = 60,
                Width  = _buttonWidth,
                Margin = new Thickness(_spaceControl, 0, 0, 0)
            };

            // Unlock achievement by code
            var unlockAchievementCodeButton = new Button()
            {
                Width           = _buttonWidth,
                Height          = _buttonHeight,
                Text            = "Unlock achievement by code",
                Foreground      = _foregroundButton,
                BackgroundColor = _backgroundColor,
                Margin          = new Thickness(_spaceControl, 0, 0, 0)
            };

            unlockAchievementCodeButton.Click += async(s, e) =>
            {
                var code = unlockAchievementText.Text;
                await _socialService.UnlockAchievement(code);
            };

            var sp3 = new StackPanel
            {
                Orientation = Orientation.Horizontal,
                Margin      = new Thickness(100, _topMargin + 5, 0, 0),
            };

            sp3.Add(unlockAchievementlabel);
            sp3.Add(unlockAchievementText);
            sp3.Add(unlockAchievementCodeButton);

            EntityManager.Add(sp3);
        }
Exemplo n.º 13
0
    /**
     * Spawn entities in the arena
     */
    private void SpawnEntities()
    {
        FunctionPeriodic.Create(
            () =>
        {
            if (EntityManager.Count() < _ENTITY_MAX_SPAWNS)
            {
                Vector3 entityWorldPosition = new Vector3(
                    Random.Range(-_MAX_RADIUS, _MAX_RADIUS),
                    AssetManager.Get_Prefab_Entity().transform.localScale.y / 2 + AssetManager.GetTerrain().localScale.y,
                    Random.Range(-_MAX_RADIUS, _MAX_RADIUS)
                    );

                Entity entity = Instantiate(
                    AssetManager.Get_Prefab_Entity(),
                    entityWorldPosition,
                    Quaternion.identity
                    );

                HealthBar healthBar = Instantiate(
                    AssetManager.Get_Prefab_HealthBar(),
                    entity.transform.position + Vector3.up * .2f,
                    entity.transform.rotation
                    );

                healthBar.transform.SetParent(entity.transform);

                entity.Setup(string.Format("Entity_{0}", EntityManager.Count().ToString()), 100f, 100f, 0f, 100f, Random.Range(_MIN_WALK_SPEED, _MAX_WALK_SPEED), Random.Range(_MIN_RUN_SPEED, _MAX_RUN_SPEED), _THROW_IMPULSE_FORCE, healthBar);

                EntityManager.Add(entity);
            }
        },
            "SpawnEntities",
            0f,
            0f,
            () =>
        {
            if (EntityManager.Count() >= _ENTITY_MAX_SPAWNS)
            {
                Destroy(GameObject.Find("SpawnEntities"));
            }
        }
            );
    }
Exemplo n.º 14
0
        private void CreateLeaderBoardByCodePanel()
        {
            var leaderboardlabel = new TextBlock()
            {
                Text  = "Enter leaderboard code:",
                Width = 200,
            };
            var leaderboardCodeText = new TextBox()
            {
                Text   = string.Empty,
                Height = 60,
                Width  = _buttonWidth,
                Margin = new Thickness(_spaceControl, 0, 0, 0)
            };

            // Show leaderboard by code
            var leaderboardCodeButton = new Button()
            {
                Width           = _buttonWidth,
                Height          = _buttonHeight,
                Text            = "Show leaderboard by code",
                Foreground      = _foregroundButton,
                BackgroundColor = _backgroundColor,
                Margin          = new Thickness(_spaceControl, 0, 0, 0)
            };

            leaderboardCodeButton.Click += (s, e) =>
            {
                var code = leaderboardCodeText.Text;
                _socialService.ShowLeaderboard(code);
            };

            var sp4 = new StackPanel
            {
                Orientation = Orientation.Horizontal,
                Margin      = new Thickness(100, _topMargin + 5, 0, 0),
            };

            sp4.Add(leaderboardlabel);
            sp4.Add(leaderboardCodeText);
            sp4.Add(leaderboardCodeButton);

            EntityManager.Add(sp4);
        }
Exemplo n.º 15
0
        protected override void CreateScene()
        {
            var camera2D = new FixedCamera2D("Camera2D")
            {
                BackgroundColor = Color.White
            };

            EntityManager.Add(camera2D);

            int offset = 50;
            var title  = new Entity("Title")
                         .AddComponent(new Sprite("Content/Textures/home.wpk"))
                         .AddComponent(new SpriteRenderer(DefaultLayers.Alpha))
                         .AddComponent(new Transform2D()
            {
                X = 0,
                Y = 0
            });

            EntityManager.Add(title);

            var twoPlayers = new Entity("2Players")
                             .AddComponent(new Transform2D()
            {
                Rectangle = new RectangleF(80, 400, 500, 170)
            })
                             .AddComponent(new RectangleCollider())
                             .AddComponent(new TouchGestures());

            twoPlayers.FindComponent <TouchGestures>().TouchPressed += new EventHandler <GestureEventArgs>(TwoPlayers_TouchPressed);
            EntityManager.Add(twoPlayers);

            var threePlayers = new Entity("3Players")
                               .AddComponent(new Transform2D()
            {
                Rectangle = new RectangleF(730, 400, 520, 170)
            })
                               .AddComponent(new RectangleCollider())
                               .AddComponent(new TouchGestures());

            threePlayers.FindComponent <TouchGestures>().TouchPressed += new EventHandler <GestureEventArgs>(ThreePlayers_TouchPressed);

            EntityManager.Add(threePlayers);
        }
Exemplo n.º 16
0
        public void StartMission(Client player)
        {
            if (player.getData("Livreur") == false || player.getData("Livreur") == null)
            {
                Vector3[]   JobMarkers = { new Vector3(-155.9332,  -1348.11, 29.92623), new Vector3(-64.1832, -1450.629, 32.52178), new Vector3(10.88392, -1669.231, 29.25884), new Vector3(-50.26782, -1783.394, 28.30124),
                                           new Vector3(5.014607,    -1884.653, 23.69442), new Vector3(46.17117, -1864.312, 23.28129), new Vector3(100.2306, -1913.019, 21.16526), new Vector3(130.0086,   -1853.98, 25.00826),new Vector3(128.1205,-1896.221, 23.6725),
                                           new Vector3(170.7524,    -1871.188, 24.40022), new Vector3(374.0941, -1990.498, 24.21575), new Vector3(345.6743, -2014.632, 22.23506) };
                VehicleHash vehicleJob = API.vehicleNameToModel("Boxville4");
                player.setData("Livreur", true);

                Vehicle vehicle = API.createVehicle(vehicleJob, positionVeh, new Vector3(), 20, 20);
                API.setEntitySyncedData(vehicle, "VEHICLE_FUEL", 100);
                API.setEntitySyncedData(vehicle, "VEHICLE_FUEL_MAX", 100);
                API.setEntityData(vehicle, "weight", 0);
                API.setEntityData(vehicle, "weight_max", 0);
                string plate = Vehicles.Vehicle.RandomPlate().ToString();
                API.setVehicleNumberPlate(vehicle, plate);
                vehicle.setSyncedData("Livreur", true);
                EntityManager.Add(vehicle);

                API.sendNotificationToPlayer(player, "Monter dans un vehicule et rendez vous au differents markers");
                for (int i = 5; i > 0; i--)
                {
                    Random rnd   = new Random();
                    int    index = rnd.Next(0, JobMarkers.Length - 1);

                    if (i == 5)
                    {
                        API.sendNotificationToPlayer(player, "Vous avez " + i + "colis a livrer, les points de livraison se trouve sur les markers rouge");
                    }
                    else
                    {
                        API.sendNotificationToPlayer(player, "Vous avez encore " + i + "colis a livrer");
                    }
                    MarkerManager(player, JobMarkers[index]);
                }
                player.setData("Mission_finish", true);
                FinMission(player);
            }
            else
            {
                API.sendNotificationToPlayer(player, "Vous avez deja un vehicule de fonction");
            }
        }
Exemplo n.º 17
0
        public static void LoadProperties()
        {
            foreach (var property in ContextFactory.Instance.Property.ToList())
            {
                PropertyController propertyController = new PropertyController(property);
                if (property.Group != null)
                {
                    propertyController.GroupController = EntityManager.GetGroup(property.Group.Id);
                    API.shared.consoleOutput("Loaded property " + property.PropertyID + " with group: " + propertyController.GroupController.Group.Name);
                    if (propertyController.GroupController != null)
                    {
                        string name = property.Group.Name;
                        if (name == null)
                        {
                            propertyController.ownername = "None";
                        }
                        else
                        {
                            propertyController.ownername = property.Name;
                        }

                        if (propertyController.GroupController.Group.Type == GroupType.Business) // If property's group is a business, initialize items.
                        {
                        }
                    }
                }
                else if (property.Character != null)
                {
                    string name = property.Character.Name;
                    if (name == null)
                    {
                        propertyController.ownername = "None";
                    }
                    else
                    {
                        propertyController.ownername = name.Replace("_", " ");
                    }
                }

                propertyController.CreateWorldEntity();
                EntityManager.Add(propertyController);
            }
            API.shared.consoleOutput("[GM] Loaded properties: " + ContextFactory.Instance.Property.Count());
        }
Exemplo n.º 18
0
        /// <summary>
        /// Creates the scene.
        /// </summary>
        /// <remarks>
        /// This method is called before all
        /// <see cref="T:WaveEngine.Framework.Entity" /> instances in this instance are initialized.
        /// </remarks>
        protected override void CreateScene()
        {
            var camera2D = new FixedCamera2D("Camera2D")
            {
                BackgroundColor = Color.CornflowerBlue
            };

            EntityManager.Add(camera2D);


            Entity ground = new Entity("ground")
                            .AddComponent(new Transform2D()
            {
                X = 400, Y = 400, Origin = Vector2.Center
            })
                            .AddComponent(new Sprite("Content/groundSprite.wpk"))
                            .AddComponent(new RectangleCollider())
                            .AddComponent(new RigidBody2D()
            {
                PhysicBodyType = PhysicBodyType.Static
            })
                            .AddComponent(new SpriteRenderer(DefaultLayers.Opaque));

            EntityManager.Add(ground);

            Entity circle = new Entity("Circle")
                            .AddComponent(new Transform2D()
            {
                X = 450, Origin = Vector2.Center
            })
                            .AddComponent(new Sprite("Content/circleSprite.wpk"))
                            .AddComponent(new CircleCollider())
                            .AddComponent(new RigidBody2D())
                            .AddComponent(new SpriteRenderer(DefaultLayers.Alpha));

            EntityManager.Add(circle);

            for (int i = 0; i < 8; i++)
            {
                Entity box = CreateBox(i.ToString(), 300 + i * 5, i * -50);
                EntityManager.Add(box);
            }
        }
Exemplo n.º 19
0
        protected override void CreateScene()
        {
            FreeCamera camera = new FreeCamera("MainCamera", new Vector3(0, 10, 20), new Vector3(0, 5, 0))
            {
                BackgroundColor = Color.CornflowerBlue,
            };

            camera.Entity.AddComponent(new FireBehavior());

            EntityManager.Add(camera.Entity);

            Entity ground = new Entity("Ground")
                            .AddComponent(new Transform3D()
            {
                Position = new Vector3(0, -1, 0), Scale = new Vector3(100, 1, 100)
            })
                            .AddComponent(new BoxCollider())
                            .AddComponent(Model.CreateCube())
                            .AddComponent(new RigidBody3D()
            {
                IsKinematic = true
            })
                            .AddComponent(new MaterialsMap(new BasicMaterial(Color.Gray)))
                            .AddComponent(new ModelRenderer());

            EntityManager.Add(ground);

            int index = 0;

            for (int i = 0; i < 15; i++)
            {
                bool even = (i % 2 == 0);

                for (int e = 0; e < 3; e++)
                {
                    Vector3 size     = (even) ? new Vector3(1, 1, 3) : new Vector3(3, 1, 1);
                    Vector3 position = new Vector3((even ? e : 1.0f), i, (even ? 1.0f : e));
                    Entity  box      = CreateBox("Box" + index++, position, size, 1);

                    EntityManager.Add(box);
                }
            }
        }
Exemplo n.º 20
0
        private void GenerateDemoEmployeesAndUsers(int numberOfEmployees = 20)
        {
            Employee employee;

            for (int i = 1; i <= numberOfEmployees; i++)
            {
                employee = _employeesManager.Add(
                    new Employee(GUIUtils.GetRandomFirstName(), GUIUtils.GetRandomLastName()));

                _usersManager.Add(new User(
                                      employee.EmployeeID,
                                      i == 1 ? UserType.Manager : i < 5 ? UserType.Supervisor : UserType.Worker)
                {
                    UserName = $"user{i:D2}",
                    Password = $"pass{i:D2}"
                }
                                  );
            }
        }
Exemplo n.º 21
0
        private void CreateDebugMode()
        {
            ToggleSwitch debugMode = new ToggleSwitch()
            {
                OnText     = "Debug On",
                OffText    = "Debug Off",
                Margin     = new Thickness(5),
                Width      = 200,
                Foreground = darkColor,
                Background = lightColor,
            };

            debugMode.Toggled += (s, o) =>
            {
                RenderManager.DebugLines = debugMode.IsOn;
            };

            EntityManager.Add(debugMode.Entity);
        }
Exemplo n.º 22
0
 /// <summary>
 /// Create Help text
 /// </summary>
 private void CreateHelpText()
 {
     helpText = new TextBlock()
     {
         VerticalAlignment = VerticalAlignment.Top,
         Margin            = new Thickness(20, 20, 0, 0),
         Text = "Key H show/hide help text \n" +
                "Key F1 diagnostics mode \n" +
                "Key F5 Emiter boxes scene \n" +
                "Key F6 Wall boxes scene \n" +
                "Key F7 Bridge scene \n" +
                "Key R restart scene \n" +
                "Key G change gravity direction \n" +
                "Key W, A, S, D move camera \n" +
                "Key 1 apply impulse mode \n" +
                "Key 2 launch ball mode"
     };
     EntityManager.Add(helpText.Entity);
 }
Exemplo n.º 23
0
        private void CreateTexturedToast(bool[,] texture, string name, string text, Vector2 position)
        {
            bool[,] scaledTexture = BoolToTextureConverter.ScaleTexture(texture, 80, 80);

            TextBlock textBlock = new TextBlock(name + "Text")
            {
                Foreground = Color.Black,
                Text       = text,
                Margin     = new Thickness(position.X - 50, position.Y - 75, 0, 0),
            };

            EntityManager.Add(textBlock);

            Entity previewToast = new Entity(name + "Toast")
                                  .AddComponent(new Sprite("Assets/Textures/toast_2D.wpk"))
                                  .AddComponent(new SpriteRenderer(DefaultLayers.Alpha))
                                  .AddComponent(new Transform2D()
            {
                Opacity   = 1,
                X         = position.X,
                Y         = position.Y,
                DrawOrder = 0.1f,
                XScale    = 0.2f,
                YScale    = 0.2f,
                Origin    = Vector2.Center,
            });

            EntityManager.Add(previewToast);

            Entity previewModel = new Entity(name + "Texture")
                                  .AddComponent(new Sprite(BoolToTextureConverter.TxdFromBoolArray(scaledTexture, this.RenderManager)))
                                  .AddComponent(new SpriteRenderer(DefaultLayers.Alpha))
                                  .AddComponent(new Transform2D()
            {
                Opacity   = 1,
                X         = position.X,
                Y         = position.Y,
                DrawOrder = 0.05f,
                Origin    = Vector2.Center,
            });

            EntityManager.Add(previewModel);
        }
Exemplo n.º 24
0
        public Player(Vector2f spawnPositon, IPlayerController playerController, Texture[] playerTexture, Texture healthBarTexture, EntityManager manager, Camera _camera)
        {
            _textures = playerTexture;

            manager.Add(new HealthBar(healthBarTexture, this));

            canBeHitByBullet = true;

            _playerController = playerController;

            _sprite = new Sprite {
                Position    = spawnPositon,
                TextureRect = _animations[(int)Direction.DOWN].GetShape(),
                Origin      = new Vector2f(_animations[0].GetShape().Width * 0.5f, _animations[0].GetShape().Height * 0.5f)
            };
            _currentDirection = Direction.DOWN;

            Camera = _camera;
        }
Exemplo n.º 25
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            color        = Color.White;
            screenheight = graphics.GraphicsDevice.Viewport.Height;
            screenwidth  = graphics.GraphicsDevice.Viewport.Width;

            Center = new Vector2()
            {
                X = (float)Viewport.Width / 2,
                Y = (float)Viewport.Height / 2,
            };

            EntityManager.InitializeGame(this, "LevelOne");
            EntityManager.Add(MainPlayer.Instance);

            base.Initialize();

            _indexer = 1;
        }
Exemplo n.º 26
0
        private void CreateUI()
        {
            // Play Button
            Button play = new Button("Play")
            {
                Text                   = string.Empty,
                IsBorder               = false,
                BackgroundImage        = WaveContent.Assets.Textures.play_png,
                PressedBackgroundImage = WaveContent.Assets.Textures.playPressed_png,
                Margin                 = new Thickness(244, 580, 0, 0),
            };

            play.Click += this.Play_Click;

            play.Entity.FindChild("ImageEntity").FindComponent <Transform2D>().Origin = Vector2.Center;
            play.Entity.AddComponent(new AnimationUI());
            EntityManager.Add(play);

            // Best Scores
            TextBlock bestScores = new TextBlock("BestScores")
            {
                FontPath            = WaveContent.Assets.Fonts.Bulky_Pixels_16_TTF,
                Text                = "your best score:",
                Foreground          = new Color(223 / 255f, 244 / 255f, 255 / 255f),
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment   = VerticalAlignment.Bottom,
                Margin              = new Thickness(161, 0, 0, 30),
            };

            EntityManager.Add(bestScores);

            // Scores
            TextBlock scores = new TextBlock()
            {
                FontPath            = WaveContent.Assets.Fonts.Bulky_Pixels_26_TTF,
                Text                = this.gameStorage.BestScore.ToString(),
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment   = VerticalAlignment.Bottom,
                Margin              = new Thickness(440, 0, 0, 40),
            };

            EntityManager.Add(scores);
        }
Exemplo n.º 27
0
        private Entity CreateAnchor(string name, Vector3 position, Vector3 scale)
        {
            Entity table = new Entity(name)
                           .AddComponent(new Transform3D()
            {
                Position = position,
                Scale    = scale
            })
                           .AddComponent(Model.CreateCube())
                           .AddComponent(new BoxCollider3D())
                           .AddComponent(new RigidBody3D()
            {
                IsKinematic = true
            });

            EntityManager.Add(table);

            return(table);
        }
Exemplo n.º 28
0
        protected override void CreateScene()
        {
            var pointList = new List <CameraPoint>()
            {
                new CameraPoint()
                {
                    Position = new Vector3(0f, 0f, 15f), LookAt = Vector3.Zero, Up = Vector3.Up
                },
                new CameraPoint()
                {
                    Position = new Vector3(30f, 0f, 15f), LookAt = Vector3.Zero, Up = Vector3.Up
                },
                new CameraPoint()
                {
                    Position = new Vector3(30f, 30f, 15f), LookAt = new Vector3(-15f, 0f, 0f), Up = Vector3.UnitX
                },
                new CameraPoint()
                {
                    Position = new Vector3(-30f, 0f, 15f), LookAt = new Vector3(-15f, 0f, 0f), Up = Vector3.Up
                },
                new CameraPoint()
                {
                    Position = new Vector3(0f, 0f, 15f), LookAt = Vector3.Zero, Up = Vector3.Up
                }
            };

            PathCamera pathCamera = new PathCamera("path", new Vector3(0, 15f, 15f), Vector3.Zero, pointList, 500)
            {
                Speed = 0.5f,
            };

            RenderManager.SetActiveCamera(pathCamera.Entity);
            EntityManager.Add(pathCamera.Entity);

            CreateCube("Cube1", Vector3.Zero);
            CreateCube("Cube2", new Vector3(15f, 0f, 0f));
            CreateCube("Cube3", new Vector3(-15f, 0f, 0f));
            CreateCube("Cube4", new Vector3(0f, 0f, 15f));
            CreateCube("Cube5", new Vector3(0f, 0f, -15f));

            RenderManager.BackgroundColor = Color.CornflowerBlue;
        }
Exemplo n.º 29
0
        private void CreatePlayer()
        {
            Entity player = new Entity("Player")
                            .AddComponent(new Transform2D()
            {
                X         = WaveServices.ViewportManager.VirtualWidth / 2f,
                Y         = WaveServices.ViewportManager.VirtualHeight * 0.75f,
                Origin    = Vector2.Center,
                DrawOrder = 0,
            })
                            .AddComponent(new PerPixelCollider("Content/PlayerCollider.wpk", 0.5f))
                            .AddComponent(new PlayerBehavior(this.gameplayBehavior))
                            .AddComponent(new Sprite("Content/Player.wpk"))
                            .AddComponent(new SpriteRenderer(DefaultLayers.Alpha));

            EntityManager.Add(player);

            // Bullet Manager
            BulletManager bulletManager = new BulletManager(this.gameplayBehavior);

            EntityManager.Add(bulletManager);

            this.gameplayBehavior.Player = player;

            // Left Joystick
            RectangleF leftArea = new RectangleF(WaveServices.ViewportManager.LeftEdge,
                                                 WaveServices.ViewportManager.TopEdge,
                                                 WaveServices.ViewportManager.VirtualWidth / 2f + Math.Abs(WaveServices.ViewportManager.LeftEdge),
                                                 WaveServices.ViewportManager.VirtualHeight + Math.Abs(WaveServices.ViewportManager.TopEdge));
            var leftJoystick = new Joystick("leftJoystick", leftArea);

            EntityManager.Add(leftJoystick);

            // Right Joystick
            RectangleF rightArea = new RectangleF(WaveServices.ViewportManager.VirtualWidth / 2,
                                                  WaveServices.ViewportManager.TopEdge,
                                                  WaveServices.ViewportManager.VirtualWidth / 2f + Math.Abs(WaveServices.ViewportManager.LeftEdge),
                                                  WaveServices.ViewportManager.VirtualHeight + Math.Abs(WaveServices.ViewportManager.TopEdge));
            var fireButton = new FireButton("fireButton", rightArea);

            EntityManager.Add(fireButton);
        }
Exemplo n.º 30
0
        protected override void CreateScene()
        {
            FreeCamera camera = new FreeCamera("MainCamera", new Vector3(0, 10, 20), new Vector3(0, 5, 0))
            {
                BackgroundColor = Color.CornflowerBlue,
            };
            camera.Entity.AddComponent(new FireBehavior());
            EntityManager.Add(camera.Entity);            

            Entity ground = new Entity("Ground")
                .AddComponent(new Transform3D() { Position = new Vector3(0, -1, 0) })
                .AddComponent(new BoxCollider())
                .AddComponent(Model.CreatePlane(Vector3.Up, 50))
                .AddComponent(new RigidBody3D() { IsKinematic = true })
                .AddComponent(new MaterialsMap(new BasicMaterial(Color.Gray)))
                .AddComponent(new ModelRenderer());

            EntityManager.Add(ground);

            #region CreateWall
            int width = 10;
            int height = 10;
            float blockWidth = 2f;
            float blockHeight = 1f;
            float blockLength = 1f;

            int n = 0;
            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    n++;
                    var toAdd = CreateBox("box" + n, new Vector3(i * blockWidth + .5f * blockWidth * (j % 2) - width * blockWidth * .5f,
                                                                 blockHeight * .5f + j * (blockHeight),
                                                                 0),
                                                    new Vector3(blockWidth, blockHeight, blockLength), 10);

                    EntityManager.Add(toAdd);
                }
            }
            #endregion
        }
Exemplo n.º 31
0
        /// <summary>
        /// Creates a new column with recycled components.
        /// </summary>
        /// <param name="column">The column.</param>
        /// <param name="zPosition">The z position.</param>
        /// <returns></returns>
        public Entity CreateColumn(Column column, float zPosition, EntityManager eManager)
        {
            Entity entityColumn = null;

            // Column Cache
            if (this.columnCache.Count > 0)
            {
                entityColumn = this.columnCache.Dequeue();
            }
            else
            {
                entityColumn = new Entity()
                    {
                        Tag = COLUMNTAG
                    }
                    .AddComponent(new Transform3D());

                eManager.Add(entityColumn);
            }

            var transform = entityColumn.FindComponent<Transform3D>();
            Vector3 positiontemp = transform.Position;
            positiontemp.Z = zPosition;
            transform.Position = positiontemp;
            entityColumn.IsVisible = true;

            // column element iteration to block entity Creation
            for (int i = 0; i < column.Count; i++)
            {
                var position = new Vector3(0, i * this.Scale.Z, 0);
                Color color = Color.Black;

                switch (column[i])
                {
                    case BlockTypeEnum.GROUND:
                        color = Color.WhiteSmoke;
                        break;
                    case BlockTypeEnum.BOX:
                        color = Color.BlueViolet;
                        break;
                    case BlockTypeEnum.PYRAMID:
                        color = Color.Red;
                        break;
                    case BlockTypeEnum.SPEEDERBLOCK:
                        color = Color.Yellow;
                        break;
                    case BlockTypeEnum.EMPTY:
                    default:
                        break;
                }

                // add child to column
                if (column[i] != BlockTypeEnum.EMPTY)
                {
                    entityColumn.AddChild(this.CreateBlock(position, color, this.Scale, column[i]));
                }
            }

            return entityColumn;
        }
        private Node CreateNode(Box3D bounds, int level, EntityManager entityManager)
        {
            var mesh = MeshCreator.CreateXZGrid(10, 10);
            var staticMesh = new StaticMesh
            {
                Color = new Vector4(0f, 0f, 1f, 1f),
                ModelMatrix = Matrix4.Identity,
            };

            var size = bounds.Max - bounds.Min;
            var mesh3V3N = mesh.Transformed(Matrix4.CreateScale((float)size.X, 1, (float)size.Z) * Matrix4.CreateTranslation((Vector3)bounds.Center));
            var improvedPerlinNoise = new ImprovedPerlinNoise(4711);
            for (int i = 0; i < mesh3V3N.Vertices.Length; i++)
            {
                var vertex = mesh3V3N.Vertices[i];
                var height = improvedPerlinNoise.Noise(vertex.Position.X, vertex.Position.Z) * 0.2;
                mesh3V3N.Vertices[i] = new Vertex3V3N
                {
                    Normal = new Vector3(0, 1, 0),
                    Position = new Vector3(vertex.Position.X, (float)height, vertex.Position.Z)
                };
            }

            staticMesh.Update(mesh3V3N);

            var entity = new Entity(Guid.NewGuid().ToString());
            entityManager.Add(entity);
            entityManager.AddComponentToEntity(entity, staticMesh);

            if (level == 0)
            {
                return new Node(bounds, new Node[] { }, entity, 1);
            }

            var min = bounds.Min;
            var max = bounds.Max;
            var center = bounds.Center;

            return new Node(bounds,
                new[]
                {
                    CreateNode(new Box3D(bounds.Min, center), level -1, entityManager),
                    CreateNode(new Box3D(new Vector3d(center.X, 0, min.Z), new Vector3d(max.X, 0, center.Z)), level -1, entityManager),
                    CreateNode(new Box3D(new Vector3d(min.X, 0, center.Z), new Vector3d(center.X, 0, max.Z)), level - 1, entityManager),
                    CreateNode(new Box3D(center, max), level - 1, entityManager)
                }, entity, Math.Pow(2, level));
        }
        protected override void OnLoad(EventArgs e)
        {
            StartJobThread();
            StartJobThread();
            StartJobThread();
            StartJobThread();
            StartJobThread();
            StartJobThread();
            StartJobThread();
            StartJobThread();

            _stopwatch = new Stopwatch();
            _stopwatch.Start();

            _keyboardInputObservable.SubscribeKey(KeyCombination.LeftAlt && KeyCombination.Enter, CombinationDirection.Down, ToggleFullScren);

            _keyboardInputObservable.SubscribeKey(KeyCombination.Esc, CombinationDirection.Down, Exit);
            _keyboardInputObservable.SubscribeKey(KeyCombination.P, CombinationDirection.Down, () => _camera.Projection = ProjectionMode.Perspective);
            _keyboardInputObservable.SubscribeKey(KeyCombination.O, CombinationDirection.Down, () => _camera.Projection = ProjectionMode.Orthographic);
            _keyboardInputObservable.SubscribeKey(KeyCombination.F, CombinationDirection.Down, () => _synchronizeCameras = !_synchronizeCameras);

            _entityManager = new EntityManager();

            var terrainSystem = new TerrainSystem(FractalBrownianMotionSettings.Default);
            _systems = new List<IEntitySystem>
            {
                terrainSystem,
                new FreeCameraSystem(_keyboardInputProcessor, _mouseInputProcessor,_camera),
                new LightMoverSystem(),
                new OceanSystem(),
                new CubeMeshSystem(),
                new InputSystem(_keyboardInputProcessor)
                //new ChunkedLODSystem(_lodCamera),
                //new RenderSystem(_camera),
            };

            var light = new Entity(Guid.NewGuid().ToString());
            _entityManager.Add(light);
            _entityManager.AddComponentToEntity(light, new PositionalLightComponent { Position = new Vector3d(0, 20, 0) });
            _entityManager.AddComponentToEntity(light, new InputComponent(Key.J, Key.L, Key.M, Key.N, Key.U, Key.I));

            const int numberOfChunksX = 20;
            const int numberOfChunksY = 20;
            for (var i = 0; i < numberOfChunksX; i++)
            {
                for (var j = 0; j < numberOfChunksY; j++)
                {
                    var entity = new Entity(Guid.NewGuid().ToString());
                    _entityManager.Add(entity);
                    _entityManager.AddComponentToEntity(entity, new ChunkComponent(i, j));
                    _entityManager.AddComponentToEntity(entity, new StaticMesh());
                }
            }

            var settingsViewModel = new SettingsViewModel(new NoiseFactory.NoiseParameters());
            settingsViewModel.SettingsChanged += () =>
            {
                var settings = settingsViewModel.Assemble();
                terrainSystem.SetTerrainSettings(new NoiseFactory.RidgedMultiFractal().Create(settings));
            };

            _terrain = new Terrain(new ChunkedLod());
            _cube = new Cube();
        }
Exemplo n.º 34
0
        static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                Console.WriteLine("Syntax: ImportBatchCreator filepath");
                return;
            }
            var filePath = args[0];
            var em = new EntityManager("RichardK", "RichardK");
            var objects = new List<Object>();
            foreach (var line in File.ReadLines(filePath))
            {
                var pieces = new String[0];
                if (line != null)
                    pieces = line.Split(',');
                if (pieces.Length < 3)
                {
                    Console.WriteLine("Line not valid: " + line);
                    return;
                }
                var comboOrder = BuildComboOrder(pieces[0], Decimal.Parse(pieces[1]), pieces[2]);
                objects.Add(comboOrder);
            }

            var batchName = String.Format(CultureInfo.CurrentCulture, "Import batch {0}.xml", DateTime.Now.ToString("s", CultureInfo.CurrentCulture).Replace(':', '-'));
            var batch = new ImportBatchData { Batch = objects, Name = batchName };
            var addResults = em.Add(batch);
            if (!addResults.IsValid)
                Console.WriteLine("Results not valid: " + addResults.ValidationResults.Summary);
            else
                Console.WriteLine("Import batch created.");
        }