private void CreatePlatforms(Loader loader, int index, Vector3 position) { var file = @"Resources\Models\platform" + index.ToString() + ".fbx"; var obstacle = loader.LoadGameObjectFromFile(file, position, Vector3.Zero); obstacle.Tag = "obstacle"; obstacle.Collision = new BoxCollision(2.2f, 0.8f * index); obstacle.AddComponent(new ColliderComponent()); obstacle.AddScript(new ColliderScript()); var platform = new Game3DObject(new Vector3(0.0f, 1.5f * index, 0.0f), Vector3.Zero); platform.Tag = "ground"; platform.Collision = new BoxCollision(1.8f, 0.8f); platform.AddComponent(new ColliderComponent()); platform.AddScript(new ColliderScript()); obstacle.AddChild(platform); AddGameObject(obstacle); }
private void CreatePlayerLoader(Loader loader) { // создание игрока _player = new Game3DObject(new Vector3(0.0f, 10.0f, -5.0f), Vector3.Zero); float deltaAngle = Camera.FOVY / Game.RenderForm.ClientSize.Height; _player.Tag = "player"; _player.Collision = new BoxCollision(1.0f, 1.7f); _player.AddComponent(new PhysicsComponent()); _player.AddScript(new PhysicsScript()); _player.AddComponent(new ColliderComponent()); _player.AddScript(new ColliderScript()); var playerComponent = new PlayerComponent(); playerComponent.OnArrowsCountChanged += UpdateArrowsCountUI; playerComponent.OnHealthChanged += (count) => _healthProgressBar.Value = count; playerComponent.AddArrows(ArrowType.Standart, 5); playerComponent.AddArrows(ArrowType.Poison, 2); _player.AddComponent(playerComponent); _player.AddScript(new PlayerMovement(deltaAngle, 4f, 0.5f, 2.0f)); _player.AddChild(Camera); // доабвление игроку лука string file = @"Resources\Models\bow.fbx"; var bow = loader.LoadGameObjectFromFile(file, new Vector3(-0.017f, 0.94f, 0.08f), Vector3.Zero); _player.AddChild(bow); //добавление точки появления стрел игроку var arrowParrent = new Game3DObject(new Vector3(-0.052f, 0.95f, 0.0f), Vector3.Zero); arrowParrent.AddComponent(new VisibleComponent()); arrowParrent.AddScript(new VisibleScript()); // скрипт стрельбы var bowShootScript = new BowShoot(2.0f, 1.0f); //создание копируемых стрел для игрока //обычная стрела file = @"Resources\Models\arrow.fbx"; var arrow = loader.LoadGameObjectFromFile(file, Vector3.Zero, Vector3.Zero); arrow.Collision = new BoxCollision(0.3f, 0.2f, 0.3f); var arrowComponents = new List <Func <ObjectComponent> > { () => new ArrowComponent(), () => new PhysicsComponent(0.05f), () => new ColliderComponent() }; var arrowScripts = new List <Func <Script> > { () => new Arrow(arrowParrent, 20.0f, 5.0f), () => new PhysicsScript(), () => new ColliderScript() }; var arrowTemplate = new CopyableGameObject(arrow, arrowScripts, arrowComponents); bowShootScript.AddArrowTemplate(ArrowType.Standart, arrowTemplate); //стрела с ядом file = @"Resources\Models\arrowPoison.fbx"; arrow = loader.LoadGameObjectFromFile(file, Vector3.Zero, Vector3.Zero); arrow.Collision = new BoxCollision(0.3f, 0.2f, 0.3f); arrowComponents = new List <Func <ObjectComponent> > { () => new ArrowComponent(), () => new PhysicsComponent(0.05f), () => new ColliderComponent() }; arrowScripts = new List <Func <Script> > { () => new PoisonArrow(arrowParrent, 20.0f, 5.0f, 5.0f), () => new PhysicsScript(), () => new ColliderScript() }; arrowTemplate = new CopyableGameObject(arrow, arrowScripts, arrowComponents); bowShootScript.AddArrowTemplate(ArrowType.Poison, arrowTemplate); arrowParrent.AddScript(bowShootScript); //добавление стрел к точке появления file = @"Resources\Models\arrow.fbx"; arrow = loader.LoadGameObjectFromFile(file, Vector3.Zero, Vector3.Zero); arrowParrent.AddChild(arrow); file = @"Resources\Models\arrowPoison.fbx"; arrow = loader.LoadGameObjectFromFile(file, Vector3.Zero, Vector3.Zero); arrow.IsHidden = true; arrowParrent.AddChild(arrow); _player.AddChild(arrowParrent); AddGameObject(_player); }