예제 #1
0
        public bool CharHitsPlatform(Character character, Platform platform)
        {
            DirCardinal dir = CollideDetect.GetDirectionOfCollision(character, platform);

            if (dir != DirCardinal.Down)
            {
                return(false);
            }

            // Character is "Dropping" through platforms:
            if (character.status.action is DropdownAction)
            {
                character.physics.touch.TouchMover(null);
                return(false);
            }

            // Activate the Platform
            platform.ActivatePlatform();
            character.physics.touch.TouchMover(platform);

            // Assign the Character with the "OnMover" action, which will maintain their momentum after leaving the platform.
            ActionMap.OnMover.StartAction(character);

            // Special Character Collision for Platforms.
            // Only the Character should run collision. Platform has no need to be touched, pushed, aligned, etc.
            // Additionally, it needs to skip the intend.Y test normally associated with CollideObjDown(platform).
            character.physics.touch.TouchDown();
            character.physics.AlignUp(platform);
            character.physics.StopY();

            return(true);
        }
예제 #2
0
        public bool RunImpact(GameObject character, GameObject obj)
        {
            Character ch = (Character)character;

            // Specific Impact Types
            if (obj is Enemy)
            {
                return(((Enemy)obj).RunCharacterImpact(ch));
            }
            if (obj is Item)
            {
                return(this.CharHitsItem(ch, (Item)obj));
            }
            if (obj is Platform)
            {
                return(this.CharHitsPlatform(ch, (Platform)obj));
            }
            if (obj is Projectile)
            {
                return(this.CharHitsProjectile(ch, (Projectile)obj));
            }
            if (obj is Block)
            {
                return(this.CharHitsBlock(ch, (Block)obj));
            }

            DirCardinal dir = CollideDetect.GetDirectionOfCollision(ch, obj);

            // Standard Collision
            return(Impact.StandardImpact(ch, obj, dir));
        }
예제 #3
0
        public bool EnemyHitsPlatform(Enemy enemy, Platform platform)
        {
            // If the enemy doesn't collide with tiles, they don't collide with platforms.
            if (enemy.CollideVal <= CollideEnum.NoTileCollide)
            {
                return(false);
            }

            DirCardinal dir = CollideDetect.GetDirectionOfCollision(enemy, platform);

            if (dir != DirCardinal.Down)
            {
                return(false);
            }

            // Enemy needs to track it's platform physics:
            enemy.physics.touch.TouchMover(platform);

            // Special Actor Collision for Platforms.
            // Only the Actor should run collision. Platform has no need to be touched, pushed, aligned, etc.
            // Additionally, it needs to skip the intend.Y test normally associated with CollideObjDown(platform).
            enemy.physics.touch.TouchDown();
            enemy.physics.AlignUp(platform);
            enemy.physics.StopY();

            return(true);
        }
예제 #4
0
        public bool CharHitsProjectile(Character character, Projectile projectile)
        {
            // Skip Character if they cast the projectile.
            if (projectile.ByCharacterId == character.id)
            {
                return(false);
            }

            DirCardinal dir = CollideDetect.GetDirectionOfCollision(character, projectile);

            // Set the projectile to bounce off of the screen:
            EndBounceParticle.SetParticle(character.room, Systems.mapper.atlas[(byte)AtlasGroup.Objects], projectile.SpriteName, new Vector2(projectile.posX, projectile.posY), Systems.timer.Frame + 40, 1, 0.5f, 0f);

            // Destroy the Projectile
            projectile.Destroy();

            // If this projectile can be jumped on:
            if (projectile.SafelyJumpOnTop)
            {
                // Hit from above (projectile is below):
                if (dir == DirCardinal.Down)
                {
                    //character.BounceUp(projectile.posX + projectile.bounds.MidX, 1, 0, 0);
                    ActionMap.Jump.StartAction(character, 1, 0, 0, true, false);
                    Systems.sounds.bulletJump.Play();
                    return(true);
                }

                // Hit from below (projectile is above):
                else if (dir == DirCardinal.Up && character.status.action is Action)
                {
                    character.status.action.EndAction(character);
                }
            }

            // If wearing a hard hat, can ignore damage from above.
            if (dir == DirCardinal.Up)
            {
                if (character.hat is HardHat)
                {
                    return(true);
                }
            }

            character.wounds.ReceiveWoundDamage(projectile.Damage);

            return(true);
        }
