public override void ResolveCollision(FireballCollisionResponse other)
        {
            LinkBehavior linkBehavior = entity.GetComponent <LinkBehavior>();

            // Take Damage
            entity.GetComponent <LinkHealthManagement>().DeductHealth(other.damage);

            // Change to Hurt Sprite (enables and disables immunity inside)
            if (!entity.GetComponent <LinkHealthManagement>().immune)
            {
                entity.GetComponent <LinkHealthManagement>().DeductHealth(Constants.FIREBALL_DAMAGE);
                linkBehavior.damaged = true;
                entity.GetComponent <LinkHealthManagement>().immune = true;

                // Push back
                Vector2 linkPos  = entity.GetComponent <Transform>().position;
                Vector2 enemyPos = other.entity.GetComponent <Transform>().position;
                Vector2 diff     = linkPos - enemyPos;
                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 LinkKnockback(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 LinkKnockback(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 LinkKnockback(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 LinkKnockback(Constants.Direction.RIGHT, distance, frames));
                    // Console.WriteLine("Enemy is left from link!");
                }

                // Debug; If this ever gets output, something is wrong.
                else
                {
                    Console.WriteLine("Enemy was unrecognized direction!");
                }
            }
        }
Esempio n. 2
0
    /**
     * Check if this platform is connected by the special starting link
     */
    public bool isConnectedToStart(LinkBehavior startingLink)
    {
        List <ConnectableEntityBehavior> alreadySearched = new List <ConnectableEntityBehavior>();
        ConnectableEntityBehavior        temp            = startingLink.connectableEntity;

        while (temp != null)
        {
            if (temp == this)
            {
                return(true);
            }
            if (temp.GetComponent <ContainerEntityBehavior>() != null &&
                temp.GetComponent <ContainerEntityBehavior>().GetChildComponent <LinkBehavior>() != null &&
                temp.GetComponent <ContainerEntityBehavior>().GetChildComponent <LinkBehavior>().connectableEntity != null)
            {
                alreadySearched.Add(temp);
                temp = temp.GetComponent <ContainerEntityBehavior>().GetChildComponent <LinkBehavior>().connectableEntity;
                if (alreadySearched.Contains(temp)) // you have reached the end of the list or there is an infinite loop
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
        return(false);
    }
Esempio n. 3
0
        public LinkLabel()
        {
            LinkArea      = new LinkArea(0, -1);
            link_behavior = LinkBehavior.SystemDefault;
            link_visited  = false;
            pieces        = null;
            focused_index = -1;

            string_format.FormatFlags |= StringFormatFlags.NoClip;

            ActiveLinkColor   = Color.Red;
            DisabledLinkColor = ThemeEngine.Current.ColorGrayText;
            LinkColor         = Color.FromArgb(255, 0, 0, 255);
            VisitedLinkColor  = Color.FromArgb(255, 128, 0, 128);
            SetStyle(ControlStyles.Selectable, false);
            SetStyle(ControlStyles.ResizeRedraw |
                     ControlStyles.UserPaint |
                     ControlStyles.AllPaintingInWmPaint |
                     ControlStyles.SupportsTransparentBackColor |
                     ControlStyles.Opaque
#if NET_2_0
                     | ControlStyles.OptimizedDoubleBuffer
#else
                     | ControlStyles.DoubleBuffer
#endif
                     , true);
            CreateLinkPieces();
        }
    public void MoveAboveLinkedPlatform()
    {
        LinkBehavior childLink = getChildLink();

        if (childLink.connectableEntity != null)
        {
            targetLocation = childLink.connectableEntity.transform.position + (new Vector3(0, 3, 0));
        }
    }
        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!");
                }
            }
        }
Esempio n. 6
0
 public ToolStripLabel(string text, Image image, bool isLink, EventHandler onClick, string name)
     : base(text, image, onClick, name)
 {
     this.active_link_color  = Color.Red;
     this.is_link            = isLink;
     this.link_behavior      = LinkBehavior.SystemDefault;
     this.link_color         = Color.FromArgb(0, 0, 255);
     this.link_visited       = false;
     this.visited_link_color = Color.FromArgb(128, 0, 128);
 }
    public LinkBehavior getChildLink()
    {
        LinkBehavior lb = GetComponent <ContainerEntityBehavior>().GetChildComponent <LinkBehavior>();

        if (lb == null)
        {
            GetComponent <ContainerEntityBehavior>().refreshChildList();
            lb = GetComponent <ContainerEntityBehavior>().GetChildComponent <LinkBehavior>();
        }
        return(lb);
    }
Esempio n. 8
0
        public static DataGridViewLinkColumn generarBotonDataGrid
            (Boolean linkValue, String headerText, String nombreProperty, LinkBehavior comportamiento, String texto)
        {
            DataGridViewLinkColumn link = new DataGridViewLinkColumn();

            link.UseColumnTextForLinkValue = linkValue;
            link.HeaderText       = headerText;
            link.DataPropertyName = nombreProperty;
            link.LinkBehavior     = comportamiento;
            link.Text             = texto;

            return(link);
        }
Esempio n. 9
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;
            }
        }
Esempio n. 10
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();
                }
            }
        }
