/// <summary>
 /// Creates a new SimplePhysicsAlgorithm object.
 /// </summary>
 /// <param name="collisionHandler">The assigned CollisionHandler which will be informed about collisions.</param>
 /// <param name="world">The assigned World whose objects are to be updated.</param>
 public SimplePhysicsAlgorithm(CollisionHandler collisionHandler, World world, ConfigurationRetriever configRetriever)
 {
     this.collisionHandler = collisionHandler;
     this.world = world;
     this.configRetriever = configRetriever;
     this.difficulty = 0;
 }
Example #2
0
 // Start is called before the first frame update
 void Start()
 {
     rb                = GetComponent <Rigidbody>();
     coHandler         = GetComponent <CollisionHandler>();
     audioSource       = GetComponent <AudioSource>();
     coHandler.enabled = true;
 }
Example #3
0
 public ProjectileManager(Game game, Camera cam, CollisionHandler collision) : base(game)
 {
     projectiles    = new List <Projectile>();
     HitProjectiles = new List <Projectile>();
     this.collision = collision;
     this.cam       = cam;
 }
Example #4
0
 public void StartGame()
 {
     SceneManager.LoadScene("Game");
     StartCoroutine(WaitForLoadGameScene());
     handler = CollisionHandler.instance;
     handler.StartRules();
 }
        public void ResolveCollisionsWithRigidBodyAndStaticObject_ShouldDoNothing()
        {
            var firstObject = new GameObject
            {
                Layer       = 1,
                HasCollider = true,
                Position    = new Vector2D(0, 0)
            };

            firstObject.AddComponent <RigidBody2D>().Velocity = Vector2D.Down;

            var secondObject = new GameObject
            {
                Layer       = 1,
                HasCollider = true,
                Position    = new Vector2D(0, 1)
            };

            firstObject.Step();
            secondObject.Step();

            CollisionHandler.ResolveCollisions(new[] { firstObject, secondObject });

            firstObject.Position.Should().BeEquivalentTo(Vector2D.Down);
            secondObject.Position.Should().BeEquivalentTo(Vector2D.Up);
        }
Example #6
0
        public Map(Game game)
        {
            _game   = game;
            _logger = LoggerProvider.GetLogger();
            Id      = _game.Config.GameConfig.Map;
            var path = Path.Combine(
                game.Config.ContentPath,
                _game.Config.ContentManager.GameModeName,
                "AIMesh",
                "Map" + Id,
                "AIPath.aimesh_ngrid"
                );

            if (File.Exists(path))
            {
                NavGrid = NavGridReader.ReadBinary(path);
            }
            else
            {
                _logger.Error("Failed to load navigation graph. Aborting map load.");
                return;
            }

            AnnouncerEvents  = new List <IAnnounce>();
            CollisionHandler = new CollisionHandler(_game, this);
            MapProperties    = GetMapProperties(Id);
        }
Example #7
0
        public void AddProtectedCollisionHandler <O, T>(O obj, CollisionHandler <O, T> handler)
            where O : IPhysicsObject
            where T : IPhysicsObject
        {
            if (obj == null)
            {
                throw new NullReferenceException("Colliding object must not be null");
            }
            if (handler == null)
            {
                throw new NullReferenceException("Handler must not be null");
            }

            CollisionHandler <IPhysicsObject, IPhysicsObject> targetHandler =
                delegate(IPhysicsObject collider, IPhysicsObject collidee)
            {
                if (collidee is T)
                {
                    handler((O)collider, (T)collidee);
                }
            };

            obj.Collided += targetHandler;
            protectedCollisionHandlers.Add(new CollisionRecord(obj, null, null, handler), targetHandler);
        }
        /// <summary>
        /// Adds a delegate to the collision handler.
        /// </summary>
        /// <param name="index"></param>
        /// <param name="yourdelegate"></param>
        public void SetCollisionDelegate(int index, OnFrameDelegate yourdelegate)
        {
            CollisionHandler collisionHandler = FrameDelegates[index];

            collisionHandler.collisionDelegate += yourdelegate;
            FrameDelegates[index] = collisionHandler;
        }
