Beispiel #1
0
        /* Want to reverse direction if it hits link, another blade trap, or a wall. */

        public override void ResolveCollision(LinkCollisionResponse other)
        {
            BladeTrapMovement btMovement = entity.GetComponent <BladeTrapMovement>();

            if (entity.GetComponent <BladeTrapMovement>().state == BladeTrapMovement.State.EXTENDING)
            {
                btMovement.ReverseDirection();
            }
        }
        public override void ResolveCollision(LinkCollisionResponse other)
        {
            LinkBehavior linkBehavior = other.entity.GetComponent <LinkBehavior>();

            if (linkBehavior.attacking)
            {
                // sound effect
                //Sound.PlaySound(Sound.SoundEffects.Enemy_Hit, entity, !Sound.SOUND_LOOPS);

                entity.GetComponent <EnemyHealthManagement>().DeductHealth(Constants.LINK_SWORD_DAMAGE);

                // Push back
                Vector2 enemyPos = other.entity.GetComponent <Transform>().position;
                Vector2 linkPos  = entity.GetComponent <Transform>().position;
                Vector2 diff     = enemyPos - linkPos;
                int     distance = Constants.ENEMY_KNOCKBACK_DISTANCE;
                int     frames   = Constants.ENEMY_KNOCKBACK_FRAMES;

                // Enemy is Up from Link
                // UPWARD && MORE VERTICAL THAN HORIZONTAL
                if (enemyPos.Y <= linkPos.Y && Math.Abs(diff.Y) >= Math.Abs(diff.X))
                {
                    entity.AddComponent(new EnemyKnockback(Constants.Direction.DOWN, distance, frames));
                    // Console.WriteLine("Enemy is up from link!");
                }

                // Enemy is Right from Link
                // RIGHTWARD && MORE HORIZONTAL THAN VERTICAL
                else if (enemyPos.X >= linkPos.X && Math.Abs(diff.X) >= Math.Abs(diff.Y))
                {
                    entity.AddComponent(new EnemyKnockback(Constants.Direction.LEFT, distance, frames));
                    // Console.WriteLine("Enemy is right from link!");
                }

                // Enemy is Down from Link
                // DOWNWARD && MORE VERTICAL THAN HORIZONTAL
                else if (enemyPos.Y >= linkPos.Y && Math.Abs(diff.Y) >= Math.Abs(diff.X))
                {
                    entity.AddComponent(new EnemyKnockback(Constants.Direction.UP, distance, frames));
                    // Console.WriteLine("Enemy is down from link!");
                }

                // Enemy is Left from Link
                // LEFTWARD && MORE HORIZONTAL THAN VERTICAL
                else if (enemyPos.X <= linkPos.X && Math.Abs(diff.X) >= Math.Abs(diff.Y))
                {
                    entity.AddComponent(new EnemyKnockback(Constants.Direction.RIGHT, distance, frames));
                    // Console.WriteLine("Enemy is left from link!");
                }

                // Debug; If this ever gets output, something is wrong.
                else
                {
                    Console.WriteLine("Link was unrecognized direction!");
                }
            }
        }
 public override void ResolveCollision(LinkCollisionResponse other)
 {
     if (!done && LinkBehavior.linkDirection == direction)
     {
         BehaviorScript script = new BlockMovement(direction, "boss_door");
         entity.AddComponent(script);
         done = true;
     }
 }
        public override void ResolveCollision(LinkCollisionResponse other)
        {
            LevelManager.Load(nextRoomPath);

            LevelManager.mapRoot.GetComponent <Transform>().position    = -1 * LevelManager.currentLevel.Root.GetComponent <Transform>().position;
            LevelManager.mapRoot.GetComponent <Transform>().position.Y += Level.screen_height;
            // "other" here should be Link
            other.entity.GetComponent <Transform>().position = LevelManager.currentLevel.Root.GetComponent <Transform>().position + startPos;
        }
        public override void ResolveCollision(LinkCollisionResponse other)
        {
            var link         = other.entity;
            var linkBehavior = link.GetComponent <LinkBehavior>();

            if (linkBehavior.attacking)
            {
                Entity.Destroy(entity);
            }
        }
