public LaserCastEvent(CollisionManager.RaycastResult raycastResult, IntegerVector origin, AllegianceInfo allegianceInfo) { this.Name = NAME; this.RaycastResult = raycastResult; this.Origin = origin; this.AllegianceInfo = allegianceInfo; }
public GameManagerImpl(Game game) : base(game) { rendererManager = new RenderManager(this); collisionManager = new CollisionManager(this); logicManager = new LogicManager(this); }
void Start() { manager = GameObject.Find("Manager").GetComponent<Manager>(); nwm = manager.GetComponent<NetworkManager>(); nm = manager.GetComponent<NotificationManager>(); cm = manager.GetComponent<CollisionManager>(); }
public void PhysicsCallback(CollisionManager.CollisionComponent mine, CollisionManager.CollisionComponent other, CollResult coll, int collNumber) { if(other.CheckFlag(CollisionManager.FLAGS.GROUND)) { //Move position to above the path (bottom of collision should be above the ground. Above being relative to normal //set velocity to be speed magnitude perpendicular to normal of the primitive it's colliding against, } }
public static CollisionManager getInstance() { if(CollisionManager.instance == null) { CollisionManager.instance = GameObject.Find("CollisionManager").GetComponent<CollisionManager>(); } return(CollisionManager.instance); }
public HeatSeekingMissile(Vector2 _pos, CollisionManager.Side _side) : base(_pos, _side) { closestEnemyOnCreate = Shmup.GameObjects.Where(e => e is Enemy).OrderByDescending(e => Vector2.Distance(e.GetPosition(), this.GetPosition())).FirstOrDefault() as Enemy; textureFile = "Sprites/HeatSeekingMissile"; speed = 5; damage = 20; SoundEffect shotSound = Shmup.contentManager.Load<SoundEffect>("Sounds/47252__nthompson__rocketexpl"); shotSound.Play(0.5f, 0f, 0f); }
// Use this for initialization void Start() { networkManager = gameObject.GetComponent<NetworkManager>(); collisionManager = gameObject.GetComponent<CollisionManager>(); textManager = gameObject.GetComponent<TextManager>(); notificationManager = gameObject.GetComponent<NotificationManager>(); panelManager = GameObject.Find("Panel"); scaleChilds(panelManager); }
public Game1() { _graphics = new GraphicsDeviceManager(this); _collisionManager = new CollisionManager(); _entityFactory = new EntityFactory(this); Content.RootDirectory = "Content"; Services.AddService(typeof(IEntityFactory), _entityFactory); Services.AddService(typeof(CollisionManager), _collisionManager); Services.AddService(typeof(ContentManager), Content); }
public MainGame(WurmsGame parent) : base(parent) { this._objects = new Dictionary<string, GameObject>(); this._reticle = new Reticle(this._parent.Content.Load<Texture2D>("CrossHair"), this._parent._spriteBatch, new Vector2(0.0f, 0.0f)); this._objects["water"] = new Water(this._parent, this._parent.Content.Load<Texture2D>("Water"), new Vector2(0.0f, 300.0f)); this._objects["terrain"] = new Terrain(this._parent, this._parent.Content.Load<Texture2D>("FirstLand"), new Vector2(0.0f, 0.0f)); this._objects["player_one"] = new Player(this._parent, this._parent.Content.Load<Texture2D>("RedPlayerWithShotgun"), new Vector2(240.0f, 100.0f)); this._activePlayer = (Player)this._objects["player_one"]; this._collisionMan = new CollisionManager(ref this._objects, ref this._reticle); }
public Laser(Vector2 _pos, CollisionManager.Side _side) : base(_pos, _side) { speed = 10; damage = 5; SoundEffect shotSound = Shmup.contentManager.Load<SoundEffect>("Sounds/30935__aust-paul__possiblelazer"); shotSound.Play(0.5f, 0f, 0f); if (_side == CollisionManager.Side.Player) { textureFile = "Sprites/laserBlue"; } else { textureFile = "Sprites/laserRed"; } }
private GameManager() { messageDecoder = MessageDecoder.GetInstance(); communicator = Communicator.GetInstance(); gridManager = new GridManager(); playerManager = new PlayerManager(); itemManager = new ItemManager(); collisionManager = new CollisionManager(); aiManager = new AIManager(); // Event subscribe messageDecoder.InitialMapReceived += messageDecoder_InitialMapReceived; messageDecoder.PlayerSetupReceived += messageDecoder_PlayerSetupReceived; messageDecoder.GameUpdateReceived += messageDecoder_GameUpdateReceived; messageDecoder.CoinUpdateReceived += messageDecoder_CoinUpdateReceived; messageDecoder.LifeUpdateReceived += messageDecoder_LifeUpdateReceived; }
public void RayCastTest() { // Arrange var box = new Box2(new Vector2(5, 5), new Vector2(10, -5)); var ray = new Ray(new Vector2(0, 1), Vector2.UnitX); var manager = new CollisionManager(); var mock = new Mock<ICollidable>(); mock.Setup(foo => foo.WorldAABB).Returns(box); manager.AddCollidable(mock.Object); // Act var result = manager.IntersectRay(ray); // Assert Assert.That(result.DidHitObject, Is.True); Assert.That(result.Distance, Is.EqualTo(5)); Assert.That(result.HitPos.X, Is.EqualTo(5)); Assert.That(result.HitPos.Y, Is.EqualTo(1)); }
/// <summary> /// Input helper method provided by GameScreen. Packages up the various input /// values for ease of use /// </summary> /// <param name="input">The state of the gamepads</param> public override void HandleInput(InputState input) { if (input == null) { throw new ArgumentNullException("input"); } if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { foreach (GameScreen screen in ScreenManager.GetScreens()) { screen.ExitScreen(); } CollisionManager.ClearAll(); ScreenManager.AddScreen(new BackgroundScreen()); ScreenManager.AddScreen(new MainMenuScreen()); } }
public override void EntityUpdate() { foreach (Hitbox hit in shieldBox.mCollisions) { //Debug.Log("Something in the collisions"); if (!shieldBox.mDealtWith.Contains(hit)) { hit.mState = ColliderState.Closed; hit.mCollisions.Clear(); shieldBox.mDealtWith.Add(hit); } } Position = owner.Position; base.EntityUpdate(); CollisionManager.UpdateAreas(shieldBox); }
internal override void postWheelCreated() { base.postWheelCreated(); if (HighLogic.LoadedSceneIsEditor) { return; } if (tempColliderTransform != null) { GameObject standInCollider = new GameObject("KSPWheelTempCollider"); standInCollider.transform.NestToParent(tempColliderTransform); Vector3 worldAxis = tempColliderTransform.TransformDirection(tempColliderAxis); standInCollider.transform.Translate(worldAxis * tempColliderOffset, Space.World); standInCollider.layer = 26; collider = standInCollider.AddComponent <SphereCollider>(); collider.radius = wheel.radius; collider.enabled = controller.wheelState == KSPWheelState.RETRACTING || controller.wheelState == KSPWheelState.DEPLOYING; CollisionManager.IgnoreCollidersOnVessel(vessel, collider); } }
protected override void Initialize() { // TODO: Add your initialization logic here //Intro Buttons PlayBtn = new Button(); QuitBtn = new Button(); //Add all levels levels.Add(new FirstLevel(Content)); levels.Add(new SecondLevel(Content)); //Begin Level level = levels[i]; //collision collisionManager = new CollisionManager(new CollisionHelper()); base.Initialize(); }
// Update is called once per frame void Update() { if (Input.GetKey(KeyCode.W)) { transform.position += Vector3.forward; } if (Input.GetKey(KeyCode.S)) { transform.position += Vector3.back; } if (Input.GetKey(KeyCode.A)) { transform.position += Vector3.left; } if (Input.GetKey(KeyCode.D)) { transform.position += Vector3.right; } if (Input.GetKey(KeyCode.Q)) { transform.position += Vector3.up; } if (Input.GetKey(KeyCode.E)) { transform.position += Vector3.down; } if (Input.GetKeyDown(KeyCode.Tab)) { CollisionManager.SetCurrentSelectedBallBounce(); if (!CollisionManager.isNoBallBounceSelected()) { transform.LookAt(CollisionManager.GetCurrentSelectedBallBounce().transform); } } if (Input.GetKeyDown(KeyCode.Space) && !CollisionManager.isNoBallBounceSelected()) { BallBounce current = CollisionManager.GetCurrentSelectedBallBounce(); current.velocity += ((transform.forward).normalized) * 50; } }
public Game() { //init global RNG rng = new Random(); toUpdate = new List <Action>(); lateUpdate = new List <Action>(); Settings.Load("settings.ini"); //create a window and set graphics mode window = new GameWindow(Settings.xRes, Settings.yRes, new OpenTK.Graphics.GraphicsMode(Settings.colorDepth, Settings.bitDepth, 0, 0)); window.Title = "NullEngine Test"; //initialize window data worldMaxX = int.MaxValue; worldMaxY = int.MaxValue; worldRect = new Rectangle(0, 0, worldMaxX, worldMaxY); windowRect = new Rectangle(worldx, worldy, window.Width, window.Height); //initialize managers input = new InputManager(); buttonMan = new ButtonManager(); colMan = new CollisionManager(100); //initialize global textures font = new TextureAtlas("Game/Content/font.png", 16, 6, 8, 12, 0); buttonBackground = TextureManager.LoadTexture("Game/Content/buttonBackground.png", false); //inititialize frame timer; sw = new Stopwatch(); frameTime = 0; //initialize render Queue renderQueue = new Queue <Action>(); //add load update and ender functions to global call lists window.Load += window_Load; window.UpdateFrame += window_UpdateFrame; window.RenderFrame += window_RenderFrame; }
public override void EntityUpdate() { base.EntityUpdate(); switch (mEnemyState) { case EnemyState.Idle: break; case EnemyState.Moving: if (Body.mPS.pushesLeftTile) { Body.mSpeed.y = -mMovingSpeed; } if (Body.mPS.pushesBottomTile) { Body.mSpeed.x = mMovingSpeed; } if (Body.mPS.pushesTopTile) { Body.mSpeed.x = -mMovingSpeed; } if (Body.mPS.pushesRightTile) { Body.mSpeed.y = mMovingSpeed; } //transform.SetPositionAndRotation(transform.position, Quaternion.Euler(0, 0, transform.rotation.z + 1)); break; } CollisionManager.UpdateAreas(HurtBox); CollisionManager.UpdateAreas(Sight); Sight.mEntitiesInSight.Clear(); }
// Use this for initialization void Start() { collisionManager = new CollisionManager(); levelSet = new Dictionary<LevelCount, int>(LEVEL_COUNT); levelSet.Add(LevelCount.ONE, 6); levelSet.Add(LevelCount.TWO, 7); levelSet.Add(LevelCount.THREE, 8); levelSet.Add(LevelCount.FOUR, 9); levelSet.Add(LevelCount.FIVE, 10); timeIntervalSet = new Dictionary<int, int>(LEVEL_COUNT); timeIntervalSet.Add(levelSet[LevelCount.ONE], 25); timeIntervalSet.Add(levelSet[LevelCount.TWO], 23); timeIntervalSet.Add(levelSet[LevelCount.THREE], 21); timeIntervalSet.Add(levelSet[LevelCount.FOUR], 19); timeIntervalSet.Add(levelSet[LevelCount.FIVE], 17); levelSelect(LevelCount.ONE); currentLevel = 0; }
public void AABBProjectionTestC() { float currentFrame = GetNextTestTime(); Vector2f velocity1 = new SFML.Window.Vector2f(300.0f, 300.0f); Vector2f velocity2 = new SFML.Window.Vector2f(400.0f, -300.0f); Vector2f startPosition1 = new SFML.Window.Vector2f(150.0f, 100.0f) + (velocity1 * currentFrame); Vector2f startPosition2 = new SFML.Window.Vector2f(175.0f, 350.0f) + (velocity2 * currentFrame); velocity1 = velocity1 - (velocity1 * currentFrame); velocity2 = velocity2 - (velocity2 * currentFrame); CollisionObject box1 = new CollisionObject(startPosition1, new Vector2f(50.0f, 50.0f), Color.Blue); CollisionObject box2 = new CollisionObject(startPosition2, new Vector2f(50.0f, 50.0f), Color.Magenta); box1.Velocity = velocity1; box2.Velocity = velocity2; CollisionResults results = CollisionManager.TestCollisions(box1, box2); window.Draw(results); }
private bool GetCollision() { switch (DifficultySettings.CurrentDifficulty.AimAssist) { case true: if (InputHelper.MouseLeftButtonPressed() && (CollisionManager.IsCollision("crosshair", Name))) { return(true); } break; case false: if (InputHelper.MouseLeftButtonPressed() && (CollisionManager.IsPerPixelCollision("crosshair", Name))) { return(true); } break; } return(false); }
protected override void OnUpdating(UltravioletTime time) { EntityManager.RemoveMarkedEntities(); GUIManager.Update(); CollisionManager.SetCurrentWorld(world); AudioManager.FetchSongComponents(); AudioManager.PlaySong(); CollisionManager.FetchCollisionComponent(); CollisionManager.UpdateComponents(); MovementManager.FetchMovementComponent(); MovementManager.UpdateMovement(); InputManager.OnUpdateEffectInputs(); CollisionManager.OnUpdateCollision(time); MovementManager.UpdateCorrectionMovement(); CollisionManager.UpdatePositionEntities(); GraphicManager.FetchSpriteComponents(); GraphicManager.UpdateSprites(time); RuleManager.UpdateRule(); base.OnUpdating(time); }
public WorldPathingRequest(ClusterDescriptor start, ClusterDescriptor end, List <ClusterDescriptor> path, bool skipUnrestrictedPvPZones) { _client = GameManager.GetInstance(); _world = ObjectManager.GetInstance(); _collision = _world.GetCollisionManager(); _origin = start; _destination = end; _skipUnrestrictedPvPZones = skipUnrestrictedPvPZones; _path = path; _timeout = DateTime.Now; _state = new StateMachine <State, Trigger>(State.Start); _state.Configure(State.Start) .Permit(Trigger.ApproachDestination, State.Running); _state.Configure(State.Running) .Permit(Trigger.ReachedDestination, State.Finish); }
private void enableColliders() { if (!HighLogic.LoadedSceneIsFlight) { return; } int len = transforms.Length; colliders = new SphereCollider[len]; Vector3 offset; for (int i = 0; i < len; i++) { colliders[i] = transforms[i].gameObject.AddComponent <SphereCollider>(); colliders[i].radius = colliderRadius; offset = part.transform.TransformDirection(colliderOffset); //from part-local to world offset = transforms[i].InverseTransformDirection(offset); //from world to transform local colliders[i].center = offset; CollisionManager.IgnoreCollidersOnVessel(vessel, colliders[i]); } }
protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); titleScreen = Content.Load <Texture2D>(@"Textures\TitleScreen"); spriteSheet = Content.Load <Texture2D>(@"Textures\spriteSheet"); starField = new StarField(Window.ClientBounds.Width, Window.ClientBounds.Height, 200, new Vector2(0, 30), spriteSheet, new Rectangle(0, 450, 2, 2)); asteroidManager = new AsteroidManager(10, spriteSheet, new Rectangle(0, 0, 50, 50), 20, Window.ClientBounds.Width, Window.ClientBounds.Height); playerManager = new PlayerManager(spriteSheet, new Rectangle(0, 150, 50, 50), 3, new Rectangle(0, 0, Window.ClientBounds.Width, Window.ClientBounds.Height)); enemyManager = new EnemyManager(spriteSheet, new Rectangle(0, 200, 50, 50), 6, playerManager, new Rectangle(0, 0, Window.ClientBounds.Width, Window.ClientBounds.Height)); explosionManager = new ExplosionManager(spriteSheet, new Rectangle(0, 100, 50, 50), 3, new Rectangle(0, 450, 2, 2)); collisionManager = new CollisionManager(asteroidManager, playerManager, enemyManager, explosionManager); SoundManager.Initialize(Content); pericles14 = Content.Load <SpriteFont>(@"Fonts\Pericles14"); }
/// <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() { // TODO: Add your initialization logic here this.networkManager.Connect(); var randomNumberGenerator = new MersenneTwister(); this.inputManager = new InputManager(this, this.resolutionManager); this.soundManager = new SoundManager(randomNumberGenerator); this.shotManager = new ShotManager(this.resolutionManager, this.soundManager); this.shotManager.ShotFired += (sender, e) => this.networkManager.SendMessage(new ShotFiredMessage(e.Shot)); this.asteroidManager = new AsteroidManager(this.resolutionManager, randomNumberGenerator, this.IsHost); if (this.IsHost) { this.asteroidManager.AsteroidStateChanged += (sender, e) => this.networkManager.SendMessage(new UpdateAsteroidStateMessage(e.Asteroid)); } this.playerManager = new PlayerManager( this.resolutionManager, randomNumberGenerator, this.inputManager, this.shotManager, this.IsHost); this.playerManager.PlayerStateChanged += (sender, e) => this.networkManager.SendMessage(new UpdatePlayerStateMessage(e.Player)); this.enemyManager = new EnemyManager( randomNumberGenerator, this.shotManager, this.playerManager, this.IsHost); if (this.IsHost) { this.enemyManager.EnemySpawned += (sender, e) => this.networkManager.SendMessage(new EnemySpawnedMessage(e.Enemy)); } this.explosionManager = new ExplosionManager(this.soundManager, randomNumberGenerator); this.collisionManager = new CollisionManager(this.asteroidManager, this.playerManager, this.enemyManager, this.explosionManager, this.shotManager); this.Components.Add(this.inputManager); base.Initialize(); }
public override void EntityUpdate() { if (hitbox.mState != ColliderState.Closed) { foreach (IHurtable hit in hitbox.mCollisions) { //Debug.Log("Something in the collisions"); if (!hitbox.mDealtWith.Contains(hit)) { hit.GetHurt(attack); if (owner is Entity entity) { int count = entity.abilities.Count; for (int i = 0; i < count; i++) { entity.abilities[i].OnHitTrigger(this, hit); } } hitbox.mDealtWith.Add(hit); } } } mTimeAlive += Time.deltaTime; if (mTimeAlive >= mMaxTime) { mToRemove = true; return; } base.EntityUpdate(); Position = owner.Position + Vector2.up * attack.attackOffset.y + Vector2.right * attack.attackOffset.x * (int)owner.mDirection; CollisionManager.UpdateAreas(hitbox); }
public override bool makeMove() { Vector2 move = Vector2.Zero; move = CalculateMove(nextMove, updateDelta, STEP); //calculate how far coordinate is from Path and compere it with Torerance int moduloY = ((int)(screenVectorPosition.Y + move.Y)) % GameObject.OBJECT_SIZE; bool onHorizontalPath = GameObject.OBJECT_SIZE / 2 - Math.Abs(moduloY - GameObject.OBJECT_SIZE / 2) <= TOLERANCE; int moduloX = ((int)(screenVectorPosition.X + move.X)) % GameObject.OBJECT_SIZE; bool onVerticalPath = GameObject.OBJECT_SIZE / 2 - Math.Abs(moduloX - GameObject.OBJECT_SIZE / 2) <= TOLERANCE; bool moved = false; //changing move direction if (((onVerticalPath && !WasOnVerticalPath()) || onHorizontalPath && !WasOnHorizontalPath()) && !CollisionManager.getInstance().IsCollision(roundRectangleToPath(this.ScreenRectanglePosition, move, nextMove, onHorizontalPath, onVerticalPath), nextMove, GameObjectType.WALLS)) { this.screenVectorPosition += new Vector2((int)move.X, (int)move.Y); movementDirection = nextMove; moved = true; } else if (!CollisionManager.getInstance().IsCollision(roundRectangleToPath(this.ScreenRectanglePosition, move = CalculateMove(movementDirection, updateDelta, STEP), movementDirection, onHorizontalPath, onVerticalPath), movementDirection, GameObjectType.WALLS)) { this.screenVectorPosition += new Vector2((int)move.X, (int)move.Y); moved = true; } if (moved) { this.ScreenRectanglePosition = roundRectangleToPath(this.ScreenRectanglePosition, move, movementDirection, onHorizontalPath, onVerticalPath); } return(moved); }
void instanceControl() { if (playerInstance != null && playerInstance != this) { CollisionManager pcmScript = playerInstance.gameObject.GetComponent <CollisionManager>(); pcmScript.reset(); Destroy(this.gameObject); return; } else { playerInstance = this; } DontDestroyOnLoad(this.gameObject); GameObject BGM = Resources.Load(Globals.SEdir + "BGMusic") as GameObject; Instantiate(BGM, transform.position, Quaternion.identity); }
//--------------------------------------------------------------------------- public void Draw(SpriteBatch batch, float deltaTime) { if (UIManager.Get().IsUIDebugViewActive) { Rectangle bounds = Bounds(); batch.Draw(CollisionManager.Get().PointTexture, new Rectangle(bounds.X, bounds.Y, bounds.Width, 1), CollisionManager.Get().PointTexture.Bounds, Color.Cyan, 0, Vector2.Zero, SpriteEffects.None, 1.0f); batch.Draw(CollisionManager.Get().PointTexture, new Rectangle(bounds.X, bounds.Y, 1, bounds.Height), CollisionManager.Get().PointTexture.Bounds, Color.Cyan, 0, Vector2.Zero, SpriteEffects.None, 1.0f); batch.Draw(CollisionManager.Get().PointTexture, new Rectangle(bounds.X + bounds.Width, bounds.Y, 1, bounds.Height), CollisionManager.Get().PointTexture.Bounds, Color.Cyan, 0, Vector2.Zero, SpriteEffects.None, 1.0f); batch.Draw(CollisionManager.Get().PointTexture, new Rectangle(bounds.X, bounds.Y + bounds.Height, bounds.Width, 1), CollisionManager.Get().PointTexture.Bounds, Color.Cyan, 0, Vector2.Zero, SpriteEffects.None, 1.0f); } }
//per default we use the goal point of the environment as our target point. public void update(Engine.Environment env, List <Robot> robots, CollisionManager cm) { Point2D temp = new Point2D((int)env.goal_point.x, (int)env.goal_point.y); temp.rotate((float)-(owner.heading), owner.circle.p); //((float)-(owner.heading * 180.0 / 3.14), owner.circle.p); //translate with respect to location of navigator temp.x -= (float)owner.circle.p.x; temp.y -= (float)owner.circle.p.y; //what angle is the vector between target & navigator float angle = angleValue((float)temp.x, (float)temp.y); // (float)temp.angle(); //! angle *= 57.297f;//convert to degrees //fire the appropriate radar sensor for (int i = 0; i < radarAngles1.Count; i++) { signalsSensors[i].setSignal(0.0); //radar[i] = 0.0f; if (angle >= radarAngles1[i] && angle < radarAngles2[i]) { signalsSensors[i].setSignal(1.0); // Console.WriteLine(i); } //radar[i] = 1.0f; if (angle + 360.0 >= radarAngles1[i] && angle + 360.0 < radarAngles2[i]) { signalsSensors[i].setSignal(1.0); // Console.WriteLine(i); } // radar[i] = 1.0f; // inputs[sim_engine.robots[0].rangefinders.Count + i] = sim_engine.radar[i]; } }
/// <summary> /// Load graphics content for the screen. /// </summary> public override void LoadContent() { m_manager = new GameObjectManager(); m_player = new Player(m_core.Content.Load <Model>("player/soldier2")); m_manager.AddEntity(m_player); man = new CollisionManager(); m_player.Manager = man; for (int i = 0; i < 10; i++) { Enemy e = new Enemy(m_core.Content.Load <Model>("player/zombie_bones")); SkinningData skinningData = e.Model.Tag as SkinningData; if (skinningData == null) { throw new InvalidOperationException ("This model does not contain a SkinningData tag."); } e.Anim = new AnimationPlayer(skinningData); AnimationClip clip = skinningData.AnimationClips["Animace"]; e.Anim.StartClip(clip); m_manager.AddEntity(e); } GameCore.Camera.Player = (Player)m_manager.GetObject("ZombieSmashGame.Entities.Player"); spriteBatch = new SpriteBatch(m_core.GraphicsDevice); font = m_core.Content.Load <SpriteFont>("gamefont"); }
public GameScene(SceneManager sceneManager) : base(sceneManager) { isPortalActive = false; lives = 3; keysLeft = 0; gameInstance = this; entityManager = new EntityManager(); systemManager = new SystemManager(); collisionManager = new CollisionManager(ref gameInstance); //enemyManager = new EnemyManager(ref gameInstance); // Set the title of the window sceneManager.Title = "Game"; // Set the Render and Update delegates to the Update and Render methods of this class sceneManager.renderer = Render; sceneManager.updater = Update; // Set Keyboard events to go to a method in this class sceneManager.keyboardDownDelegate += Keyboard_KeyDown; sceneManager.keyboardUpDelegate += Keyboard_KeyUp; // Enable Depth Testing GL.Enable(EnableCap.DepthTest); GL.DepthMask(true); GL.Enable(EnableCap.CullFace); GL.CullFace(CullFaceMode.Back); GL.ClearColor(0.0f, 0.0f, 0.0f, 1.0f); // Set Camera camera = new Camera(new Vector3(-8, 2, 7), new Vector3(-8, 2, 8), (float)(sceneManager.Width) / (float)(sceneManager.Height), 0.1f, 1000f); //map = new Camera(new Vector3(-28.5f, 10, -28.5f), new Vector3(-28.5f, 2, -28.5f), (float)(sceneManager.Width/2) / (float)(sceneManager.Height/2), 0.1f, 100f); inputManager = new InputManager(ref camera); CreateEntities(); CreateSystems(); //ResourceManager.LoadTexture("Textures/heart.png"); }
// Start is called before the first frame update void Start() { startX = transform.position.x; startY = transform.position.y; tempYOscillationPauseTime = verticalOscillationPauseTime; tempXOscillationPauseTime = horizontalOscillationPauseTime; //get platforms components p_collider = GetComponent <BoxCollider2D>(); spriteRenderer = GetComponent <SpriteRenderer>(); alphaOriginal = spriteRenderer.color; alphaOriginal.a = 1.0f; alphaTemp = spriteRenderer.color; //value between 0-1 of alpha to change platforms to when we cant collide alphaTemp.a = alphaAmount; //get player components player = GameObject.Find("Player"); playerstate = player.GetComponent <PlayerState>(); collisionManager = player.GetComponent <CollisionManager>(); }
public void BoxesCollisionManyTest() { const Byte radius = 64; Vector2 enemysPosition = new Vector2(100, 100); // Left. var targetPosition = new Vector2(30, 100); var collide = CollisionManager.BoxesCollision(radius, enemysPosition, targetPosition); Assert.False(collide); targetPosition = new Vector2(36, 100); collide = CollisionManager.BoxesCollision(radius, enemysPosition, targetPosition); Assert.True(collide); // Top. targetPosition = new Vector2(120, 32); collide = CollisionManager.BoxesCollision(radius, enemysPosition, targetPosition); Assert.False(collide); targetPosition = new Vector2(36, 36); collide = CollisionManager.BoxesCollision(radius, enemysPosition, targetPosition); Assert.True(collide); // Right. targetPosition = new Vector2(230, 100); collide = CollisionManager.BoxesCollision(radius, enemysPosition, targetPosition); Assert.False(collide); targetPosition = new Vector2(220, 100); collide = CollisionManager.BoxesCollision(radius, enemysPosition, targetPosition); Assert.True(collide); // Down. targetPosition = new Vector2(100, 224); collide = CollisionManager.BoxesCollision(radius, enemysPosition, targetPosition); Assert.False(collide); targetPosition = new Vector2(120, 200); collide = CollisionManager.BoxesCollision(radius, enemysPosition, targetPosition); Assert.True(collide); }
/// <summary> /// /// </summary> /// <param name="raycasts"></param> /// <param name="map"></param> /// <returns>A list of normalised collision distances, and the collidion points themselves.</returns> public static (float[], Vector2f?[]) GetRaycastCollisions(List <LineSegment> raycasts, List <LineSegment> map) { var colliding = new HashSet <LineSegment>(); var collisionPoints = new Vector2f?[raycasts.Count]; var collisionDistances = new float[raycasts.Count()]; for (int i = 0; i < raycasts.Count; i++) { collisionDistances[i] = 1; } for (int i = 0; i < raycasts.Count; i++) { var ray = raycasts[i]; var p2 = ray.Start; var p3 = ray.End; foreach (var line in map) { var p0 = line.Start; var p1 = line.End; var collisionPoint = CollisionManager.CheckCollision(p0, p1, p2, p3); if (collisionPoint != null) { colliding.Add(ray); var rayLength = Math.Pow(p2.X - p3.X, 2) + Math.Pow(p2.Y - p3.Y, 2); var hitLength = Math.Pow(p2.X - collisionPoint.Value.X, 2) + Math.Pow(p2.Y - collisionPoint.Value.Y, 2); var hitDistance = (float)(hitLength / rayLength); if (hitDistance < collisionDistances[i]) { collisionDistances[i] = hitDistance; collisionPoints[i] = collisionPoint; } } } } return(collisionDistances, collisionPoints); }
public SnakeGame(IRenderEngine renderEngine) { this.renderEngine = renderEngine; collisionManager = new CollisionManager(); inputMapper = new InputMapper(); score = new Score(0, 12); gameState = 1; grid = new Grid(new int[,] { { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, { 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 }, { 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 }, { 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 }, { 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 }, { 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 }, { 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 }, { 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 }, { 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 }, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } }); snake = new Snake(4, 4, 4, 1, 0); grid.AddRandomPowerUp(snake.GetPositions()); }
void Shoot() { timer = LFloat.zero; eventHandler.Shoot(); var shootRay = new Ray2D { origin = transform.pos, direction = transform.forward }; if (CollisionManager.Raycast((int)EColliderLayer.Enemy, shootRay, out var shootHit)) { var collider = CollisionManager.GetCollider(shootHit.colliderId); var point = shootHit.point.ToLVector3XZ(LFloat.one); point.y = shootTrans.y; collider?.Entity?.TakeDamage(damagePerShot, point); eventHandler.SetLinePosition(1, point); } else { var point = (shootRay.origin + shootRay.direction * range).ToLVector3XZ(LFloat.one); point.y = shootTrans.y; eventHandler.SetLinePosition(1, point); } }
public RayCollisionPoint CollideRay(Ray ray) { // get all objects var collidables = ColliderObjects.GetAllObjects((GameObject go) => go is ICollidable); var nearestCollision = new RayCollisionPoint(); foreach (var collidable in collidables) { //Console.WriteLine($"Testing RCP with {collidable}"); RayCollisionPoint rcp = CollisionManager.GetRayCollision(ray, collidable.Collision); // check if the point is closer if (rcp.DidCollide && rcp.RayDistance < nearestCollision.RayDistance && rcp.RayDistance >= 0.0f) { nearestCollision = rcp; } } return(nearestCollision); }
/// <summary> /// Creates new instance of <see cref="Game"/>. /// </summary> /// <param name="score"><see cref="ScoreManager"/> to keep track of points.</param> /// <param name="textDraw"><see cref="TextManager"/> to write text objects to the <see cref="ScreenCanvas"/>.</param> /// <param name="canvas"><see cref="ScreenCanvas"/> to draw objects on.</param> public Game(ScoreManager score, TextManager textDraw, ScreenCanvas canvas) { _score = score; _textDraw = textDraw; _currentLevel = AsteroidStartCount; _inProcess = true; //Setup caches with a new ship _cache = new CacheManager( _score , new Ship() , new AsteroidBelt(_currentLevel) , Enumerable.Range(0, 4).Select(i => new Bullet()).ToList() ); _collisionManager = new CollisionManager(_cache); _drawingManager = new DrawingManager(_cache, canvas); //Unpaused _paused = false; _pauseTimer = PauseInterval; }
public void Update(Shadow shadow) { foreach (Block tile in CollisionTiles) { shadow.Collision(tile.Rectangle, Width, Height); } for (int i = 0; i < CollisionCoins.Count; i++) { if (CollisionManager.TouchCoin(shadow.hitBox, CollisionCoins[i].Rectangle)) { CollisionCoins[i].isCollected = true; CollisionCoins[i].Update(); coinsCollected++; if (coinsCollected == CollisionCoins.Count) { Global.currentLevel++; Global.reset = true; } } } }
//--------------------------------------------------------------------------- public override void Draw(SpriteBatch batch, CameraData data, float deltaTime) { if (CollisionManager.Get().IsDebugViewActive) { Texture2D tex = CollisionManager.Get().PointTexture; if (tex != null) { foreach (Fixture fixture in Fixtures) { PolygonShape shape = fixture.Shape as PolygonShape; if (shape != null) { for (int i = 0; i < shape.Vertices.Count; i++) { Vector2 start = (fixture.Body.Position + shape.Vertices[i]) * Unit; Vector2 end = (fixture.Body.Position + shape.Vertices[(i + 1) % shape.Vertices.Count]) * Unit; DrawLine(batch, tex, start, end, data); } } } } } }
public Missile(Vector2 _pos, CollisionManager.Side _side) : base(_pos, _side) { textureFile = "Sprites/missile"; speed = 5; damage = 20; SoundEffect shotSound = Shmup.contentManager.Load<SoundEffect>("Sounds/47252__nthompson__rocketexpl"); shotSound.Play(0.5f, 0f, 0f); }
protected virtual void Awake() { mgr = MonoBehaviour.FindObjectOfType(typeof(CollisionManager)) as CollisionManager; mgr.RegisterObject(this); }
void Start() { collisionManager = this.transform.parent.GetComponent<CollisionManager>(); }
public void LoadContent() { if (mode == Mode.Demo) { pacmans.Add(new PacmanGameObject(-1, 0)); monsters.Add(new MonsterGameObject(-3, 0, MonsterGameObject.MonsterGameObjectColor.Blue)); monsters.Add(new MonsterGameObject(-4, 0, MonsterGameObject.MonsterGameObjectColor.Pink)); monsters.Add(new MonsterGameObject(-5, 0, MonsterGameObject.MonsterGameObjectColor.Green)); monsters.Add(new MonsterGameObject(-6, 0, MonsterGameObject.MonsterGameObjectColor.Red)); listOfAllGameObjects.Add(pacmans); listOfAllGameObjects.Add(monsters); } else if (mode == Mode.Normal) { monsters.Add(new MonsterGameObject(MonsterGameObject.MonsterGameObjectColor.Blue)); monsters.Add(new MonsterGameObject(MonsterGameObject.MonsterGameObjectColor.Green)); monsters.Add(new MonsterGameObject(MonsterGameObject.MonsterGameObjectColor.Pink)); monsters.Add(new MonsterGameObject(MonsterGameObject.MonsterGameObjectColor.Red)); Viewport viewport = ScreenManager.GraphicsDevice.Viewport; GameCoordinates topLeftArena = new GameCoordinates(0, 0); GameCoordinates bottomRightArena = new GameCoordinates(); //TODO:remove magic number bottomRightArena.X = viewport.Width / 24 - 2; bottomRightArena.Y = viewport.Height / 24 - 2; walls = board.Walls; //borders if ( //false true ) { walls.Add(new HorizontalWallGameObject(topLeftArena.Y, topLeftArena.X, bottomRightArena.X)); walls.Add(new HorizontalWallGameObject(bottomRightArena.Y, topLeftArena.X, bottomRightArena.X)); walls.Add(new VerticalWallGameObject(topLeftArena.X, topLeftArena.Y, bottomRightArena.Y)); walls.Add(new VerticalWallGameObject(bottomRightArena.X, topLeftArena.Y, bottomRightArena.Y)); } dots = DotGameObject.Generate(bottomRightArena.X, bottomRightArena.Y); listOfAllGameObjects.Add(dots); pills = MagicPillGameObject.Generate(); listOfAllGameObjects.Add(pills); listOfAllGameObjects.Add(walls); listOfAllGameObjects.Add(portals); listOfAllGameObjects.Add(fruits); pacman = new PacmanGameObject(); pacmans.Add(pacman); listOfAllGameObjects.Add(pacmans); listOfAllGameObjects.Add(monsters); List<GameObject> other = new List<GameObject>(); other.Add(toolBarGameObject = new ToolBarGameObject()); listOfAllGameObjects.Add(other); /* List<GameObject> monsterHouses = new List<GameObject>(); monsterHouses.Add(monsterHouse); listOfAllGameObjects.Add(monsterHouses); */ } collisionManager = CollisionManager.getInstance(); collisionManager.Initialize(walls, portals, monsterHouses, dots, pills, fruits, pacmans, monsters); GameObject.LoadStaticContent(); foreach (List<GameObject> list in listOfAllGameObjects) foreach (GameObject gameObject in list) { gameObject.LoadContent(); } }
protected override void Initialize() { theFileManager = FileManager.Get(this); theInputManager = InputManager.Get(this); theUtilityManager = UtilityManager.Get(this); theTileManager = TileManager.Get(this); theButtonManager = ButtonManager.Get(this); thePlayerManager = PlayerManager.Get(this); theScreenManager = ScreenManager.Get(this); theCameraManager = CameraManager.Get(this); theEnemyManager = EnemyManager.Get(this); theProjectileManager = ProjectileManager.Get(this); theCollisionManager = CollisionManager.Get(this); theScreenManager.WorldScreen = new MainMenu(); Player.CreatePlayer("test", new Vector2(mScreenDimensions.X / 2.0f, mScreenDimensions.Y / 2.0f), Vector2.Zero); TileButton.Create(new FloorCopper(), Keys.E); TileButton.Create(new FloorMetal(), Keys.R); TileButton.Create(new HardWallCopper(), Keys.T); TileButton.Create(new HardWallMetal(), Keys.Y); TileButton.Create(new WallMetal(), Keys.Q); TileButton.Create(new CopperWall(), Keys.W); EnemyButton.Create(new EnemyTurret(), Keys.F); // EnemyButton.Create("Turret_Gun", Keys.F); theTileManager.Load("Level_1.xml"); base.Initialize(); }
private void applyCollisionManager(CollisionManager collisionManager) { //Debug.Log ("applyCollisionManager " + collisionManager.blobName1 + " " + collisionManager.blobName2); BlobManager newBlob = collisionManager.getBlobManager (); addToBlobs (newBlob); startBlob (newBlob, collisionManager.newMapData, newBlob.getPrism ().getPosition ()); mainBlobName = newBlob.blobName; newBlob.voxelCount=collisionManager.blob1.voxelCount+collisionManager.blob2.voxelCount; if (!collisionManager.isBlob2InsideBlob1) removeBlob (collisionManager.blob1.blobName); removeBlob (collisionManager.blob2.blobName); }
public void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen) { updateDelta += gameTime.ElapsedGameTime.Milliseconds; if (mode == Mode.Demo && updateDelta > 10000) { int y = (new Random()).Next(16); updateDelta = 0; pacmans.Clear(); monsters.Clear(); pacmans.Add(new PacmanGameObject(-1, y)); monsters.Add(new MonsterGameObject(-3, y, MonsterGameObject.MonsterGameObjectColor.Blue)); monsters.Add(new MonsterGameObject(-4, y, MonsterGameObject.MonsterGameObjectColor.Pink)); monsters.Add(new MonsterGameObject(-5, y, MonsterGameObject.MonsterGameObjectColor.Green)); monsters.Add(new MonsterGameObject(-6, y, MonsterGameObject.MonsterGameObjectColor.Red)); listOfAllGameObjects.Clear(); listOfAllGameObjects.Add(pacmans); listOfAllGameObjects.Add(monsters); collisionManager = CollisionManager.getInstance(); collisionManager.Initialize(walls, portals, monsterHouses, dots, pills, fruits, pacmans, monsters); GameObject.LoadStaticContent(); foreach (List<GameObject> list in listOfAllGameObjects) foreach (GameObject gameObject in list) { gameObject.LoadContent(); } } foreach (List<GameObject> list in listOfAllGameObjects) foreach (GameObject gameObject in list) { gameObject.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen); } foreach (PacmanGameObject pm in pacmans) { if (pm.IsDead) GameOver = true; } if (DotGameObject.VisibleDotCounter == 0) levelCompleted = true; }
static CollisionManager() { instance = new CollisionManager(); }
public void RayCastCallBack(CollisionManager.CollisionComponent mine, CollisionManager.CollisionComponent other, CollResult coll, int collNumber) { if(other.CheckFlag(CollisionManager.FLAGS.GROUND)) { } }
public EntityManager(ContentManager contentManager, Microsoft.Xna.Framework.Game game) : base(game) { _contentManager = contentManager; _entities = new List<IEntity>(); _collisionManager = new CollisionManager(); }
private void collideBlob(string blobName) { /* sets up a collisionManager and adds it to the list of work to be done in pieces every frame */ //Debug.Log ("collideBlob for " + blobName); BlobManager blob1 = getBlob (mainBlobName); BlobManager blob2 = getBlob (blobName); blob1.setCollisionStatus (); blob2.setCollisionStatus (); Prism newPrism = CollisionManager.getPrismFromBlobs (blob1, blob2); BlobManager newBlob; if (blob1.getPrism ().isPrismEqual (newPrism)) { newBlob = null; } else { newBlob = getNewBlob (getNextBlobName (), false); } CollisionManager collisionManager = new CollisionManager (this, blobName, newBlob); collisionManagers.Add (collisionManager); }
public Weapon(Vector2 _pos, CollisionManager.Side _side) : base(_pos) { this.side = _side; }