Example #9
0
    private void Start()
    {
        _collision     = GetComponent <CollisionHandler>();
        _rigidbodyCube = gameObject.GetComponent <Rigidbody>();

        SubscribeOnEvents();
    }
Example #10
0
        protected void InitializeComponents()
        {
            CollisionHandler.DoActionWithCheckReference(() => CollisionHandler.Initialize(this));

            spriteRenderer.DoActionWithCheckReference(() =>
                                                      _spriteRendererTransform = spriteRenderer.GetComponent <Transform>());
        }
Example #11
0
        public Map(Game game, long firstSpawnTime, long spawnInterval, long firstGoldTime, bool hasFountainHeal, int id)
        {
            _objects          = new Dictionary <uint, GameObject>();
            _champions        = new Dictionary <uint, Champion>();
            _visionUnits      = new Dictionary <TeamId, Dictionary <uint, Unit> >();
            _expToLevelUp     = new List <int>();
            _waveNumber       = 0;
            _firstSpawnTime   = firstSpawnTime;
            _firstGoldTime    = firstGoldTime;
            _spawnInterval    = spawnInterval;
            _gameTime         = 0;
            _nextSpawnTime    = firstSpawnTime;
            _nextSyncTime     = 10 * 1000;
            _announcerEvents  = new List <GameObjects.Announce>();
            _game             = game;
            _firstBlood       = true;
            _killReduction    = true;
            _hasFountainHeal  = hasFountainHeal;
            _collisionHandler = new CollisionHandler(this);
            _fountains        = new Dictionary <TeamId, Fountain>();
            _fountains.Add(TeamId.TEAM_BLUE, new Fountain(TeamId.TEAM_BLUE, 11, 250, 1000));
            _fountains.Add(TeamId.TEAM_PURPLE, new Fountain(TeamId.TEAM_PURPLE, 13950, 14200, 1000));
            _id = id;

            _teamsIterator = Enum.GetValues(typeof(TeamId)).Cast <TeamId>().ToList();

            foreach (var team in _teamsIterator)
            {
                _visionUnits.Add(team, new Dictionary <uint, Unit>());
            }
        }
Example #12
0
 public GameViewModel()
 {
     NewGame(715, 855, false, 500000, 10, 2);
     GameInformation    = "Press any key to start game...";
     _gameObjectHandler = new GameObjectHandler();
     _collisionHandler  = new CollisionHandler();
 }
Example #13
0
        private void KeyboardAction(KeyboardState kbState)
        {
            foreach (var key in this.KbKeys.Where(kbState.IsKeyDown))
            {
                switch (key)
                {
                case Keys.D:
                    MovementHandler.MoveRight(this);
                    this.MovementAngle = GlobalVariables.RightAngle;
                    break;

                case Keys.W:
                    MovementHandler.MoveUp(this);
                    this.MovementAngle = GlobalVariables.UpAngle;
                    break;

                case Keys.S:
                    MovementHandler.MoveDown(this);
                    this.MovementAngle = GlobalVariables.DownAngle;
                    break;

                case Keys.A:
                    MovementHandler.MoveLeft(this);
                    this.MovementAngle = GlobalVariables.LeftAngle;
                    break;
                }
                CollisionHandler.PlayerReaction(this, key);
            }
        }