Esempio n. 11
0
    public string getVariableName()
    {
        if (containerEntity == null)
        {
            return(variableName);
        }

        if (containerEntity != null && containerEntity.GetComponent <ConnectableEntityBehavior>() != null &&
            containerEntity.GetComponent <ConnectableEntityBehavior>().getMostRecentlyConnectedLink() != null)
        {
            LinkBehavior mostRecent        = containerEntity.GetComponent <ConnectableEntityBehavior>().getMostRecentlyConnectedLink();
            string       mostRecentVarName = mostRecent.getVariableName();
            return(mostRecentVarName + ".next");
        }
        return(variableName);
    }
    private List <PlatformBehavior> platformEntities;      // a reference to all platform entities in the level. TODO: generalize this?


    void Start()
    {
        debugFrameCount = 0;

        selectedLink = null;
        hoverLink    = null;

        mouseOverLinkRefs = new List <LinkBehavior>();
        loggingManager.setGameController(this);
        worldGenerator.setGameController(this);
        hudBehavior.setGameController(this);
        hudBehavior.setLoggingManager(loggingManager);
        gameCanvas = hudBehavior.GetComponent <Canvas>();

        // set the game to its initial state
        gameCanvas.gameObject.SetActive(false);
        winGameCanvas.gameObject.SetActive(false);
        menuCanvas.gameObject.SetActive(true);
    }
Esempio n. 13
0
 public LinkBehavior getMostRecentlyConnectedLink()
 {
     if (incomingConnectionLinks.Count > 0)
     {
         LinkBehavior linkToReturn = null;
         foreach (LinkBehavior lb in incomingConnectionLinks)
         {
             if (lb.type == LinkBehavior.Type.HELICOPTER || lb.type == LinkBehavior.Type.START || lb.containerEntity == null)
             {
                 linkToReturn = lb;
                 break;
             }
         }
         if (linkToReturn != null)
         {
             return(linkToReturn);
         }
         return(incomingConnectionLinks[incomingConnectionLinks.Count - 1]); // return last one added
     }
     return(null);
 }
    // Update is called once per frame
    void Update()
    {
        float        distAway  = Vector3.Distance(transform.position, targetLocation);
        LinkBehavior childLink = getChildLink();

        if (childLink != null)
        {
            if (distAway > 0.1f)
            {
                Vector3 moveDir = (targetLocation - transform.position).normalized;
                // move, lerping based on the distance away
                transform.Translate(Vector3.Lerp(new Vector3(), (moveDir * flySpeed * Time.deltaTime), distAway / 12f));
                if (childLink != null && childLink.connectableEntity != null)
                {
                    childLink.GetComponent <LinkBehavior>().setRenderArrow(false);
                    childLink.GetComponent <LinkBehavior>().UpdateRendering(); // refresh its position as it moves
                }
            }
            else
            {
                childLink.setRenderArrow(true);
            }
        }
    }
Esempio n. 15
0
        /// <summary>
        /// 数据
        /// </summary>
        public void Data()
        {
            var type = (SiteLinkType)Enum.Parse(typeof(SiteLinkType),
                                                Request.Query("type"), true);

            string linkRowsHtml;
            //链接列表
            var sb = new StringBuilder();
            var i  = 0;

            var bindTitle = string.Empty;
            var archive   = default(ArchiveDto);
            var cate      = default(CategoryDto);

            IList <SiteLinkDto> links = new List <SiteLinkDto>(
                ServiceCall.Instance.SiteService.GetLinksByType(SiteId, type, true));


            #region 链接拼凑

            LinkBehavior bh = (link) =>
            {
                i++;
                sb.Append("<tr visible=\"").Append(link.Visible ? "1" : "0").Append("\" indent=\"")
                .Append(link.Id.ToString())
                .Append("\"><td class=\"hidden\">").Append(link.Id.ToString()).Append("</td>")
                .Append("<td class=\"")
                .Append(link.Pid != 0 ? "child" : "parent")
                .Append("\">")
                .Append(link.Visible ? link.Text : "<span style=\"color:#d0d0d0\">" + link.Text + "</span>")
                .Append("<span class=\"micro\">(");

                if (string.IsNullOrEmpty(link.Bind))
                {
                    if (link.Uri == "")
                    {
                        sb.Append("<span style=\"color:red\">未设置</span>");
                    }
                    else
                    {
                        sb.Append(link.Uri);
                    }
                }
                else
                {
                    var binds = (link.Bind ?? "").Split(':');
                    if (binds.Length != 2 || binds[1] == string.Empty)
                    {
                        binds = null;
                    }
                    else
                    {
                        if (binds[0] == "category")
                        {
                            cate      = ServiceCall.Instance.SiteService.GetCategory(SiteId, int.Parse(binds[1]));
                            bindTitle = cate.ID > 0 ? string.Format("绑定栏目:{0}", cate.Name) : null;
                        }
                        else if (binds[0] == "archive")
                        {
                            int archiveId;
                            int.TryParse(binds[1], out archiveId);

                            archive = ServiceCall.Instance.ArchiveService
                                      .GetArchiveById(SiteId, archiveId);

                            if (archive.Id <= 0)
                            {
                                binds = null;
                            }
                            else
                            {
                                bindTitle = string.Format("绑定文档:{0}", archive.Title);
                            }
                        }
                    }

                    sb.Append(bindTitle);
                }

                sb.Append(")</span></td>")
                .Append("</tr>");

                return("");
            };

            #endregion

            IList <SiteLinkDto> links2;
            for (var j = 0; j < links.Count; j++)
            {
                if (links[j].Pid == 0)
                {
                    bh(links[j]);

                    //设置子类
                    links2 = new List <SiteLinkDto>(links.Where(a => a.Pid == links[j].Id));
                    for (var k = 0; k < links2.Count; k++)
                    {
                        bh(links2[k]);
                    }
                    //links.Remove(links2[k]);
                }
            }


            linkRowsHtml = sb.Length != 0
                ? string.Concat("<table cellspacing=\"0\" class=\"ui-table\">", sb.ToString(), "</table>")
                : "<div style=\"text-align:center\">暂无链接,请点击右键添加!</div>";

            //输出分页数据
            PagerJson2("<div style=\"display:none\">for ie6</div>" + linkRowsHtml,
                       string.Format("共{0}条", i.ToString()));
        }
Esempio n. 16
0
 public void addIncomingLink(LinkBehavior lb)
 {
     incomingConnectionLinks.Add(lb);
 }