예제 #5
0
        public bool CharHitsItem(Character character, Item item)
        {
            // Sport Ball
            if (item is SportBall)
            {
                return(((SportBall)item).RunCharacterImpact(character));
            }

            // If this item is being held, skip.
            if (item.isHeld)
            {
                return(false);
            }

            // If the entity is intangible, don't collide with the Character.
            if (item.intangible > Systems.timer.Frame)
            {
                return(false);
            }

            DirCardinal dir = CollideDetect.GetDirectionOfCollision(character, item);

            // If item is hit from side:
            if (dir == DirCardinal.Left || dir == DirCardinal.Right)
            {
                // Check if Grabbing Item
                if (character.heldItem.WillPickupAttemptWork(item, dir))
                {
                    character.heldItem.PickUpItem(item);
                    return(true);
                }
            }

            // If item is hit from above:
            else if (dir == DirCardinal.Up)
            {
                // Check if Grabbing Item
                if (character.heldItem.WillPickupAttemptWork(item, character.FaceRight ? DirCardinal.Right : DirCardinal.Left))
                {
                    character.heldItem.PickUpItem(item);
                    return(true);
                }
            }

            // If we've made it this far, run standard collision with item:
            return(Impact.StandardImpact(character, item, dir));
        }
예제 #6
0
        public bool RunImpact(GameObject enemy, GameObject obj)
        {
            Enemy en = (Enemy)enemy;

            // If the object is a platform, run special collision tests first.
            if (obj is Platform)
            {
                return(this.EnemyHitsPlatform(en, (Platform)obj));
            }

            // For projectiles, direction may be unnecessary.
            if (obj is Projectile)
            {
                return(en.RunProjectileImpact(obj as Projectile));
            }

            // Don't collide with Flight Enemies
            if (en is EnemyFlight || obj is EnemyFlight)
            {
                return(false);
            }

            DirCardinal dir = CollideDetect.GetDirectionOfCollision(en, obj);

            // Specific Impact Types
            if (obj is Enemy)
            {
                return(this.EnemyHitsEnemy(en, (Enemy)obj, dir));
            }
            if (obj is Item)
            {
                return(this.EnemyHitsItem(en, (Item)obj, dir));
            }
            if (obj is Block)
            {
                return(this.EnemyHitsBlock(en, (Block)obj, dir));
            }

            // Standard Collision
            return(Impact.StandardImpact(en, obj, dir));
        }
예제 #7
0
        public bool ItemHitsPlatform(Item item, Platform platform)
        {
            DirCardinal dir = CollideDetect.GetDirectionOfCollision(item, platform);

            if (dir != DirCardinal.Down)
            {
                return(false);
            }

            // Item needs to track it's platform physics:
            item.physics.touch.TouchMover(platform);

            // Special Actor Collision for Platforms.
            // Only the Actor should run collision. Platform has no need to be touched, pushed, aligned, etc.
            // Additionally, it needs to skip the intend.Y test normally associated with CollideObjDown(platform).
            item.physics.touch.TouchDown();
            item.physics.AlignUp(platform);
            item.physics.StopY();

            return(true);
        }
예제 #8
0
        public bool RunImpact(GameObject item, GameObject obj)
        {
            Item it = (Item)item;

            // Specific Impact Types
            if (obj is Projectile)
            {
                return(this.ItemHitsProjectile(it, (Projectile)obj));
            }

            // Make sure the items aren't being held.
            if (it.isHeld)
            {
                return(false);
            }

            // Platforms
            if (obj is Platform)
            {
                return(this.ItemHitsPlatform(it, (Platform)obj));;
            }

            // Item-Item Collision
            if (obj is Item)
            {
                if (((Item)obj).isHeld)
                {
                    return(false);
                }
            }

            DirCardinal dir = CollideDetect.GetDirectionOfCollision(it, obj);

            // Standard Collision
            return(Impact.StandardImpact(it, obj, dir));
        }
예제 #9
0
        public bool CharHitsBlock(Character character, Block block)
        {
            DirCardinal dir = CollideDetect.GetDirectionOfCollision(character, block);

            return(Impact.StandardImpact(character, block, dir));
        }