Example #14
0
    private void ShootWeapon(Ray ray)
    {
        // Hide the representation of weapon
        // untill the weapon hits somewhere else.
        WeaponHolder.SetActive(false);

        // Instantiate a new weapon to shoot.
        Vector3    pos = ray.origin;
        Quaternion rot = Quaternion.LookRotation(ray.direction);

        weaponInstance = Instantiate(Weapon, pos, rot) as GameObject;
        weaponInstance.transform.Rotate(Vector3.left * 90);
        weaponInstance.name = "Weapon";

        // Add a collision handler script to recenlty instantiated weapon.
        CollisionHandler colHandler = weaponInstance.AddComponent <CollisionHandler>() as CollisionHandler;

        colHandler.SetWeaponHolder(WeaponHolder);
        colHandler.SetScoreManager(ScoreManager);


        // Add force to the rigidbody of weapon to shoot it.
        weaponInstanceRigidBody = weaponInstance.GetComponent <Rigidbody>();
        weaponInstanceRigidBody.AddForce(ray.direction * WeaponThrowingForce, ForceMode.Acceleration);

        // Set the initial position after shooting.
        weaponHolderTransform.position = initialPosition;

        // Destroy the first weapon at a time if the
        // number of total weapon exceeds MAX_NUM_WEAPON.
        weaponCollector(weaponInstance);

        // Update the remaining ammo.
        updateAmmo();
    }
 private void Start()
 {
     _game             = FindObjectOfType <Game>();
     _collision        = GetComponent <CollisionHandler>();
     _deactivatedCubes = _game.DeactivatedCubes.transform;
     SubscribeOnEvents();
 }
        public void ResolveConflictedCollidersWithoutDirection_ShouldMoveCollidersToDifferentPositions()
        {
            var firstObject = new GameObject
            {
                Layer       = 1,
                HasCollider = true,
                Position    = new Vector2D(0, 0)
            };

            firstObject.AddComponent <RigidBody2D>().Velocity = Vector2D.Zero;

            var secondObject = new GameObject
            {
                Layer       = 1,
                HasCollider = true,
                Position    = new Vector2D(0, 0)
            };

            secondObject.AddComponent <RigidBody2D>().Velocity = Vector2D.Zero;

            CollisionHandler.ResolveCollisions(new[] { firstObject, secondObject });

            firstObject.Position.Should().BeEquivalentTo(Vector2D.Left);
            secondObject.Position.Should().BeEquivalentTo(Vector2D.Down);
        }
Example #17
0
 public void FindAllCollisions(IEnumerable <IBox2DCollider> colliders, CollisionHandler Handler)
 {
     if (ReferenceEquals(null, Handler))
     {
         return;
     }
     Clear();
     foreach (var collider in colliders)
     {
         Insert(collider);
     }
     for (int y = 0; y < CellCountY; ++y)
     {
         for (int x = 0; x < CellCountX; ++x)
         {
             var cell = cells[x, y];
             for (int i = 0; i < cell.Count; ++i)
             {
                 for (int j = i + 1; j < cell.Count; ++j)
                 {
                     Handler(cell[i], cell[j]);
                 }
             }
         }
     }
 }
Example #18
0
 public GameState(Camera camera, int gridSize, ContentManager content)
 {
     mGridSize            = gridSize;
     mCamera              = camera;
     UnitsByPlayer        = new Dictionary <Players, List <IUnit> >();
     SpatialUnitsByPlayer = new SpatialStructuredUnits(mGridSize);
     BuildingsByPlayer    = new Dictionary <Players, List <IUnit> >();
     HeroesByPlayer       = new Dictionary <Players, Hero>();
     UnitsByModel         = new Dictionary <ModelManager.Model, List <IUnit> >();
     Resources            = new Dictionary <Players, Dictionary <Resources, int> >();
     VillagePos           = new Dictionary <Players, Vector2>();
     VillagesByPlayer     = new Dictionary <Players, Village>();
     mMap               = new TileStates[0, 0];
     mPathZones         = new PathFindingZones(0, 0, mGridSize);
     IsPaused           = true;
     mCollision         = new CollisionHandler(gridSize, UnitsByPlayer, IsObstructed);
     mEnemy             = new DummyKi();
     HeroRespawnManager = new HeroRespawnManager();
     mDamageFactor      = new Dictionary <Players, float>();
     foreach (var player in PlayerConstants.sPlayers)
     {
         mDamageFactor.Add(player, 1f);
     }
     mBlockedSound      = new SoundEffectManager(content, "sounds/Logo_miss");
     mStatistics        = new Statistics(content, null, null);
     StatisticsByPlayer = new Dictionary <Players, Dictionary <string, int> >();
     InitStatisticsByPlayer(Players.Player);
     InitStatisticsByPlayer(Players.Ai);
     mPathFinderInstances = new ThreadLocal <PathFinder>(() => new PathFinder(IsObstructed, gridSize));
     mContent             = content;
 }