Esempio n. 17
0
		public LinkLabel ()
		{
			LinkArea = new LinkArea (0, -1);
			link_behavior = LinkBehavior.SystemDefault;
			link_visited = false;
			pieces = null;
			focused_index = -1;

			string_format.FormatFlags |= StringFormatFlags.NoClip;
			
			ActiveLinkColor = Color.Red;
			DisabledLinkColor = ThemeEngine.Current.ColorGrayText;
			LinkColor = Color.FromArgb (255, 0, 0, 255);
			VisitedLinkColor = Color.FromArgb (255, 128, 0, 128);
			SetStyle (ControlStyles.Selectable, false);
			SetStyle (ControlStyles.ResizeRedraw | 
				ControlStyles.UserPaint | 
				ControlStyles.AllPaintingInWmPaint |
				ControlStyles.SupportsTransparentBackColor | 
				ControlStyles.Opaque |
				ControlStyles.OptimizedDoubleBuffer
				, true);
			CreateLinkPieces ();
		}
Esempio n. 18
0
    /**
     * Generate a world using the given .JSON file in 'levelDescriptionJson'
     */
    public void CreateWorldFromLevelDescription()
    {
        LevelEntitiesJSON level = JsonUtility.FromJson <LevelEntitiesJSON>(levelDescriptionJsonFiles[levelFileIndex].text);

        gameController.winCondition = GetWinConditionFromString(level.winCondition);
        // list of link blocks we are creating
        levelLinks = new List <LinkBehavior>();
        Debug.Log("Loading blocks");
        // while generating the level, add things to levelEntities list so it can be destroyed for the next level generated.
        for (int i = 0; i < level.blocks.Length; i++)
        {
            Vector2 blockPos = new Vector2((float)(level.blocks[i].x + (level.blocks[i].width / 2f)),
                                           (float)(level.blocks[i].y - (level.blocks[i].height / 2f)));
            Transform objToInstances = GetAssocInstanceFromType(level.blocks[i].type);
            if (objToInstances != null)
            {
                if (objToInstances == groundPreFab && level.blocks[i].height == 1)
                {
                    objToInstances = groundTopPreFab; // render it with details on top of the block.
                }
                Transform obj         = Instantiate(objToInstances, blockPos, Quaternion.identity);
                Vector2   sizeOfBlock = new Vector3((int)level.blocks[i].width, (int)level.blocks[i].height);
                obj.GetComponent <SpriteRenderer>().size = sizeOfBlock;
                obj.GetComponent <BoxCollider2D>().size  = sizeOfBlock;
                obj.GetComponent <LoggableBehavior>().setLogID(level.blocks[i].logId); // ground block
                levelEntities.Add(obj);
            }
        }
        Debug.Log("Loading player");
        // create the player
        if (level.player != null)
        {
            Vector2 loc = new Vector2((float)(level.player.x + (1 / 2f)), (float)(level.player.y - (1 / 2f)));
            gameController.playerRef = Instantiate(playerPreFab, loc, Quaternion.identity);
            gameController.playerRef.GetComponent <PlayerBehavior>().gameController = gameController;
            gameController.playerRef.GetComponent <LoggableBehavior>().setLogID(level.player.logId);
            levelEntities.Add(gameController.playerRef);
            // move the backdrop right behind the player initially.
            backgroundRef.position = gameController.playerRef.position + new Vector3(0, 0, -10);
        }
        Debug.Log("Loading goal");
        if (level.goalPortal != null)
        {
            Vector2   loc  = new Vector2((float)(level.goalPortal.x + (1 / 2f)), (float)(level.goalPortal.y - (1 / 2f)));
            Transform goal = Instantiate(goalPortalPreFab, loc, Quaternion.identity);
            goal.GetComponent <LoggableBehavior>().setLogID(level.goalPortal.logId);
            levelEntities.Add(goal);
        }
        Debug.Log("Loading helicopter robot");
        if (level.helicopterRobot != null)
        {
            Vector2   loc   = new Vector2((float)(level.helicopterRobot.x + (1 / 2f)), (float)(level.helicopterRobot.y - (1 / 2f)));
            Transform robot = Instantiate(helicopterRobotPreFab, loc, Quaternion.identity);
            HelicopterRobotBehavior robotBehavior = robot.GetComponent <HelicopterRobotBehavior>();
            robotBehavior.gameController = gameController;
            robotBehavior.targetLocation = robot.position;
            robotBehavior.GetComponent <LoggableBehavior>().setLogID(level.helicopterRobot.logId);

            gameController.helicopterRobotRef = robot;
            robotBehavior.GetComponent <ContainerEntityBehavior>().refreshChildList();
            robotBehavior.getChildLink().GetComponent <LoggableBehavior>().setLogID("helicopter");
            robotBehavior.getChildLink().type = LinkBehavior.Type.HELICOPTER;
            robotBehavior.getChildLink().setVariableName("temp");
            robotBehavior.getChildLink().setContainerEntity(robot.GetComponent <ContainerEntityBehavior>());
            levelEntities.Add(robot);
            levelLinks.Add(robotBehavior.GetComponent <ContainerEntityBehavior>().GetChildComponent <LinkBehavior>());
        }

        // corresponding list of IDs telling the link blocks what they should point to when the level is generated
        List <string>                 levelLinksConnIds     = new List <string>();
        List <LinkBehavior>           levelLinkComps        = new List <LinkBehavior>();
        List <ObjectiveBlockBehavior> levelObjectiveBlocks  = new List <ObjectiveBlockBehavior>();
        List <PlatformBehavior>       levelPlatformEntities = new List <PlatformBehavior>();

        gameController.platformsToAdd = new List <PlatformBehavior>();
        // create the start link
        Debug.Log("Loading start link");
        if (level.startLink != null)
        {
            Vector2      loc               = new Vector2((float)(level.startLink.x + (1 / 2f)), (float)(level.startLink.y - (1 / 2f)));
            Transform    startLinkTran     = Instantiate(linkBlockPreFab, loc, Quaternion.identity);
            LinkBehavior startLinkBehavior = startLinkTran.GetComponent <LinkBehavior>();
            startLinkTran.position          = startLinkTran.position + (new Vector3(0, 0, -5));
            startLinkBehavior.type          = LinkBehavior.Type.START;
            startLinkBehavior.defaultSprite = startLinkBlockSprite;
            startLinkBehavior.nullSprite    = nullStartLinkBlockSprite;
            startLinkBehavior.GetComponent <LoggableBehavior>().setLogID(level.startLink.logId);

            startLinkBehavior.GetComponent <SpriteRenderer>().sprite = startLinkBlockSprite;
            gameController.startingLink = startLinkBehavior; // set start link reference
            levelLinks.Add(startLinkBehavior);
            levelEntities.Add(startLinkTran);

            levelLinksConnIds.Add(level.startLink.objIDConnectingTo);
            levelLinkComps.Add(startLinkBehavior);
        }

        Debug.Log("Loading external link blocks");
        // create the indiv link blocks.
        for (int i = 0; i < level.linkBlocks.Length; i++)
        {
            Vector2   loc     = new Vector2((float)(level.linkBlocks[i].x + (1 / 2f)), (float)(level.linkBlocks[i].y - (1 / 2f)));
            Transform newLink = Instantiate(linkBlockPreFab, loc, Quaternion.identity);
            newLink.position = newLink.position + (new Vector3(0, 0, -5));
            LinkBehavior lb = newLink.GetComponent <LinkBehavior>();
            lb.GetComponent <LoggableBehavior>().setLogID(level.linkBlocks[i].logId);
            levelLinks.Add(lb);
            levelEntities.Add(newLink);

            levelLinksConnIds.Add(level.linkBlocks[i].objIDConnectingTo);
            levelLinkComps.Add(lb);
        }

        Debug.Log("Loading objective blocks");
        // create the objective blocks (fire)
        for (int i = 0; i < level.objectiveBlocks.Length; i++)
        {
            Vector2   loc       = new Vector2((float)(level.objectiveBlocks[i].x + (1 / 2f)), (float)(level.objectiveBlocks[i].y - (1 / 2f)));
            Transform newOBlock = Instantiate(objectiveBlockPreFab, loc, Quaternion.identity);
            newOBlock.GetComponent <LoggableBehavior>().setLogID(level.objectiveBlocks[i].logId);
            levelObjectiveBlocks.Add(newOBlock.GetComponent <ObjectiveBlockBehavior>());
            levelEntities.Add(newOBlock);
        }

        Debug.Log("Loading instruction blocks");
        // create the instruction blocks (question marks)
        for (int i = 0; i < level.instructionBlocks.Length; i++)
        {
            Vector2   loc = new Vector2((float)(level.instructionBlocks[i].x + (1 / 2f)), (float)(level.instructionBlocks[i].y - 1));
            Transform newInstructBlock = Instantiate(instructionViewBlockPreFab, loc, Quaternion.identity);
            newInstructBlock.GetComponent <InstructionViewBlockBehavior>().screenId = level.instructionBlocks[i].screenId;
            levelEntities.Add(newInstructBlock);
        }

        Debug.Log("Loading the platforms");
        // create the platforms.
        Dictionary <string, PlatformBehavior> listPlatformMap = new Dictionary <string, PlatformBehavior>();

        for (int i = 0; i < level.singleLinkedListPlatforms.Length; i++)
        {
            Vector2          loc           = new Vector2((float)(level.singleLinkedListPlatforms[i].x + (3 / 2f)), (float)(level.singleLinkedListPlatforms[i].y - (1 / 2f)));
            Transform        newLLPlatform = Instantiate(singleLinkedListPreFab, loc, Quaternion.identity);
            PlatformBehavior newPlat       = newLLPlatform.GetComponent <PlatformBehavior>();
            newPlat.GetComponent <ConnectableEntityBehavior>().incomingConnectionLinks = new List <LinkBehavior>();
            newPlat.gameController = gameController;

            newPlat.GetComponent <ContainerEntityBehavior>().refreshChildList();
            newPlat.setValue(level.singleLinkedListPlatforms[i].value);
            newPlat.GetComponent <LoggableBehavior>().setLogID(level.singleLinkedListPlatforms[i].logId);
            newPlat.GetComponent <ConnectableEntityBehavior>().incomingConnectionLinks = new List <LinkBehavior>();
            listPlatformMap.Add(level.singleLinkedListPlatforms[i].objId, newPlat);
            newPlat.getChildLink().state = LinkBehavior.State.NORMAL;
            newPlat.getChildLink().GetComponent <LoggableBehavior>().setLogID("child" + level.singleLinkedListPlatforms[i].logId);
            newPlat.getChildLink().setContainerEntity(newPlat.GetComponent <ContainerEntityBehavior>());
            levelLinks.Add(newPlat.GetComponent <ContainerEntityBehavior>().GetChildComponent <LinkBehavior>()); // add it to the list of blocks for references
            levelEntities.Add(newLLPlatform);

            levelLinksConnIds.Add(level.singleLinkedListPlatforms[i].childLinkBlockConnectId);
            levelLinkComps.Add(newPlat.getChildLink());
            levelPlatformEntities.Add(newPlat);

            newPlat.isInLevel = !level.singleLinkedListPlatforms[i].toAdd;
            if (level.singleLinkedListPlatforms[i].toAdd == true)
            {
                newLLPlatform.gameObject.SetActive(false);
                gameController.platformsToAdd.Add(newPlat);
            }
        }
        gameController.hudBehavior.setPlatformsToAddText(gameController.platformsToAdd.Count);
        Debug.Log("Completed loading " + listPlatformMap.Count + " platforms");

        Debug.Log("Establishing links ");
        // establishing links for the link blocks with the platforms
        for (int i = 0; i < levelLinksConnIds.Count; i++)
        {
            if (levelLinksConnIds[i] != null && levelLinksConnIds[i].Length > 0) // if this link has a connection.
            {
                string platformId = levelLinksConnIds[i];
                if (listPlatformMap[platformId].isInLevel == true)
                {
                    // establish the connection
                    levelLinkComps[i].ensureReferences();
                    levelLinkComps[i].setConnectionTo(listPlatformMap[platformId].GetComponent <ConnectableEntityBehavior>());
                }
            }
        }

        Debug.Log("Assigning variable names");
        string[] varNames = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "m", "n", "p", "q", "r", "z", "y" };
        int      varIndex = 0;

        // verify that no link blocks are being displayed
        foreach (LinkBehavior lb in levelLinks)
        {
            if (lb.type == LinkBehavior.Type.HELICOPTER)
            {
                lb.setVariableName("temp");
            }
            else if (lb.type == LinkBehavior.Type.START)
            {
                lb.setVariableName("list.head");
            }
            else
            {
                lb.setVariableName(varNames[varIndex++]);
            }
            lb.ensureReferences();
            lb.UpdateRendering();
        }

        Debug.Log("Updating everything");
        // update the win conditions for the objective blocks
        gameController.setLevelObjectiveBlocksList(levelObjectiveBlocks);
        gameController.setLevelPlatformEntitiesList(levelPlatformEntities);
        gameController.updateObjectiveHUDAndBlocks();
        gameController.updatePlatformEntities();
        gameController.codePanelBehavior.clearCodeText();
        gameController.hudBehavior.setLevelOnText(levelFileIndex + 1);
        gameController.hudBehavior.setPlatformsToAddText(gameController.platformsToAdd.Count);
        Debug.Log("Done loading world");
    }
        public static void EnsureLinkFonts(Font baseFont, LinkBehavior link, ref Font linkFont, ref Font hoverLinkFont) {
            if (linkFont != null && hoverLinkFont != null) {
                return;
            }

            bool underlineLink = true;
            bool underlineHover = true;

            if (link == LinkBehavior.SystemDefault) {
                link = GetIELinkBehavior();
            }

            switch (link) {
                case LinkBehavior.AlwaysUnderline:
                    underlineLink = true;
                    underlineHover = true;
                    break;
                case LinkBehavior.HoverUnderline:
                    underlineLink = false;
                    underlineHover = true;
                    break;
                case LinkBehavior.NeverUnderline:
                    underlineLink = false;
                    underlineHover = false;
                    break;
            }

            Font f = baseFont;

            // We optimize for the "same" value (never & always) to avoid creating an
            // extra font object.
            //
            if (underlineHover == underlineLink) {
                FontStyle style = f.Style;
                if (underlineHover) {
                    style |= FontStyle.Underline;
                }
                else {
                    style &= ~FontStyle.Underline;
                }
                hoverLinkFont = new Font(f, style);
                linkFont = hoverLinkFont;
            }
            else {
                FontStyle hoverStyle = f.Style;
                if (underlineHover) {
                    hoverStyle |= FontStyle.Underline;
                }
                else {
                    hoverStyle &= ~FontStyle.Underline;
                }

                hoverLinkFont = new Font(f, hoverStyle);

                FontStyle linkStyle = f.Style;
                if (underlineLink) {
                    linkStyle |= FontStyle.Underline;
                }
                else {
                    linkStyle &= ~FontStyle.Underline;
                }

                linkFont = new Font(f, linkStyle);
            }
        }
		public ToolStripLabel (string text, Image image, bool isLink, EventHandler onClick, string name)
			: base (text, image, onClick, name)
		{
			this.active_link_color = Color.Red;
			this.is_link = isLink;
			this.link_behavior = LinkBehavior.SystemDefault;
			this.link_color = Color.FromArgb (0, 0, 255);
			this.link_visited = false;
			this.visited_link_color = Color.FromArgb (128, 0, 128);
		}