Beispiel #6
0
        public override void ResolveCollision(LinkCollisionResponse other)
        {
            if (!done)
            {
                Link          link          = (Link)other.entity;
                LinkInventory linkInventory = link.GetComponent <LinkInventory>();

                // update item inventory numbers
                switch (currentItem.GetItemType())
                {
                case "bow":
                    linkInventory.AddUseableItem((int)ItemInventory.UseInventory.BOW);
                    // Console.WriteLine("Bow = " + linkInventory.GetUseableItemCount((int)ItemInventory.UseInventory.BOW));
                    LevelManager.backdrop.Bow.GetComponent <Sprite>().SetVisible(true);
                    break;

                case "raft":
                    linkInventory.AddPassiveItem((int)ItemInventory.PassiveIventory.RAFT);
                    // Console.WriteLine("Raft = " + linkInventory.GetPassiveItemCount((int)ItemInventory.PassiveIventory.RAFT));
                    break;

                case "ladder":
                    linkInventory.AddPassiveItem((int)ItemInventory.PassiveIventory.LADDER);
                    // Console.WriteLine("Ladder = " + linkInventory.GetPassiveItemCount((int)ItemInventory.PassiveIventory.LADDER));
                    break;

                case "powerBand":
                    linkInventory.AddPassiveItem((int)ItemInventory.PassiveIventory.POWER_BAND);
                    // Console.WriteLine("Power Band = " + linkInventory.GetPassiveItemCount((int)ItemInventory.PassiveIventory.POWER_BAND));
                    break;

                default:
                    break;
                }

                Sprite       itemSprite      = entity.GetComponent <Sprite>();
                int          itemSpriteWidth = itemSprite.sprite.frames[itemSprite.sprite.currentFrame].Width;
                LinkBehavior linkBehavior    = link.GetComponent <LinkBehavior>();
                linkBehavior.picking_up_item = true;
                linkBehavior.linkHands       = 1;
                Transform linkTrans = link.GetComponent <Transform>();
                linkTrans.position += new Vector2(-itemSpriteWidth / 2, 0);
                Sprite linkSprite       = link.GetComponent <Sprite>();
                int    linkSpriteHeight = linkSprite.sprite.frames[linkSprite.sprite.currentFrame].Height;
                entity.GetComponent <Transform>().position          += new Vector2(0, -linkSpriteHeight);
                entity.GetComponent <ItemDeletionTimer>().startTimer = true;

                done = true;
            }
        }