Example #19
0
        public Map(Game game)
        {
            _game = game;
            Id    = _game.Config.GameConfig.Map;
            var path = Path.Combine(
                Program.ExecutingDirectory,
                "Content",
                "Data",
                _game.Config.ContentManager.GameModeName,
                "AIMesh",
                "Map" + Id,
                "AIPath.aimesh_ngrid"
                );

            if (File.Exists(path))
            {
                NavGrid = NavGridReader.ReadBinary(path);
            }
            else
            {
                _logger.LogCoreError("Failed to load navigation graph. Aborting map load.");
                return;
            }

            AnnouncerEvents  = new List <Announce>();
            CollisionHandler = new CollisionHandler(this);
            MapGameScript    = GetMapScript(Id);
        }
Example #20
0
        public Map(Game game, long firstSpawnTime, long spawnInterval, long firstGoldTime, bool hasFountainHeal, int id)
        {
            _objects                        = new Dictionary <uint, GameObject>();
            _inhibitors                     = new Dictionary <uint, Inhibitor>();
            _champions                      = new Dictionary <uint, Champion>();
            _visionUnits                    = new Dictionary <TeamId, Dictionary <uint, Unit> >();
            ExpToLevelUp                    = new List <int>();
            _minionNumber                   = 0;
            _firstSpawnTime                 = firstSpawnTime;
            FirstGoldTime                   = firstGoldTime;
            _spawnInterval                  = spawnInterval;
            GameTime                        = 0;
            _nextSpawnTime                  = firstSpawnTime;
            _nextSyncTime                   = 10 * 1000;
            _announcerEvents                = new List <Announce>();
            _game                           = game;
            HasFirstBloodHappened           = false;
            IsKillGoldRewardReductionActive = true;
            _spawnEnabled                   = _game.Config.MinionSpawnsEnabled;
            _hasFountainHeal                = hasFountainHeal;
            _collisionHandler               = new CollisionHandler(this);
            _fountains                      = new Dictionary <TeamId, Fountain>
            {
                { TeamId.TEAM_BLUE, new Fountain(TeamId.TEAM_BLUE, 11, 250, 1000) },
                { TeamId.TEAM_PURPLE, new Fountain(TeamId.TEAM_PURPLE, 13950, 14200, 1000) }
            };
            Id = id;

            _teamsIterator = Enum.GetValues(typeof(TeamId)).Cast <TeamId>().ToList();

            foreach (var team in _teamsIterator)
            {
                _visionUnits.Add(team, new Dictionary <uint, Unit>());
            }
        }
Example #21
0
    public void OnCollisionEnter(Collision other)
    {
        if (other.gameObject.CompareTag("Slytherin"))
        {
            CollisionHandler.ResolveDiffTeamCollision(this.GetComponent <PlayerBase>(), other.gameObject.GetComponent <PlayerBase>());
        }
        else if (other.gameObject.CompareTag("Gryffindor"))
        {
            CollisionHandler.ResolveSameTeamCollision(this.gameObject, other.gameObject);
        }

        else if (other.gameObject.CompareTag("Ground"))
        {
            //player is already unconscious and falling
            if (state.Equals(PlayerState.Unconscious))
            {
                TransitionState(PlayerState.Waiting);
            }
        }

        else if (other.gameObject.CompareTag("Environment"))
        {
            TransitionState(PlayerState.Unconscious);
        }

        else if (other.gameObject.CompareTag("Boundary"))
        {
            _rb.AddForce(-other.gameObject.transform.position);
        }
    }