Esempio n. 21
0
        public static LinkLabel AddLink(this Control Control, string Text, Font Font, Point Location, Color LinkColor, LinkBehavior LinkBehavior)
        {
            LinkLabel Link = new LinkLabel();

            Link.Text         = Text;
            Link.AutoSize     = true;
            Link.Font         = Font;
            Link.LinkColor    = LinkColor;
            Link.BackColor    = Color.Transparent;
            Link.LinkBehavior = LinkBehavior;
            Control.Controls.Add(Link);
            if (Location.Y == -1000)
            {
                Link.Location = new Point(Location.X, Link.MidH());
            }
            else if (Location.X == -1000)
            {
                Link.Location = new Point(Link.MidW(), Location.Y);
            }
            else
            {
                Link.Location = Location;
            }
            Link.Refresh();

            return(Link);
        }
Esempio n. 22
0
        public static void EnsureLinkFonts(Font baseFont, LinkBehavior link, ref Font linkFont, ref Font hoverLinkFont)
        {
            if ((linkFont == null) || (hoverLinkFont == null))
            {
                bool flag  = true;
                bool flag2 = true;
                if (link == LinkBehavior.SystemDefault)
                {
                    link = GetIELinkBehavior();
                }
                switch (link)
                {
                case LinkBehavior.AlwaysUnderline:
                    flag  = true;
                    flag2 = true;
                    break;

                case LinkBehavior.HoverUnderline:
                    flag  = false;
                    flag2 = true;
                    break;

                case LinkBehavior.NeverUnderline:
                    flag  = false;
                    flag2 = false;
                    break;
                }
                Font prototype = baseFont;
                if (flag2 == flag)
                {
                    FontStyle newStyle = prototype.Style;
                    if (flag2)
                    {
                        newStyle |= FontStyle.Underline;
                    }
                    else
                    {
                        newStyle &= ~FontStyle.Underline;
                    }
                    hoverLinkFont = new Font(prototype, newStyle);
                    linkFont      = hoverLinkFont;
                }
                else
                {
                    FontStyle style = prototype.Style;
                    if (flag2)
                    {
                        style |= FontStyle.Underline;
                    }
                    else
                    {
                        style &= ~FontStyle.Underline;
                    }
                    hoverLinkFont = new Font(prototype, style);
                    FontStyle style3 = prototype.Style;
                    if (flag)
                    {
                        style3 |= FontStyle.Underline;
                    }
                    else
                    {
                        style3 &= ~FontStyle.Underline;
                    }
                    linkFont = new Font(prototype, style3);
                }
            }
        }
    void Update()
    {
        debugFrameCount++;

        // don't process the game if the world is still being instantiated.
        if (worldGenerator.isBusy())
        {
            return;
        }

        if (playerRef != null)
        {
            // always set the camera on top of the player.
            cameraRef.transform.position = new Vector3(playerRef.position.x, playerRef.position.y, transform.position.z - 50);
        }

        // if you are adding a platform...
        // cancels when you click on nothing or when you right click.

        Vector3 mousePointInWorld = Camera.main.ScreenToWorldPoint(Input.mousePosition);

        mousePointInWorld.z = 0;
        // add platform system
        if (addingPlatforms && platformsToAdd.Count > 0)
        {
            PlatformBehavior platformToPreviewForAdd = platformsToAdd[0];  // show a preview of the platform.
            platformToPreviewForAdd.GetComponent <ContainerEntityBehavior>().refreshChildList();
            platformToPreviewForAdd.renderAsFadedPreview();
            platformToPreviewForAdd.setValueBlockText("" + platformToPreviewForAdd.getValue());
            platformToPreviewForAdd.transform.position = mousePointInWorld;
            platformToPreviewForAdd.gameObject.SetActive(true);
            platformToPreviewForAdd.GetComponent <BoxCollider2D>().isTrigger = true;

            if ((Input.GetMouseButtonDown(1) || Input.GetKeyDown(KeyCode.Escape)) && hoverLink == null) // deselecting with right click?
            {
                addingPlatforms = false;
                platformToPreviewForAdd.gameObject.SetActive(false);
                if (selectedLink != null)  // deselect on canceling placement.
                {
                    selectedLink.setPreviewConnection(null);
                    selectedLink.setState(LinkBehavior.State.NORMAL);
                    selectedLink = null;
                }
            }
            else if (selectedLink != null && Input.GetMouseButton(0)) // dragging from a link.
            {
                selectedLink.setPreviewConnection(platformToPreviewForAdd.GetComponent <ConnectableEntityBehavior>());
                selectedLink.UpdateRendering();
            }
            else if (selectedLink != null && Input.GetMouseButtonUp(0)) // release to finish adding platform,
            {
                platformsToAdd.Remove(platformToPreviewForAdd);
                platformToPreviewForAdd.transform.position = mousePointInWorld;
                platformToPreviewForAdd.gameObject.SetActive(true);
                platformToPreviewForAdd.GetComponent <BoxCollider2D>().isTrigger = false;
                platformToPreviewForAdd.isInLevel = true;                                                         // set as being added to the level.
                platformToPreviewForAdd.GetComponent <ContainerEntityBehavior>().refreshChildList();
                selectedLink.setConnectionTo(platformToPreviewForAdd.GetComponent <ConnectableEntityBehavior>()); // connect the selected link to the new platform
                platformToPreviewForAdd.updateRenderAndState();                                                   // force rendering update.
                addingPlatforms = false;
                codePanelBehavior.appendCodeText(selectedLink.getVariableName() + " = new Node();");              // append code to the generated code window.

                string actMsg = "Platform is added from link " + selectedLink.GetComponent <LoggableBehavior>().getLogID() + " at (" + mousePointInWorld.x + ", " + mousePointInWorld.y + ")";
                loggingManager.sendLogToServer(actMsg);

                selectedLink.setPreviewConnection(null);
                selectedLink.setState(LinkBehavior.State.NORMAL);
                selectedLink = null;                                     // deselect.

                hudBehavior.setPlatformsToAddText(platformsToAdd.Count); // update UI
                updateObjectiveHUDAndBlocks();
                updatePlatformEntities();
            }
        } // end addingPlatforms block


        if (!Input.GetMouseButtonDown(0) && !Input.GetMouseButtonDown(0)) // the state of clicking has not changed this frame.
        {
            hoverLink = null;                                             // to make sure it is properly updated this next frame.
        }
        // if it is a hover link and the mouse is released, then check to establish a connection.
        mousePointInWorld.z = 0;
        for (int i = 0; i < worldGenerator.levelLinks.Count; i++)
        {
            LinkBehavior lb = worldGenerator.levelLinks[i];
            if (lb.selectable)
            {
                if (lb.isPointInside(mousePointInWorld))
                {
                    if (lb.state == LinkBehavior.State.NORMAL)
                    {
                        hoverLink = lb;
                        lb.setState(LinkBehavior.State.HOVER);
                        if (selectedLink != null && hoverLink.connectableEntity != null)
                        {
                            selectedLink.setPreviewConnection(hoverLink.connectableEntity); // preview the connection if there is a select link.
                            selectedLink.UpdateRendering();
                        }
                    }

                    if (Input.GetMouseButtonDown(0)) // if the link is just being clicked.
                    {
                        if (lb.state == LinkBehavior.State.SELECTED)
                        {
                            // if the link being clicked is selected
                            if (getMsSinceLastClick() < doubleClickDelay)
                            {
                                lb.setConnectionTo(null); // remove connection on double click
                                lb.setPreviewConnection(null);
                                lb.UpdateRendering();
                                codePanelBehavior.appendCodeText(lb.getVariableName() + " = null;");
                                updatePlatformEntities(); // changing links - update platforms
                                updateObjectiveHUDAndBlocks();
                            }
                        }
                        else // clicking on a link that is NOT selected
                        {
                            selectedLink = lb;
                            lb.setState(LinkBehavior.State.SELECTED);
                            if (hoverLink == selectedLink)
                            {
                                hoverLink.setPreviewConnection(null);
                                hoverLink.UpdateRendering();
                                hoverLink = null; // hover link can't be the same as selected link.
                            }
                        }
                    }
                    else if (Input.GetMouseButtonUp(0))                                                         // if the mouse is being released over this link
                    {
                        if (lb.state == LinkBehavior.State.HOVER && selectedLink != null && selectedLink != lb) // if there IS a selected link. establish link.
                        {
                            selectedLink.setConnectionEqualTo(ref lb);
                            codePanelBehavior.appendCodeText(selectedLink.getVariableName() + " = " + lb.getVariableName() + ";");
                            selectedLink.setPreviewConnection(null);
                            selectedLink.setState(LinkBehavior.State.NORMAL);
                            lb.UpdateRendering();
                            updatePlatformEntities(); // changing links - update platforms
                            updateObjectiveHUDAndBlocks();
                        }
                    }
                }
                else
                { // mouse is NOT over link block
                    if (lb.state == LinkBehavior.State.HOVER)
                    {
                        lb.setState(LinkBehavior.State.NORMAL); // no longer a hover block.
                    }
                    else if (lb.state == LinkBehavior.State.SELECTED && !Input.GetMouseButton(0))
                    {
                        lb.setState(LinkBehavior.State.NORMAL); // no longer the selected block
                        lb.setPreviewConnection(null);          // no preview
                        lb.UpdateRendering();
                    }
                }
            }
            else
            {
                if (lb.state != LinkBehavior.State.NORMAL)
                {
                    lb.setState(LinkBehavior.State.NORMAL);
                }
            }
        } // end iterating through links.

        // validate the selected link
        if (selectedLink != null && selectedLink.state != LinkBehavior.State.SELECTED)
        {
            selectedLink = null;
        }
        // validate the hover link
        if (hoverLink != null && hoverLink.state != LinkBehavior.State.HOVER)
        {
            hoverLink = null;
        }


        // record the last time that the mouse clicked for double clicking
        if (Input.GetMouseButton(0))
        {
            lastTimeClickedMillis = System.DateTime.Now;
        }
    }