Beispiel #7
0
        public override void ResolveCollision(LinkCollisionResponse other)
        {
            if (!done)
            {
                Link          link          = (Link)other.entity;
                LinkInventory linkInventory = link.GetComponent <LinkInventory>();

                // update item inventory numbers
                switch (currentItem.GetItemType())
                {
                case "heartContainer":
                    Scene.Find("link").GetComponent <LinkHealthManagement>().health = Constants.LINK_STARTING_HEALTH;
                    Sound.PlaySound(Sound.SoundEffects.Get_Heart, false);
                    break;

                case "triforce":
                    linkInventory.AddPassiveItem((int)ItemInventory.PassiveIventory.TRIFORCE);
                    // Console.WriteLine("Triforce = " + linkInventory.GetPassiveItemCount((int)ItemInventory.PassiveIventory.TRIFORCE));
                    break;

                default:
                    break;
                }

                // animation for picking up item
                LinkBehavior linkBehavior = link.GetComponent <LinkBehavior>();
                linkBehavior.picking_up_item = true;
                linkBehavior.linkHands       = 2;
                Sprite    linkSprite       = entity.GetComponent <Sprite>();
                int       linkSpriteHeight = linkSprite.sprite.frames[linkSprite.sprite.currentFrame].Height;
                int       linkSpriteWidth  = linkSprite.sprite.frames[linkSprite.sprite.currentFrame].Width;
                Sprite    itemSprite       = entity.GetComponent <Sprite>();
                int       itemSpriteHeight = itemSprite.sprite.frames[itemSprite.sprite.currentFrame].Height;
                int       itemSpriteWidth  = itemSprite.sprite.frames[itemSprite.sprite.currentFrame].Width;
                Transform linkTrans        = link.GetComponent <Transform>();
                linkTrans.position += new Vector2(0, itemSpriteHeight);
                Transform itemPos = entity.GetComponent <Transform>();
                itemPos.position += new Vector2(0, -itemSpriteHeight);
                currentItem.GetComponent <ItemDeletionTimer>().startTimer = true;

                // if triforce we should quit the game? make black screen? credits?
                done = true;
                if (currentItem.GetItemType() == "triforce")
                {
                    LevelManager.Victory();
                }
            }
        }
        public override void ResolveCollision(LinkCollisionResponse other)
        {
            if (!collided)
            {
                collided = true;

                // Actual item pickup is the fanfare, selecting from inventory is Get_Item
                Sound.PlaySound(Sound.SoundEffects.Fanfare, entity, !Sound.SOUND_LOOPS);

                // logic for adding items to HUD depending on type
                Link          link      = (Link)other.entity;
                LinkInventory inventory = link.GetComponent <LinkInventory>();

                // update item inventory numbers
                switch (currentItem.GetItemType())
                {
                case "fairy":
                    // increment health by an amount
                    break;

                case "bomb":
                    inventory.AddBombs();
                    // Console.WriteLine("Bombs = " + inventory.GetUseableItemCount((int)ItemInventory.UseInventory.BOMB));
                    break;

                case "arrow":
                    inventory.AddPassiveItem((int)ItemInventory.PassiveIventory.ARROWS);
                    // Console.WriteLine("Arrows = " + inventory.GetPassiveItemCount((int)ItemInventory.PassiveIventory.ARROWS));
                    break;

                case "regularkey":
                    inventory.AddDungeonItem((int)ItemInventory.DungeonInventory.KEYS);
                    // Console.WriteLine("Keys = " + inventory.GetDungeonItemCount((int)ItemInventory.DungeonInventory.KEYS));
                    break;

                case "bosskey":
                    inventory.AddDungeonItem((int)ItemInventory.DungeonInventory.BOSS_KEY);
                    // Console.WriteLine("Boss Key = " + inventory.GetDungeonItemCount((int)ItemInventory.DungeonInventory.BOSS_KEY));
                    break;

                case "clock":
                    // freeze enemies for a time
                    break;

                case "compass":
                    inventory.AddDungeonItem((int)ItemInventory.DungeonInventory.COMPASS);
                    // Console.WriteLine("Compass = "******"yellowmap":
                case "bluemap":
                    inventory.AddDungeonItem((int)ItemInventory.DungeonInventory.MAP);
                    // Console.WriteLine("Map = " + inventory.GetDungeonItemCount((int)ItemInventory.DungeonInventory.MAP));
                    break;

                case "rupee":
                    inventory.AddPassiveItem((int)ItemInventory.PassiveIventory.RUPEES, currentItem.value);
                    // Console.WriteLine("Rupees = " + inventory.GetPassiveItemCount((int)ItemInventory.PassiveIventory.RUPEES));
                    Sound.PlaySound(Sound.SoundEffects.Get_Rupee, false);
                    break;

                default:

                    break;
                }

                Entity.Destroy(entity);
            }
        }
        public override void ResolveCollision(LinkCollisionResponse other)
        {
            Door entity = (Door)this.entity;

            if (entity.doorType == Door.Type.Open)
            {
                if (enabled && flag)
                {
                    //Debug.WriteLine(direction);
                    // be sure we only trigger this collider once
                    enabled = false;
                    // pause game until transition finished
                    // TODO
                    // load new level
                    string currentLevel = LevelManager.currentLevelPath;
                    var    split        = currentLevel.Split('_');
                    int    x            = Int16.Parse(split[0]);
                    int    y            = Int16.Parse(split[1]);

                    switch (direction)
                    {
                    case Constants.Direction.UP:
                        y--;
                        break;

                    case Constants.Direction.LEFT:
                        x--;
                        break;

                    case Constants.Direction.RIGHT:
                        x++;
                        //flag = false;
                        break;

                    case Constants.Direction.DOWN:
                        y++;
                        //flag = false;
                        break;
                    }

                    string nextRoom = x + "_" + y;
                    //Debug.WriteLine(nextRoom);

                    ////LevelManager.activeLevel.Destroy();
                    ////LevelManager.activeLevel = new Level(nextRoom);
                    LevelManager.Load(nextRoom);

                    enabled = false;


                    // disable all door colliders until Link moves into the next room
                    foreach (DoorCollisionResponse d in Door.doorResponses)
                    {
                        d.enabled = false;
                    }

                    // begin motion for Map
                    LevelManager.mapRoot.GetComponent <LevelParentBehavior>().Move(direction);
                    // begin motion for Link
                    LevelManager.link.GetComponent <LinkLevelBehavior>().Move(direction);
                }
            }
            else if (entity.doorType == Door.Type.BombWall) // dont let link through unless opened
            {
                var transform = other.entity.GetComponent <Transform>();
                transform.position = transform.lastPosition;
            }
            else if (entity.doorType == Door.Type.Locked)
            {
                List <DungeonItems> inven = other.entity.GetComponent <LinkInventory>().dungeonInventory;
                foreach (DungeonItems item in inven)
                {
                    if (item.type == DungeonItems.Types.KEY)
                    {
                        if (item.amount.current > 0)
                        {
                            item.amount.current -= 1;
                            entity.doorType      = Door.Type.Open;
                        }
                        break;
                    }
                }
                other.entity.GetComponent <Transform>().position = other.entity.GetComponent <Transform>().lastPosition;
            }
        }
