public void Update( EnemySpaceship enemy, PlayerSpaceship player, int offsetEnemy = 0, int offsetPlayer = 0, float force = 2) { if (enemy == null || player == null) { return; } var enemyRect = ImageToRectangle.TransformInRespectToCenter(enemy.CurrentImage, offsetEnemy); var playerRect = ImageToRectangle.TransformInRespectToCenter(player.CurrentImage, offsetPlayer); AttractionMechanics.Update( enemy.CurrentImage, player.CurrentImage, force); if (enemyRect.X > playerRect.X || enemyRect.X + enemyRect.Width < playerRect.X || enemyRect.Y > playerRect.Y || enemyRect.Y + enemyRect.Height < playerRect.Y) { FacePointMechanics.Update( enemy.CurrentImage, player.CurrentImage); } }
public override void Initialize(object _data) { playerSpaceship = (PlayerSpaceship)_data; Create3DUI(); base.Initialize(_data); }
// Use this for initialization void Start() { bulletPool = BulletPool.Instance; patternQueue = new Queue <BulletPattern>(); randomizedPatterns = bulletPatterns; player = PlayerSpaceship.Instance; EnqueuePatterns(); }
private void addScore(int i_Score, IShooter i_Shooter) { PlayerSpaceship shooter = i_Shooter as PlayerSpaceship; if (shooter != null) { shooter.AddScore(i_Score); } }
public SpaceshipControlEditorAdapter(bool _enabled) : base(_enabled) { EventManager.AddEventListener(ConstantEventsName.ON_PLAYER_SPACESHIP_CREATE, OnPlayerSpaceshipCreateHandler); EventManager.AddEventListener(ConstantEventsName.ON_PLAYER_SPACESHIP_DESTROY, OnPlayerSpaceshipDestroyHandler); playerSpaceship = ComponentLocator.Resolve <PlayerSpaceship>(); if (playerSpaceship == null) { SetEnable(false); } }
public void Awake() { if (_instance == null) { _instance = this; } else { Destroy(gameObject); } }
public PlayScreen(Game i_Game) : base(i_Game) { if (Game.Services.GetService <ICollisionsManager>() != null) { Game.Services.RemoveService(typeof(ICollisionsManager)); } m_GameSettings = Game.Services.GetService <GameSettings>(); new CollisionsManager(i_Game); m_Background = new Sprite(@"Sprites\BG_Space01_1024x768", i_Game); MotherShip motherShip = new MotherShip(i_Game); motherShip.NotifyDead += addScore; Add(motherShip); m_Player1Score = new TextInformationDispaly(i_Game, "P1 Score: ", "0", Color.RoyalBlue); m_Player1Lives = new LineOfSprites(i_Game, @"Sprites\Ship01_32x32", 3, new Color(Color.White, 0.5f), new Vector2(0.5f)); Add(m_Player1Score); Add(m_Player1Lives); m_Player1 = new PlayerSpaceship(@"Sprites\Ship01_32x32", i_Game, Keys.H, Keys.K, Keys.U, true); m_Player1.LivesChanged += m_Player1Lives.ChangeNumOfSprites; m_Player1.NotifyDead += decreaseOnePlayer; m_Player1.ScoreChanged += m_Player1Score.UpdateInformation; Add(m_Player1); m_NumOfAlivePlayers = m_GameSettings.NumOfPlayers; if (m_NumOfAlivePlayers == 2) { m_Player2Score = new TextInformationDispaly(i_Game, "P2 Score: ", "0", Color.Green); m_Player2Lives = new LineOfSprites(i_Game, @"Sprites\Ship02_32x32", 3, new Color(Color.White, 0.5f), new Vector2(0.5f)); Add(m_Player2Score); Add(m_Player2Lives); m_Player2 = new PlayerSpaceship(@"Sprites\Ship02_32x32", i_Game, Keys.A, Keys.D, Keys.W, false); m_Player2.LivesChanged += m_Player2Lives.ChangeNumOfSprites; m_Player2.NotifyDead += decreaseOnePlayer; m_Player2.ScoreChanged += m_Player2Score.UpdateInformation; Add(m_Player2); } m_Barriers = new Barrier[k_NumOfBarriers]; for (int i = 0; i < k_NumOfBarriers; i++) { m_Barriers[i] = new Barrier(i_Game); Add(m_Barriers[i]); } m_Enemies = new EnemiesFormation(i_Game, addScore, endGame, levelUp); Add(m_Enemies); }
public Projectile Update( EnemySpaceship enemy, PlayerSpaceship player, int offsetEnemy = 0, int offsetPlayer = 0) { if (enemy == null || player == null) { return(null); } var distance = 512; var distanceBetweenPlayerAndEnemy = Vector2.Distance(player.CurrentImage.Position, enemy.CurrentImage.Position); if (distanceBetweenPlayerAndEnemy > distance) { return(null); } enemy.CurrentImage.Rotation.Rotation = MathHelper.Lerp(player.CurrentImage.Rotation, enemy.CurrentImage.Rotation, 0.001f); return(ProjectileMaker.Create(enemy)); // var enemyRect = ImageToRectangle.Transform(enemy.CurrentImage, offsetEnemy); // var playerRect = ImageToRectangle.Transform(player.CurrentImage, offsetPlayer); }
private void SpawnPlayerSpaceship() { spawnedPlayerShip = Instantiate(playerSpaceship); spawnedPlayerShip.Init(playerSpaceshipHp, playerSpaceshipMoveSpeed); spawnedPlayerShip.OnExploded += OnPlayerSpaceshipExploded; }
//private EnemyController _enemy; void Start() { _player = _playerSpaceship.GetComponent <PlayerSpaceship>(); _gController = _gameController.GetComponent <GameController>(); _loseText.SetActive(false); }
private void Create2DUIControl(PlayerSpaceship _playerSpaceship) { controlPanel.Initialize(_playerSpaceship); }
private void Create3DUIWindows(PlayerSpaceship _playerSpaceship) { var windowsManager = ComponentLocator.Resolve <WindowsManager.WindowsManager>(); uiWindow = windowsManager.CreateWindow <SpaceShipTest3DUIWindow>(SpaceShipTest3DUIWindow.prefabPath, Enums.EnumWindowsLayer.World, _playerSpaceship, false); }
private void Awake() { m_SpaceShip = FindObjectOfType <PlayerSpaceship>(); }
private void OnPlayerSpaceshipCreateHandler(CustomEvent _event) { playerSpaceship = (PlayerSpaceship)_event.EventData; SetEnable(true); }
public void Initialize(PlayerSpaceship _playerSpaceship) { playerSpaceship = _playerSpaceship; CreateControls(); }
// Use this for initialization void Start() { spaceship = GetComponent <PlayerSpaceship>(); move = new Vector2(1, 1); }
private void Start() { spawnedPlayerShip = GameManager.Instance.spawnedPlayerShip; }
public Player() { spaceship = new PlayerSpaceship(); }
private void OnPlayerSpaceshipDestroyHandler(CustomEvent _event) { playerSpaceship = null; SetEnable(false); }
/// <summary> /// Fires an event if the player is registered for the first time /// </summary> /// <param name="newPlayer"></param> private void FirePlayerRegisteredEvent(PlayerSpaceship newPlayer) { const string PlayerRegisteredEventName = "PlayerRegisteredEvent"; var playerRegisteredEventLayer = GameSectorLayerServices[Configuration.StartingSector] .SharedContext .DataLayer .Layers .Where(l => l.DisplayName == PlayerRegisteredEventName && l.GetValidTypes().Any(t => t == typeof(EventQueueArgument))) .FirstOrDefault(); if (playerRegisteredEventLayer == null) { throw new InvalidOperationException($"Cannot use {nameof(FirePlayerRegisteredEvent)}. EventQueue PlayerRegistered doesn't exist"); } //get relation layer for event //var playerRegisteredEventRelationLayer = GameSectorLayerServices[Configuration.StartingSector] // .SharedContext // .DataLayer // .Layers // .Where(l => l.DisplayName == PlayerRegisteredEventName && // l.GetValidTypes().Any(t => t == typeof(DynamicRelation))) // .FirstOrDefault(); //var playerRegisteredEventRelationLayer = GameSectorLayerServices[Configuration.StartingSector] // .SharedContext // .DataLayer // .Layers // .Where(l => l.DisplayName == PlayerRegisteredEventName && // l.GetValidTypes().Any(t => t == typeof(DynamicRelation))) // .FirstOrDefault(); //if (playerRegisteredEventRelationLayer == null) //{ // throw new InvalidOperationException($"Cannot use {nameof(FirePlayerRegisteredEvent)}. DynamicRelation layer with the name PlayerRegistered doesn't exist"); //} //var playerRegisteredEventRelation = new DynamicRelation() //{ // Id = Guid.NewGuid().ToString(), // Entity1 = typeof(PlayerSpaceship), // Entity1Id = newPlayer.Id, // Entity2 = null, // Entity2Id = string.Empty, //}; //playerRegisteredEventRelationLayer.Add(playerRegisteredEventRelation); //if (!playerRegisteredEventRelationLayer.DataAsEnumerable<DynamicRelation>().Contains(playerRegisteredEventRelation)) // throw new InvalidOperationException($"Adding the players relation for PlayerRegisteredEvent didn't work. The relation to add is not valid for {playerRegisteredEventRelationLayer.DisplayName}"); var playerRegisteredEvent = new EventQueueArgument() { Id = Guid.NewGuid().ToString(), EventName = PlayerRegisteredEventName, // changed this ReferenceId = newPlayer.Id, //playerRegisteredEventRelation.Id ReferenceType = typeof(PlayerSpaceship) }; //TODO: event queue argument factory playerRegisteredEventLayer.Add(playerRegisteredEvent); }