Esempio n. 24
0
    public List <LinkBehavior> incomingConnectionLinks; // the link block that connects to this platform, or null if not being connected to.

    public void removeIncomingLink(LinkBehavior lb)
    {
        incomingConnectionLinks.Remove(lb);
    }
Esempio n. 25
0
        public static void EnsureLinkFonts(Font baseFont, LinkBehavior link, ref Font linkFont, ref Font hoverLinkFont)
        {
            if (linkFont != null && hoverLinkFont != null)
            {
                return;
            }

            bool underlineLink  = true;
            bool underlineHover = true;

            if (link == LinkBehavior.SystemDefault)
            {
                link = GetIELinkBehavior();
            }

            switch (link)
            {
            case LinkBehavior.AlwaysUnderline:
                underlineLink  = true;
                underlineHover = true;
                break;

            case LinkBehavior.HoverUnderline:
                underlineLink  = false;
                underlineHover = true;
                break;

            case LinkBehavior.NeverUnderline:
                underlineLink  = false;
                underlineHover = false;
                break;
            }

            Font f = baseFont;

            // We optimize for the "same" value (never & always) to avoid creating an
            // extra font object.
            //
            if (underlineHover == underlineLink)
            {
                FontStyle style = f.Style;
                if (underlineHover)
                {
                    style |= FontStyle.Underline;
                }
                else
                {
                    style &= ~FontStyle.Underline;
                }
                hoverLinkFont = new Font(f, style);
                linkFont      = hoverLinkFont;
            }
            else
            {
                FontStyle hoverStyle = f.Style;
                if (underlineHover)
                {
                    hoverStyle |= FontStyle.Underline;
                }
                else
                {
                    hoverStyle &= ~FontStyle.Underline;
                }

                hoverLinkFont = new Font(f, hoverStyle);

                FontStyle linkStyle = f.Style;
                if (underlineLink)
                {
                    linkStyle |= FontStyle.Underline;
                }
                else
                {
                    linkStyle &= ~FontStyle.Underline;
                }

                linkFont = new Font(f, linkStyle);
            }
        }