Beispiel #10
0
        public override void ResolveCollision(LinkCollisionResponse other)
        {
            Door entity = (Door)this.entity;

            if (entity.doorType == Door.Type.Open)
            {
                if (enabled && flag)
                {
                    //Debug.WriteLine(direction);
                    // be sure we only trigger this collider once
                    enabled = false;
                    // pause game until transition finished
                    // TODO
                    // load new level
                    string currentLevel = LevelManager.currentLevelPath;
                    var    split        = currentLevel.Split('_');
                    int    x            = Int16.Parse(split[0]);
                    int    y            = Int16.Parse(split[1]);

                    switch (direction)
                    {
                    case Constants.Direction.UP:
                        y--;
                        break;

                    case Constants.Direction.LEFT:
                        x--;
                        break;

                    case Constants.Direction.RIGHT:
                        x++;
                        //flag = false;
                        break;

                    case Constants.Direction.DOWN:
                        y++;
                        //flag = false;
                        break;
                    }

                    string nextRoom = x + "_" + y;

                    //Debug.WriteLine(nextRoom);

                    ////LevelManager.activeLevel.Destroy();
                    ////LevelManager.activeLevel = new Level(nextRoom);
                    LevelManager.Load(nextRoom);
                    GameStateManager.Transition = true;

                    enabled = false;


                    // disable all door colliders until Link moves into the next room
                    foreach (DoorCollisionResponse d in Door.doorResponses)
                    {
                        d.enabled = false;
                    }

                    // begin motion for Link (which will move the Map as well)
                    LevelManager.link.GetComponent <LinkLevelBehavior>().Move(direction);
                }
            }
            else if (entity.doorType == Door.Type.BombWall) // dont let link through unless opened
            {
                var transform = other.entity.GetComponent <Transform>();
                transform.position = transform.lastPosition;
            }
            else if (entity.doorType == Door.Type.Locked)
            {
                if (other.entity.GetComponent <LinkInventory>().GetDungeonItemCount((int)DungeonItems.Types.KEY) > 0)
                {
                    other.entity.GetComponent <LinkInventory>().UseKey();
                    entity.OpenDoor();
                    Sound.PlaySound(Sound.SoundEffects.Door_Unlock, entity, !Sound.SOUND_LOOPS);
                }
                other.entity.GetComponent <Transform>().position = other.entity.GetComponent <Transform>().lastPosition;
            }
        }