public Player() { Vec2D point = new Vec2D(100, 200); transform.position = point; Tag = "Player"; SpriteComponent spriteComponent = new SpriteComponent(this); spriteComponent.Image = Resources.player_1; AddComponent(spriteComponent); AnimationSprite animationSprite = new AnimationSprite(this); animationSprite.ImageList.Add(Resources.player_die_01); animationSprite.ImageList.Add(Resources.player_die_02); animationSprite.ImageList.Add(Resources.player_die_03); animationSprite.ImageList.Add(Resources.player_die_04); animationSprite.Enabled = false; animationSprite.SpriteComponent = spriteComponent; animationSprite.ImageChangeInterval = 0.1f; AddComponent(animationSprite); BoxCollider boxCollider = new BoxCollider(this); Size boxSize = spriteComponent.Image.Size; boxSize.Width -= 5; boxSize.Height -= 5; boxCollider.Size = boxSize; AddComponent(boxCollider); HealthSystem healthSystem = new HealthSystem(this); healthSystem.MaxHealth = 1; AddComponent(healthSystem); AddComponent(new InputComponent(this)); AddComponent(new BulletShooter(this)); TargetScrolling scrolling = new TargetScrolling(this); scrolling.Speed = 100; scrolling.Enabled = false; AddComponent(scrolling); }
public EnemyBullet() { transform.Rotation = 180; SpriteComponent spriteComponent = new SpriteComponent(this); spriteComponent.Image = Resources.EnemyBullet; AddComponent(spriteComponent); BoxCollider boxCollider = new BoxCollider(this); Size boxSize = new Size(); boxSize.Width = 3; boxSize.Height = 8; boxCollider.Size = boxSize; AddComponent(boxCollider); TargetScrolling scrolling = new TargetScrolling(this); scrolling.Speed = 150f; var component = GameObject.FindObjectOfType <BulletShooter>(); if (component != null) { scrolling.Destination = component.gameObject.transform.position; } AddComponent(scrolling); LimitLocationDelete limit = new LimitLocationDelete(this); AddComponent(limit); DamageSystem damageSystem = new DamageSystem(this); damageSystem.HitAbleTag = "Player"; AddComponent(damageSystem); }
public override void MakeObjects() { Size windowSize = WinformRender.Instance.NowForm.Size; Size gameSize = new Size(224, 304); Vec2D playerStartPoint = new Vec2D(gameSize.Width / 2, gameSize.Height - 32); // 백그라운드 오브젝트 생성 BackGround backGround = new BackGround(); backGround.Name = "BackGround"; Vec2D point = new Vec2D(224 / 2, 320 / 2); backGround.transform.position = point; AddObject(backGround); backGround = new BackGround(); point = new Vec2D(224 / 2, 320 / 2 - 320 + 8); backGround.transform.position = point; AddObject(backGround); backGround = new BackGround(); point = new Vec2D(224 / 2, 320 / 2 - 640 + 16); backGround.transform.position = point; AddObject(backGround); Size BackgroundSize = backGround.GetComponent <SpriteComponent>().Image.Size; // 플레이어 생성 Player player = new Player(); point = playerStartPoint; player.transform.position = point; InputComponent input = player.GetComponent <InputComponent>(); if (input != null) { input.MaxWidth = gameSize.Width; } TargetScrolling targetScrolling = player.GetComponent <TargetScrolling>(); if (targetScrolling != null) { targetScrolling.Destination = playerStartPoint; } AddObject(player); // 게임 중앙에 모이기 위한 위치 설정 CompanyHeadquarter company = new CompanyHeadquarter(); point = new Vec2D(224 / 2, 16 * 5); company.transform.position = point; AddObject(company); GameObject unitPosition; Vec2D localPoint; int totalLine = 6; int[] enemyCountAtLine = new int[] { 4, 4, 8, 8, 10, 10 }; // 여러개의 빈 오브젝트를 생성해서 위의 company의 자식으로 설정 // 부모만 움직이면 자식도 움직이기 설정 for (int t = 0; t < totalLine; t++) { for (int i = 0; i < enemyCountAtLine[t]; i++) { unitPosition = new GameObject(); company.transform.SetChild(unitPosition); localPoint = new Vec2D(16 * i - (enemyCountAtLine[t] / 2 - 1) * 16 - 8, 16 * t - 40); unitPosition.transform.localPosition = localPoint; AddObject(unitPosition); } } EnemySpawner enemySpawner = new EnemySpawner(); AddObject(enemySpawner); PlayerLifeManager playerLifeManager = new PlayerLifeManager(); LifeManager lifeManager = playerLifeManager.GetComponent <LifeManager>(); if (lifeManager != null) { lifeManager.playerhealth = player.GetComponent <HealthSystem>(); lifeManager.player = player; } AddObject(playerLifeManager); Text score = new Text(); score.transform.position = new Vec2D(gameSize.Width / 10 * 4, 0); TextComponet textComponet = score.GetComponent <TextComponet>(); AddObject(score); Text gameOver = new Text(); gameOver.transform.position = new Vec2D(gameSize.Width / 10 * 3, gameSize.Height / 2); TextComponet textComponet2 = gameOver.GetComponent <TextComponet>(); textComponet2.Text = "GameOver"; gameOver.Enabled = false; AddObject(gameOver); StageLevel stageLevel = new StageLevel(); Vec2D vec2D = new Vec2D(); vec2D.X = gameSize.Width; vec2D.Y = gameSize.Height - 8; stageLevel.transform.position = vec2D; stageLevel.Enabled = false; AddObject(stageLevel); UIManagerObject uIManagerObject = new UIManagerObject(); UIManager uIManager = uIManagerObject.GetComponent <UIManager>(); if (textComponet != null && uIManager != null) { uIManager.scoreText = textComponet; uIManager.gameOverObject = gameOver; uIManager.stageLevelObejct = stageLevel; } AddObject(uIManagerObject); WayPointManager wayPointManager = new WayPointManager(); WayPoints wayPoints = wayPointManager.GetComponent <WayPoints>(); wayPoints.GameSize = new Vec2D(gameSize.Width, gameSize.Height); AddObject(wayPointManager); GameManagerObject gameManagerObject = new GameManagerObject(); AddObject(gameManagerObject); }