当前位置: 首页>>代码示例>>C#>>正文


C# Level.fixLimits方法代码示例

本文整理汇总了C#中Level.fixLimits方法的典型用法代码示例。如果您正苦于以下问题:C# Level.fixLimits方法的具体用法?C# Level.fixLimits怎么用?C# Level.fixLimits使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Level的用法示例。


在下文中一共展示了Level.fixLimits方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: remoteCall

 protected IEnumerator remoteCall()
 {
     changinglevels = true;
     WWW content = new WWW(@"http://wiki-412.appspot.com/json/alpha2.json");
         while(!content.isDone)
         {
             Debug.Log("fetching");
             yield return null;
         }
         string hold = content.text;
         currentlevel = JsonMapper.ToObject<Level>(hold);
     currentlevel.fixLimits();
     currentlevel.constructMatrix(3);
     generateLevel();
     changinglevels = false;
 }
开发者ID:ARudiuk,项目名称:Catherine_Theme,代码行数:16,代码来源:levelmanager_base.cs

示例2: mapLevel

    //breadth first mapping of level, that goes one extra block out. Naive implementation. Need to get character away from cubes to work
    public Level mapLevel(string name)
    {
        //Create array of directions to check for mapping
        Vector3[] directions = new Vector3[6]; //declare array to go through, maybe find more elegant way
        directions[0] = Vector3.right;
        directions[1] = Vector3.left;
        directions[2] = Vector3.up;
        directions[3] = Vector3.down;
        directions[4] = Vector3.forward;
        directions[5] = Vector3.back;

        List<Point> reached = new List<Point>();
        List<Point> toreach = new List<Point>();

        toreach.Add(new Point(GameObject.FindGameObjectWithTag("block").transform.position,true));

        Vector3 position;
        bool occupied;

        Level level = new Level();

        Entity template;
        RaycastHit hitblock;

        while(toreach.Count!=0)
        {
            position = toreach[0].position;
            occupied = toreach[0].occupied;
            template = new Entity(); //new Entity

            for(int i = 0;i<6;i++) //check all 6 sides for blocks and unchecked spaces
            {
                if(Physics.Raycast(position,directions[i],out hitblock,1f))//if object in direction and it hasn't been reached or will be reached, add it to scan que
                {
                    if(hitblock.collider.tag=="block")
                    {
                        Point temp = new Point(position+directions[i],true);
                        if(!reached.Contains(temp)&&!toreach.Contains(temp))
                            toreach.Add(temp);
                    }
                    else if(hitblock.collider.tag=="character")
                    {
                        Entity temp = new Entity();
                        temp.setData(Mathf.RoundToInt(position.x+directions[i].x),Mathf.RoundToInt(position.y+directions[i].y),Mathf.RoundToInt(position.z+directions[i].z),states.character,(int) charactertypes.basic);
                        if(!level.Objects.Contains(temp))
                            level.addObject(temp);
                    }
                }

                else if(!Physics.Raycast(position,directions[i],1f)&&occupied == true)//if no object in front and coming from occupied block, and not in either list, then add
                {
                    Point temp = new Point(position+directions[i],false);
                    if(!reached.Contains(temp)&&!toreach.Contains(temp))
                        toreach.Add(temp);
                }

            }
            //if block then add
            if(occupied==true)
            {
                template.setData(Mathf.RoundToInt(position.x),Mathf.RoundToInt(position.y),Mathf.RoundToInt(position.z),states.block,(int) blocktypes.basic);//add entity for occupied spaces
                level.addObject(template);
            }

            //add to reached points, remove from points to scan
            reached.Add(toreach[0]);
            toreach.Remove(toreach[0]);
        }

        level.name = name;
        level.fixLimits();
        return level;
    }
开发者ID:ARudiuk,项目名称:Catherine_Theme,代码行数:74,代码来源:levelmanager_maplevel.cs

示例3: read

    //Use stream reader and external json library to read in a saved level
    //after loading in make sure to fix limits to the maximums so that padding will be consistent when added
    //then make the matrix of right size, including padding
    protected void read(int padding)
    {
        Debug.Log ("reading level");
        if(!Application.isWebPlayer)
        {
            using(StreamReader file = new StreamReader(Application.dataPath+"/Levels/"+currentlevel.name+".json"))
            {
                string hold = file.ReadToEnd();
                currentlevel = JsonMapper.ToObject<Level>(hold);
            }
        currentlevel.fixLimits();
        currentlevel.constructMatrix(padding);
        generateLevel();
        }

        else if(Application.isWebPlayer)
        {
            StartCoroutine(remoteCall());
        }
    }
开发者ID:ARudiuk,项目名称:Catherine_Theme,代码行数:23,代码来源:levelmanager_base.cs


注:本文中的Level.fixLimits方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。