Example #22
0
        private void OnThrowingGrenade(ThrowingGrenadeEventArgs ev)
        {
            if (CheckItem(ev.Player.CurrentItem))
            {
                ev.IsAllowed = false;
                Grenade grenadeComponent = ev.Player.GrenadeManager.availableGrenades[0].grenadeInstance.GetComponent <Grenade>();

                Timing.CallDelayed(1f, () =>
                {
                    Vector3 pos = ev.Player.CameraTransform.TransformPoint(grenadeComponent.throwStartPositionOffset);

                    if (ExplodeOnCollision)
                    {
                        var grenade = SpawnGrenade(pos, ev.Player.CameraTransform.forward * 9f, 1.5f, GetGrenadeType(ItemType)).gameObject;
                        CollisionHandler collisionHandler = grenade.gameObject.AddComponent <CollisionHandler>();
                        collisionHandler.owner            = ev.Player.GameObject;
                        collisionHandler.grenade          = grenadeComponent;
                        TrackedGrenades.Add(grenade);
                    }
                    else
                    {
                        SpawnGrenade(pos, ev.Player.CameraTransform.forward * 9f, FuseTime, GetGrenadeType(ItemType));
                    }

                    ev.Player.RemoveItem(ev.Player.CurrentItem);
                });
            }
        }
Example #23
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.tag == "EnterTown")
     {
         CollisionHandler col = other.gameObject.GetComponent <CollisionHandler>();
         GameManager.instance.nextHeroPosition = col.spawnPoint.transform.position;
         GameManager.instance.sceneToLoad      = col.sceneToLoad;
         GameManager.instance.LoadNextScene();
     }
     if (other.tag == "LeaveTown")
     {
         CollisionHandler col = other.gameObject.GetComponent <CollisionHandler>();
         GameManager.instance.nextHeroPosition = col.spawnPoint.transform.position;
         GameManager.instance.sceneToLoad      = col.sceneToLoad;
         GameManager.instance.LoadNextScene();
     }
     if (other.tag == "region1")
     {
         GameManager.instance.curRegion = 0;
     }
     if (other.tag == "region2")
     {
         GameManager.instance.curRegion = 1;
     }
     if (other.tag == "region3")
     {
         GameManager.instance.curRegion = 2;
     }
 }
Example #24
0
        /// <summary>
        /// Määrää, mihin aliohjelmaan siirrytään kun
        /// olio <code>obj</code> törmää tiettyyn toiseen olioon <code>target</code>.
        /// </summary>
        /// <param name="obj">Törmäävä olio.</param>
        /// <param name="target">Olio johon törmätään.</param>
        /// <param name="handler">Metodi, joka käsittelee törmäyksen (ei parametreja).</param>
        public void AddCollisionHandlerByRef <O, T>(O obj, T target, CollisionHandler <O, T> handler)
            where O : IPhysicsObject
            where T : IPhysicsObject
        {
            if (obj == null)
            {
                throw new NullReferenceException("Colliding object must not be null");
            }
            if (target == null)
            {
                throw new NullReferenceException("Collision target must not be null");
            }
            if (handler == null)
            {
                throw new NullReferenceException("Handler must not be null");
            }

            CollisionHandler <IPhysicsObject, IPhysicsObject> targetHandler =
                delegate(IPhysicsObject collider, IPhysicsObject collidee)
            {
                if (object.ReferenceEquals(collidee, target))
                {
                    handler((O)collider, (T)collidee);
                }
            };

            obj.Collided += targetHandler;
            collisionHandlers.Add(new CollisionRecord(obj, target, null, handler), targetHandler);
        }