Esempio n. 26
0
File: LinkC.cs Progetto: jooper/cms
        /// <summary>
        /// 数据
        /// </summary>
        public void Data_GET()
        {
            SiteLinkType type = (SiteLinkType)Enum.Parse(typeof(SiteLinkType), HttpContext.Current.Request["type"], true);

            string linkRowsHtml;
            //链接列表
            StringBuilder sb = new StringBuilder();
            int           i  = 0;

            string      bindTitle = String.Empty;
            ArchiveDto  archive   = default(ArchiveDto);
            CategoryDto cate      = default(CategoryDto);

            IList <SiteLinkDto> links = new List <SiteLinkDto>(
                ServiceCall.Instance.SiteService.GetLinksByType(this.SiteId, type, true));


            #region 链接拼凑

            LinkBehavior bh = (link) =>
            {
                sb.Append("<tr visible=\"").Append(link.Visible ? "1" : "0").Append("\" indent=\"").Append(link.Id.ToString())
                .Append("\"><td class=\"hidden\">").Append(link.Id.ToString()).Append("</td>")
                .Append("<td align=\"center\">").Append((++i).ToString()).Append("</td><td><b>")
                .Append(link.Pid != 0 ? "&nbsp;&nbsp;" : "")
                .Append(link.Visible ? link.Text : "<span style=\"color:#d0d0d0\">" + link.Text + "</span>")
                .Append("</b>&nbsp;<span class=\"micro\">(");

                if (String.IsNullOrEmpty(link.Bind))
                {
                    sb.Append(link.Uri);
                }
                else
                {
                    string[] binds = (link.Bind ?? "").Split(':');
                    if (binds.Length != 2 || binds[1] == String.Empty)
                    {
                        binds = null;
                    }
                    else
                    {
                        if (binds[0] == "category")
                        {
                            cate      = ServiceCall.Instance.SiteService.GetCategory(this.SiteId, int.Parse(binds[1]));
                            bindTitle = cate.Id > 0 ?
                                        String.Format("绑定栏目:{0}", cate.Name) :
                                        null;
                        }
                        else if (binds[0] == "archive")
                        {
                            int archiveId;
                            int.TryParse(binds[1], out archiveId);

                            archive = ServiceCall.Instance.ArchiveService
                                      .GetArchiveById(this.SiteId, archiveId);

                            if (archive.Id <= 0)
                            {
                                binds = null;
                            }
                            else
                            {
                                bindTitle = String.Format("绑定文档:{0}", archive.Title);
                            }
                        }
                    }

                    sb.Append(bindTitle);
                }

                sb.Append(")</span></td><td class=\"center\">").Append(link.OrderIndex.ToString()).Append("</td>")
                .Append("</tr>");

                return("");
            };


            #endregion

            IList <SiteLinkDto> links2;
            for (int j = 0; j < links.Count; j++)
            {
                if (links[j].Pid == 0)
                {
                    bh(links[j]);

                    //设置子类
                    links2 = new List <SiteLinkDto>(links.Where(a => a.Pid == links[j].Id));
                    for (int k = 0; k < links2.Count; k++)
                    {
                        bh(links2[k]);
                        //links.Remove(links2[k]);
                    }
                }
            }



            linkRowsHtml = sb.Length != 0 ?
                           String.Concat("<table cellspacing=\"0\" class=\"ui-table\">", sb.ToString(), "</table>") :
                           "<div style=\"text-align:center\">暂无链接,请点击右键添加!</div>";

            //输出分页数据
            base.PagerJson2("<div style=\"display:none\">for ie6</div>" + linkRowsHtml, String.Format("共{0}条", i.ToString()));
        }