Example #25
0
        /// <summary>
        /// Määrää, mihin aliohjelmaan siirrytään kun
        /// olio <code>obj</code> törmää toiseen olioon, jolla on tietty tagi <code>tag</code>.
        /// </summary>
        /// <param name="obj">Törmäävä olio.</param>
        /// <param name="tag">Törmättävän olion tagi.</param>
        /// <param name="handler">Metodi, joka käsittelee törmäyksen (ei parametreja).</param>
        public void AddCollisionHandlerByTag <O, T>(O obj, object tag, CollisionHandler <O, T> handler)
            where O : IPhysicsObject
            where T : IPhysicsObject
        {
            if (obj == null)
            {
                throw new NullReferenceException("Colliding object must not be null");
            }
            if (tag == null)
            {
                throw new NullReferenceException("Tag must not be null");
            }
            if (handler == null)
            {
                throw new NullReferenceException("Handler must not be null");
            }

            CollisionHandler <IPhysicsObject, IPhysicsObject> targetHandler =
                delegate(IPhysicsObject collider, IPhysicsObject collidee)
            {
                if (collidee is T && StringHelpers.StringEquals(collidee.Tag, tag))
                {
                    handler((O)collider, (T)collidee);
                }
            };

            obj.Collided += targetHandler;
            collisionHandlers.Add(new CollisionRecord(obj, null, tag, handler), targetHandler);
        }
Example #26
0
    /// <summary>
    /// Luodaan urhealle sankarillemme vihollisia
    /// </summary>
    /// <param name="paikka">Vihollisen sijainti</param>
    /// <param name="leveys">Vihollisen koko</param>
    /// <param name="korkeus">Vihollisen koko</param>
    /// <param name="liikemaara">Vihollisen liikkumasäde</param>
    public void LuoVihu(Vector paikka, double leveys, double korkeus, int liikemaara)
    {
        PhysicsObject vihu = new PhysicsObject(leveys, korkeus);

        vihu.Position  = paikka;
        vihu.CanRotate = false;
        vihu.Image     = VihunSkini();
        Add(vihu);

        PathFollowerBrain pfb    = new PathFollowerBrain();
        List <Vector>     reitti = new List <Vector>();

        reitti.Add(vihu.Position);
        Vector seuraavaPiste = new Vector(vihu.X - liikemaara * RUUDUN_LEVEYS, vihu.Y);

        reitti.Add(seuraavaPiste);
        pfb.Path = reitti;

        AddCollisionHandler(vihu, "pelaajanKivi", CollisionHandler.ExplodeBoth(50, true));

        Timer  heittoAjastin = new Timer();
        Random rnd           = new Random();

        heittoAjastin.Interval = rnd.Next(2, 8);
        heittoAjastin.Timeout += delegate() { Heita(vihu, "vihunKivi", -1000); };
        heittoAjastin.Start();
        vihu.Destroyed += delegate
        {
            heittoAjastin.Stop();
            pisteet.Value += 1;
        };

        vihu.Brain = pfb;
        pfb.Loop   = true;
    }
Example #27
0
        public void Init(GameObject gameObject)
        {
            m_Owner = gameObject;

            SurfaceHandler.Init(m_Owner);
            CollisionHandler.Init(m_Owner);
        }
        public void ResolveCollisionsWithTwoRigidBodies_ShouldMoveObjectsToCorrectPositions()
        {
            var firstObject = new GameObject
            {
                Layer       = 1,
                HasCollider = true,
                Position    = new Vector2D(0, -1)
            };

            firstObject.AddComponent <RigidBody2D>().Velocity = Vector2D.Right;

            var secondObject = new GameObject
            {
                Layer       = 1,
                HasCollider = true,
                Position    = new Vector2D(0, 1)
            };

            secondObject.AddComponent <RigidBody2D>().Velocity = Vector2D.Left;

            firstObject.Step();
            secondObject.Step();

            CollisionHandler.ResolveCollisions(new[] { firstObject, secondObject });

            firstObject.Position.Should().BeEquivalentTo(new Vector2D(0, -1) + Vector2D.Right);
            secondObject.Position.Should().BeEquivalentTo(new Vector2D(0, 1) + Vector2D.Left);
        }
Example #29
0
 void Start()
 {
     spaceship        = GetComponent <Rocket>();
     rigidBody        = GetComponent <Rigidbody>();
     collisionHandler = GetComponent <CollisionHandler>();
     audioSource      = GetComponent <AudioSource>();
 }
Example #30
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()
        {
            base.Initialize();

            //Author: Troy Carefoot
            Viewport viewport = GraphicsDevice.Viewport;

            mainScreen         = new Screen(viewport.Width, viewport.Height);
            gui_manager.Screen = mainScreen;
            gui_manager.Initialize();

            //Screen Margins
            mainScreen.Desktop.Bounds = new UniRectangle(
                new UniScalar(0.1f, 0.0f), new UniScalar(0.1f, 0.0f),          // x and y = 10%
                new UniScalar(0.8f, 0.0f), new UniScalar(0.8f, 0.0f)           // width and height = 80%
                );

            login_menu = new LoginMenu(this);             //Users must login to play online

            collisionHandler = new CollisionHandler();
            graphics.ApplyChanges();

            MediaPlayer.IsRepeating = true;
            MediaPlayer.Play(Assets.titleSong);
            SoundEffect.MasterVolume = .15f;
        }
Example #31
0
 protected override void Init()
 {
     //Грузим тестовый уровень для отладки
     level = LevelManager.GetLevelByNumber(0);
     StartCoroutine(WaitForLoadGameScene());
     handler = CollisionHandler.instance;
 }
Example #32
0
    void Start()
    {
        collisionHandler = GetComponent<CollisionHandler>();

        // Kinematic equation: accerlation = (2 x distance) / (time^2)
        // Initial velocity is zero.
        gravityAcceleration = (2 * jumpHeight) / Mathf.Pow (timeToJumpApex, 2);

        // Kinematic equation: final_velocity = acceleration * time
        // Initial velocity is zero.
        jumpVelocity = Mathf.Abs(gravityAcceleration) * timeToJumpApex;
    }
Example #33
0
 public static Collider Point(float x, float y, CollisionHandler handler, Object tag)
 {
     return new Collider()
     {
         Type = ColliderType.Point,
         X = x,
         Y = y,
         Handler = handler,
         Tag = tag,
         FilterType = typeof(GameObject)
     };
 }
Example #34
0
 public static Collider Circle(float x, float y, float radius, CollisionHandler handler, Object tag)
 {
     return new Collider()
     {
         Type = ColliderType.Circle,
         X = x,
         Y = y,
         X2 = radius,
         Handler = handler,
         Tag = tag,
         FilterType = typeof(GameObject)
     };
 }
 protected override void Initialize()
 {
     // TODO: Add your initialization logic here
     AssetBufferer.BufferImages(this.Content);
     this.character = new CharacterEntity(this.GraphicsDevice);
     this.characterAnimator = new CharacterAnimator(this.character);
     this.inputHandler = new PlayerInputHandler(this.character);
     this.fallingStuffAnimator = new FallingStuffAnimator();
     this.collisionHandler = new CollisionHandler(this.character, this.fallingStuffAnimator.fallingEntites);
     this.graphics.PreferredBackBufferWidth = Globals.GLOBAL_WIDTH;
     this.graphics.PreferredBackBufferHeight = Globals.GLOBAL_HEIGHT;
     this.graphics.ApplyChanges();
     base.Initialize();
 }
Example #36
0
 public static Collider LineFirst(float x, float y, float x2, float y2, CollisionHandler handler, Object tag)
 {
     return new Collider()
     {
         Type = ColliderType.LineFirst,
         X = x,
         Y = y,
         X2 = x2,
         Y2 = y2,
         Handler = handler,
         Tag = tag,
         FilterType = typeof(GameObject)
     };
 }
    public void Initialize(Transform t)
    {
        collision = GetComponent<CollisionHandler>();

        SetCameraTarget(t);
        xOrbitInput = yOrbitInput = zoomInput = yOrbitSnapInput = mouseOrbitInput = xMouseOrbitInput = 0;

        if (target)
        {
            MoveToTarget();

            collision.Initialize(GetComponent<Camera>());
            collision.UpdateCollisionHandler(destination, targetPos);
        }

        previousMousePos = currentMousePos = Input.mousePosition;
    }
        static void Main()
        {
            var objectGenerator = new ObjectGenerator(WorldWidth, WorldHeight);
            var consoleRenderer = new ConsoleRenderer(WorldWidth, WorldHeight);
            var collisionHandler = new CollisionHandler(WorldWidth, WorldHeight);
            var controller = new Controller();
            controller.Pause += Controller_Pause;

            var engine = new ExtendedEngine(WorldWidth,
                WorldHeight,
                objectGenerator,
                collisionHandler,
                consoleRenderer,
                controller);

            engine.Run();
        }