Esempio n. 27
0
        public override void ResolveCollision(EnemyCollisionResponse other)
        {
            LinkBehavior linkBehavior = entity.GetComponent <LinkBehavior>();

            // Trigger drag away and reset animation if WallMaster got him
            if (!Game1.inBossRush && other.entity.GetType() == typeof(WallMaster))
            {
                if (entity.GetComponent <DragAndReset>() == null)
                {
                    LevelManager.link.AddComponent(new DragAndReset(other.entity));
                }
                return;
            }

            // Change to Hurt Sprite (enables and disables immunity inside)
            if (!entity.GetComponent <LinkHealthManagement>().immune)
            {
                // Take Damage
                Console.WriteLine("Link is hurt");
                entity.GetComponent <LinkHealthManagement>().Damage(other.damage);

                // Push back
                Vector2 linkPos  = entity.GetComponent <Transform>().position;
                Vector2 enemyPos = other.entity.GetComponent <Transform>().position;
                Vector2 diff     = linkPos - enemyPos;
                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 LinkKnockback(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 LinkKnockback(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 LinkKnockback(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 LinkKnockback(Constants.Direction.RIGHT, distance, frames));
                    // Console.WriteLine("Enemy is left from link!");
                }

                // Debug; If this ever gets output, something is wrong.
                else
                {
                    Console.WriteLine("Enemy was unrecognized direction!");
                }
            }
        }
Esempio n. 28
0
 /**
  * Set the preview connection of this link equal to the given link block
  */
 public void setPreviewConnectionEqualTo(ref LinkBehavior lb)
 {
     setPreviewConnection(lb.connectableEntity);
 }
        public static void EnsureLinkFonts(Font baseFont, LinkBehavior link, ref Font linkFont, ref Font hoverLinkFont)
        {
            if ((linkFont == null) || (hoverLinkFont == null))
            {
                bool flag = true;
                bool flag2 = true;
                if (link == LinkBehavior.SystemDefault)
                {
                    link = GetIELinkBehavior();
                }
                switch (link)
                {
                    case LinkBehavior.AlwaysUnderline:
                        flag = true;
                        flag2 = true;
                        break;

                    case LinkBehavior.HoverUnderline:
                        flag = false;
                        flag2 = true;
                        break;

                    case LinkBehavior.NeverUnderline:
                        flag = false;
                        flag2 = false;
                        break;
                }
                Font prototype = baseFont;
                if (flag2 == flag)
                {
                    FontStyle newStyle = prototype.Style;
                    if (flag2)
                    {
                        newStyle |= FontStyle.Underline;
                    }
                    else
                    {
                        newStyle &= ~FontStyle.Underline;
                    }
                    hoverLinkFont = new Font(prototype, newStyle);
                    linkFont = hoverLinkFont;
                }
                else
                {
                    FontStyle style = prototype.Style;
                    if (flag2)
                    {
                        style |= FontStyle.Underline;
                    }
                    else
                    {
                        style &= ~FontStyle.Underline;
                    }
                    hoverLinkFont = new Font(prototype, style);
                    FontStyle style3 = prototype.Style;
                    if (flag)
                    {
                        style3 |= FontStyle.Underline;
                    }
                    else
                    {
                        style3 &= ~FontStyle.Underline;
                    }
                    linkFont = new Font(prototype, style3);
                }
            }
        }