Example #39
0
    void Start()
    {
        collision = GetComponent<CollisionHandler>();

        SetCameraTarget(target);

        zoomInput = mouseOrbitInput = 0;

        if (target)
        {
            controller = target.GetComponent<PlayerController>();
            MoveToTarget();

            collision.Initialize(Camera.main);
            collision.UpdateCollisionHandler(destination, targetPos);
        }

    }
Example #40
0
        public Bubble(Model model, Game game, Camera camera, OctTree octTree, Vector3 startPosition, Vector3 startDirection, Vector3 startUp, BasicCube[] worldMap, ScreenManager screenManager)
            : base(model, game)
        {
            this.octTree = octTree;
            //  shadow = game.Content.Load<Effect>(@"Shader/Shadow");
            movementHandler = new MovementAndInputHandler(game, this);
            collisionHandler = new CollisionHandler(game, this, screenManager, worldMap);
            effect = ((Spectrum)game).effect;
            texture = screenManager.texManager.getBubbleTexture();
            this.camera = camera;
            this.currentPosition = startPosition;
            this.game = game;
            this.bubble = model;
            this.startPosition = startPosition;
            this.currentPosition = startPosition;
            movementHandler.setStartValues(startPosition, Vector3.Backward, Vector3.Up, Quaternion.Identity, SpectrumEnums.Orientation.posY);

            this.soundManager = ((Spectrum)game).soundManager;

            this.screenManager = screenManager;
            this.screenManager.setPlayer(this);
        }
        public bool SubscribeCollisionEvent(Guid GUID, CollisionHandler handler)
        {
            bool subscribed = false;

            if (collisionEvents.ContainsKey(GUID))
            {
                collisionEvents[GUID] += handler;
                subscribed = true;
            }

            return subscribed;
        }
Example #42
0
 public void SetCollisionHandler(CollisionHandler collisionHandler)
 {
     this.entity.FindComponent<BlockEntityBehavior>().EventCollision += collisionHandler;
 }
 public bool SubscribeCollisionEvent(Guid GUID, CollisionHandler handler)
 {
     return true;
 }
Example #44
0
 // Use this for initialization
 void Start()
 {
     this.colHandler = GetComponent<CollisionHandler>();
     this.speed = 0.1f;
 }
Example #45
0
    void Start()
    {
        if (Instance != null)
        {
            Instance.orbit.yRotation = -180;
            Instance.position.distanceFromTarget = -20;
            Instance.position.newDistance = -20;
            Destroy(gameObject);
        }
        else
        {
            Instance = this;
            DontDestroyOnLoad(gameObject);
        }

        //setting camera target
        SetCameraTarget(target);

        collision = GetComponent<CollisionHandler>();

        if (target)
        {
            MoveToTarget();
            collision.Initialize(Camera.main);
            collision.UpdateCollisionHandler(destination, targetPos);
        }
        position.newDistance = position.distanceFromTarget;
    }
Example #46
0
    void Start()
    {
        collision = GetComponent<CollisionHandler>();

        SetCameraTarget(target);

        zoomInput = yOrbitSnapInput = mouseOrbitInput = 0;

        if (target)
        {
            MoveToTarget();

            collision.Initialize(Camera.main);
            collision.UpdateCollisionHandler(destination, targetPos);
        }

        previousMousePos = currentMousePos = Input.mousePosition;
    }