public void Foo(Pos pos)
        {
            if(pos.ToString() == "First")
            {

            }
        }
예제 #2
0
 public void CreateDome(Player p, byte type, DomeType domeType, ushort radius)
 {
     List<Pos> buffer = new List<Pos>();
     Level level = p.level;
     ushort cx = (ushort)(p.pos[0] / 32), cy = (ushort)(p.pos[1] / 32), cz = (ushort)(p.pos[2] / 32);
     ushort sx = (ushort)(cx - radius - 1), sy = (ushort)(cy - radius - 1), sz = (ushort)(cz - radius - 1), ex = (ushort)(cx + radius + 1), ey = (ushort)(cy + radius + 1), ez = (ushort)(cz + radius + 1);
     if (domeType == DomeType.Hollow)
     {
         for (ushort x = sx; x < ex; x++)
             for (ushort y = sy; y < ey; y++)
                 for (ushort z = sz; z < ez; z++)
                     if (Math.Round(Distance(cx, cy, cz, x, y, z)) == radius)
                         if (level.GetTile(x, y, z) != type)
                         {
                             Pos pos = new Pos(); pos.x = x; pos.y = y; pos.z = z;
                             buffer.Add(pos);
                         }
     }
     else if (domeType == DomeType.Solid)
     {
         for (ushort x = sx; x < ex; x++)
             for (ushort y = sy; y < ey; y++)
                 for (ushort z = sz; z < ez; z++)
                     if (Math.Round(Distance(cx, cy, cz, x, y, z)) <= radius)
                         if (level.GetTile(x, y, z) != type)
                         {
                             Pos pos = new Pos(); pos.x = x; pos.y = y; pos.z = z;
                             buffer.Add(pos);
                         }
     }
     Execute(p, buffer, type);
 }
예제 #3
0
        public void Main(string[] args)
        {
            var input = File.ReadAllText("input.txt").ToCharArray();

            var houses = new List<string>();

            var santaPos = new Pos(0, 0);
            var roboSantaPos = new Pos(0, 0);

            var curPos = santaPos;
            bool isSanta = true;
            foreach (var direction in input)
            {
                curPos = isSanta ? santaPos : roboSantaPos;

                houses.Add(curPos.ToString());
                Move(curPos, direction);
                houses.Add(curPos.ToString());
                isSanta = !isSanta;
            }

            var uniquehouses = houses.Distinct().Count();


        }
예제 #4
0
파일: Map.cs 프로젝트: htaunay/SmartPacman
        public SpaceType getSpaceType( Pos pos )
        {
            if ((pos.x > (width - 1)) || (pos.x < 0) || (pos.y > (height - 1)) || (pos.y < 0))
                return SpaceType.Empty;

            return spaces[pos.x, pos.y];
        }
예제 #5
0
        /// <summary>
        /// Initializes an inner docked control for the specified position.
        /// </summary>
        /// <param name="pos">Dock position.</param>
        protected virtual void SetupChildDock(Pos pos)
        {
            if (m_DockedTabControl == null)
            {
                m_DockedTabControl = new DockedTabControl(this);
                m_DockedTabControl.TabRemoved += OnTabRemoved;
                m_DockedTabControl.TabStripPosition = Pos.Bottom;
                m_DockedTabControl.TitleBarVisible = true;
            }

            Dock = pos;

            Pos sizeDir;
            if (pos == Pos.Right) sizeDir = Pos.Left;
            else if (pos == Pos.Left) sizeDir = Pos.Right;
            else if (pos == Pos.Top) sizeDir = Pos.Bottom;
            else if (pos == Pos.Bottom) sizeDir = Pos.Top;
            else throw new ArgumentException("Invalid dock", "pos");

            if (m_Sizer != null)
                m_Sizer.Dispose();
            m_Sizer = new Resizer(this);
            m_Sizer.Dock = sizeDir;
            m_Sizer.ResizeDir = sizeDir;
            m_Sizer.SetSize(2, 2);
        }
예제 #6
0
 /// <summary> To create a ParsingFrame object.</summary>
 /// <param name="module">the module name.
 /// </param>
 /// <param name="ind">the index of the character within the source. 
 /// </param>
 /// <param name="pos">the position of the character.
 /// </param>
 /// <param name="parser">the parser executed.
 /// </param>
 public ParsingFrame(string module, int ind, Pos pos, Parser parser)
 {
     this.ind = ind;
     this.module = module;
     this.parser = parser;
     this.pos = pos;
 }
예제 #7
0
        void f()
        {
            int[] clients = m.AllPlayers();
            foreach (int p in clients)
            {
                if (p == ghost)
                {
                    continue;
                }
                Pos pos = new Pos();
                pos.x = m.GetPlayerPositionX(p);
                pos.y = m.GetPlayerPositionY(p);
                pos.z = m.GetPlayerPositionZ(p);

                pos.heading = m.GetPlayerHeading(p);
                pos.pitch = m.GetPlayerPitch(p);
                history.Add(pos);
            }
            if (history.Count < 20)
            {
                return;
            }
            Pos p1 = history[0];
            history.RemoveAt(0);
            m.SetPlayerPosition(ghost, p1.x, p1.y, p1.z);
            m.SetPlayerOrientation(ghost, p1.heading, p1.pitch, 0);
        }
예제 #8
0
 /// <summary>
 ///  Opens the menu.
 /// </summary>
 /// <param name="pos">Unused.</param>
 public void Open(Pos pos)
 {
     IsHidden = false;
     BringToFront();
     Point mouse = Input.InputHandler.MousePosition;
     SetPosition(mouse.X, mouse.Y);
 }
예제 #9
0
 public void CreatePyramid(Player p, byte type, PyramidType pyramidType, ushort radius, ushort verticalExpansion)
 {
     List<Pos> buffer = new List<Pos>();
     Level level = p.level;
     ushort cx = (ushort)(p.pos[0] / 32), cy = (ushort)((p.pos[1] / 32) - 1), cz = (ushort)(p.pos[2] / 32);
     ushort sx = (ushort)(cx - radius - 1), sy = cy, sz = (ushort)(cz - radius - 1), ex = (ushort)(cx + radius + 1), ey = (ushort)(cy + (radius * verticalExpansion)), ez = (ushort)(cz + radius + 1);
     Pos pos = new Pos(); pos.x = cx; pos.y = ey; pos.z = cz;
     for (ushort iy = 0; iy < verticalExpansion; iy++)
         for (ushort ix = cx; ix > (ushort)(cx - 2); ix--)
             for (ushort iz = cz; iz > (ushort)(cz - 2); iz--)
                 if (level.GetTile(ix, (ushort)(ey + iy), iz) != type)
                 {
                     pos.x = ix; pos.y = (ushort)(ey + iy); pos.z = iz;
                     buffer.Add(pos);
                 }
     int temp = 0;
     if (pyramidType == PyramidType.Hollow)
     {
         for (ushort y = sy; y < ey; y++)
         {
             for (ushort x = sx; x < ex; x++)
                 for (ushort z = sz; z < ez; z++)
                     if (x == sx || x == (ushort)(ex - 1) || z == sz || z == (ushort)(ez - 1))
                         if (level.GetTile(x, y, z) != type)
                         {
                             pos.x = x; pos.y = y; pos.z = z;
                             buffer.Add(pos);
                         }
             temp++;
             if (temp == verticalExpansion)
             {
                 temp = 0;
                 sx += 1; ex -= 1;
                 sz += 1; ez -= 1;
             }
         }
     }
     else if (pyramidType == PyramidType.Solid)
     {
         for (ushort y = sy; y < ey; y++)
         {
             for (ushort x = sx; x < ex; x++)
                 for (ushort z = sz; z < ez; z++)
                     if (level.GetTile(x, y, z) != type)
                     {
                         pos.x = x; pos.y = y; pos.z = z;
                         buffer.Add(pos);
                     }
             temp++;
             if (temp == verticalExpansion)
             {
                 temp = 0;
                 sx += 1; ex -= 1;
                 sz += 1; ez -= 1;
             }
         }
     }
     Execute(p, buffer, type);
 }
 public Pos GetCharacterPos(Vector2 characterPos)
 {
     Vector2 characterPosWorld = rectangleToWorld (characterPos);
     Pos returnPos = new Pos ();
     returnPos.posX = (int)characterPosWorld.x;
     returnPos.posY = (int)characterPosWorld.y;
     return returnPos;
 }
 public bool CheckTargetInRange(Pos selfPos, Pos targetPos, int rangeGrid)
 {
     if (selfPos.posX - rangeGrid <= targetPos.posX && targetPos.posX <= selfPos.posX + rangeGrid && selfPos.posY - rangeGrid <= targetPos.posY && targetPos.posY <= selfPos.posY + rangeGrid) {
         return true;
     } else {
         return false;
     }
 }
예제 #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Resizer"/> class.
 /// </summary>
 /// <param name="parent">Parent control.</param>
 public Resizer(ZGE.Components.ZComponent parent)
     : base(parent)
 {
     m_ResizeDir = Pos.Left;
     MouseInputEnabled = true;
     SetSize(6, 6);
     Target = parent as GUIControl;
 }
예제 #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Resizer"/> class.
 /// </summary>
 /// <param name="parent">Parent control.</param>
 public Resizer(Controls.Control parent)
     : base(parent)
 {
     m_ResizeDir = Pos.Left;
     MouseInputEnabled = true;
     SetSize(6, 6);
     Target = parent;
 }
        public void Template1(Pos pos)
        {
            if (pos.ToString() == "First")
            {

            }

            Bar(() => Console.Write(pos.ToString() == "First"));
        }
예제 #15
0
 public void CreateCone(Player p, byte type, ConeType coneType, ushort radius, ushort verticalExpansion)
 {
     List<Pos> buffer = new List<Pos>();
     Level level = p.level;
     ushort cx = (ushort)(p.pos[0] / 32), cy = (ushort)((p.pos[1] / 32) - 1), cz = (ushort)(p.pos[2] / 32);
     ushort sx = (ushort)(cx - radius - 1), sy = cy, sz = (ushort)(cz - radius - 1), ex = (ushort)(cx + radius + 1), ey = (ushort)(cy + (radius * verticalExpansion)), ez = (ushort)(cz + radius + 1);
     ushort tempRadius = radius;
     Pos pos = new Pos(); pos.x = cx; pos.y = ey; pos.z = cz;
     for (ushort i = 0; i < verticalExpansion; i++)
         if (level.GetTile(cx, (ushort)(ey + i), cz) != type)
         {
             pos.y = (ushort)(ey + i);
             buffer.Add(pos);
         }
     int temp = 0;
     if (coneType == ConeType.Hollow)
     {
         for (ushort y = sy; y < ey; y++)
         {
             for (ushort x = sx; x < ex; x++)
                 for (ushort z = sz; z < ez; z++)
                     if (Math.Round(Distance(cx, y, cz, x, y, z)) == tempRadius)
                         if (level.GetTile(x, y, z) != type)
                         {
                             pos.x = x; pos.y = y; pos.z = z;
                             buffer.Add(pos);
                         }
             temp++;
             if (temp == verticalExpansion)
             {
                 temp = 0;
                 tempRadius--;
             }
         }
     }
     else if (coneType == ConeType.Solid)
     {
         for (ushort y = sy; y < ey; y++)
         {
             for (ushort x = sx; x < ex; x++)
                 for (ushort z = sz; z < ez; z++)
                     if (Math.Round(Distance(cx, y, cz, x, y, z)) <= tempRadius)
                         if (level.GetTile(x, y, z) != type)
                         {
                             pos.x = x; pos.y = y; pos.z = z;
                             buffer.Add(pos);
                         }
             temp++;
             if (temp == verticalExpansion)
             {
                 temp = 0;
                 tempRadius--;
             }
         }
     }
     Execute(p, buffer, type);
 }
예제 #16
0
 public PString(string value, int index, int endIndex, Pos pos, Pos defPos, Sidedness side, Option<object> userState)
 {
     Value = value;
     Index = index;
     EndIndex = endIndex;
     Pos = pos;
     DefPos = defPos;
     Side = side;
     UserState = userState;
 }
예제 #17
0
파일: Cell.cs 프로젝트: Lyloox/Abimn
 public void Draw(Pos pos, Center center = Center.None, bool fighting = false)
 {
     if (fighting)
         Tile.Draw("fight/" + IdFloor, pos);
     else
     {
         Tile.Draw("main/" + IdFloor, pos);
         if (IdDeco != 0)
             Tile.Draw("main deco/" + IdDeco, pos);
     }
 }
예제 #18
0
        private string CalculatePath(GameState state, Pos goal)
        {
            Pos start = state.myHero.pos;

            Console.WriteLine("Begining calculating path from ({0},{1}) to ({2},{3})", start.x, start.y, goal.x, goal.y);

            try
            {
                List<Pos> visited = new List<Pos>();
                List<PathCoord> availableTiles = new List<PathCoord>();

                var first = createPathCoord(start, null, state, goal, null);
                availableTiles.Add(first);

                while (availableTiles.Any())
                {
                    // Sort availableTiles
                    availableTiles.Sort((f1, f2) => f1.heuristic.CompareTo(f2.heuristic));

                    var currentVisited = availableTiles.First();
                    availableTiles.Remove(currentVisited);

                    if (visited.Any(x => x.x == currentVisited.current.x && x.y==currentVisited.current.y))
                    {
                        continue;
                    }

                   // Console.WriteLine("Visiting ({0},{1}) with heuristic {2}", currentVisited.current.x, currentVisited.current.y, currentVisited.heuristic);

                    visited.Add(currentVisited.current);

                    if (getDistance(currentVisited.current, goal) == 0)
                    {
                        string direction = Restitute(start, currentVisited);
                        Console.WriteLine("Path found! Going {0}", direction);
                        return direction;
                    }
                    else
                    {
                        var spreadFrom = getAvailableCoords(currentVisited, state, goal);
                        availableTiles.AddRange(spreadFrom);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            Console.WriteLine("No path found!");
            return Direction.Stay;
        }
예제 #19
0
 static string toErrorStr(ParseError err, Pos? pos)
 {
     System.Text.StringBuilder buf = new System.Text.StringBuilder();
     if (pos.HasValue)
         buf.Append("line " + pos.Value.Line + ", column " + pos.Value.Column);
     if (err != null)
     {
         buf.Append(":\n");
         showExpecting(buf, err.getExpecting());
         showUnexpected(buf, err.getUnexpected());
         showMessages(buf, err.getMessages());
         showEncountered(buf, err.getEncountered());
     }
     return buf.ToString();
 }
예제 #20
0
 private void UserControl1_MouseDown(object sender, MouseEventArgs e)
 {
     if (e.X >= minPos && e.X <= (maxPos) &&
         e.Y >= 100 && e.Y <= 150)
     {
         pointedPos = Pos.M;
         if (e.X <= minPos + 20) pointedPos = Pos.L;
         if (e.X >= maxPos - 20) pointedPos = Pos.R;
         lastPoint = new Point(e.X, e.Y);
         this.Refresh();
     }
     else
     {
         pointedPos = Pos.N;
     }
 }
예제 #21
0
        public void Use(Player p, string[] args)
        {
            List<Pos> stored = new List<Pos>();
            Pos pos = new Pos();
            int currentBlock = 0;
            byte type = 0;
            byte type2 = 0;
            if (args.Length != 2)
            {
                p.SendMessage("Invalid arguments!");
                Help(p);
                return;
            }
            try
            {
                type = Blocks.NameToByte(args[0]);
                type2 = Blocks.NameToByte(args[1]);
            }
            catch
            {
                p.SendMessage("Could not find block specified");
                return;
            }

            foreach (byte b in p.level.data)
            {
                if (b == type)
                {
                    Point3 meep = p.level.IntToPos(currentBlock);
                    pos.pos = meep;
                    stored.Add(pos);
                }
                currentBlock++;
            }

            //Permissions here.
            p.SendMessage(stored.Count + " blocks out of " + currentBlock + " are " + Blocks.ByteToName(type));

            //Blockqueue here

            foreach (Pos _pos in stored)
            {
                p.level.BlockChange((ushort)(_pos.pos.x), (ushort)(_pos.pos.z), (ushort)(_pos.pos.y), type2);
            }
            p.SendMessage("&4/replaceall finished!");
        }
    public GameObject GetClosestCharacterForEnemyCharacter(Pos selfPos, Vector2 selfPosTransform, int range)
    {
        //範囲内にいるキャラクターを取得
        List<GameObject> characters = GetAroundCharacter (selfPos, range);
        //取得したキャラクターの中から最も近くにいるキャラクターを取得
        GameObject closestCharacter = null;
        float distance = 9999;
        float closestDistance = 9999;

        foreach (GameObject character in characters) {
            distance = Vector2.Distance (selfPosTransform, character.transform.position);
            if (distance < closestDistance) {
                closestCharacter = character;
                closestDistance = distance;
            }
        }
        return closestCharacter;
    }
예제 #23
0
 public static void Move(Pos pos, char direction)
 {
     switch (direction)
     {
         case '>':
             pos.X += 1;
             break;
         case '<':
             pos.X -= 1;
             break;
         case '^':
             pos.Y += 1;
             break;
         case 'v':
             pos.Y -= 1;
             break;
     }
 }
예제 #24
0
 //添加消费机
 private void button1_Click(object sender, System.EventArgs e)
 {
     int comport = decimal.ToInt32(ComPort.Value);
     int posit =  decimal.ToInt32(PosId.Value);
     Pos pos = new Pos(comport,posit);
     bool posconnect = pos.IsConnected();
     Poses.Add(pos);
     ListViewItem newpos = new ListViewItem(
         new string[]{
             "COM"+comport,
             ""+posit,
             (posconnect?"已连接":"未连接")},
             null,
             posconnect?System.Drawing.Color.Black:System.Drawing.Color.Gray,
             System.Drawing.Color.White,
             this.checkBox1.Font
         );
     PosList.Items.Add(newpos);
     ComPort.Value++;
     PosId.Value++;
 }
    public List<GameObject> GetAroundCharacter(Pos selfPos, int range)
    {
        GameObject[] characters = GameObject.FindGameObjectsWithTag (TagName.Giant);
        List<GameObject> targetCharacters = new List<GameObject> ();
        if (characters.Length != 0) {

            foreach (GameObject chr in characters) {
                if (chr.GetComponent<Character> ().currentPos != null) {
                    //キャラクターの座標を取得
                    Pos chrPos = chr.GetComponent<Character> ().currentPos;
                    //範囲内にいればリストに追加
        //				print (gameObject.name + "self pos" + selfPos.posX.ToString () + selfPos.posY.ToString ());
        //				print (gameObject.name + "target pos" + chrPos.posX.ToString () + chrPos.posY.ToString ());
        //				print ("range is" + "X" + (selfPos.posX - range).ToString () + "to" + (selfPos.posX + range).ToString () + "Y" + (chrPos.posY - range).ToString () + "to" + (chrPos.posY + range).ToString ());
                    if (selfPos.posX - range <= chrPos.posX && chrPos.posX <= selfPos.posX + range && selfPos.posY - range <= chrPos.posY && chrPos.posY <= selfPos.posY + range) {
                        targetCharacters.Add (chr);
                        //chr.GetComponent<Character> ().childSprite.color = Color.red;
                    }
                }
            }
        }
        return targetCharacters;
    }
예제 #26
0
		//For the pyramid commands, Radius still refers to the distance from the center point, but is axis independant, rather than a referance to both axes
		public static void Pyramid(Player p, ushort x, ushort y, ushort z, int height, int radius, byte type, byte extType, bool invert) {
			List<Pos> buffer = new List<Pos>();
			Pos temp = new Pos();
			for (short yy = 0; yy <= height; yy++)
				for (short zz = (short)-radius; zz <= radius; zz++)
					for (short xx = (short)-radius; xx <= radius; xx++)
			{
				int cx = (x + xx), cy = (y + yy), cz = (z + zz);
				int curHeight = invert ? yy : height - yy;
				if (curHeight == 0)
					continue;
				double curRadius = radius * ((double)curHeight / (double)height);
				if (Math.Abs(xx) > curRadius || Math.Abs(zz) > curRadius)
					continue;

				byte ctile = p.level.GetTile((ushort)cx, (ushort)cy, (ushort)cz);
				if (ctile == 0){
					temp.x = (ushort)cx; temp.y = (ushort)cy; temp.z = (ushort)cz;
					buffer.Add(temp);
				}
			}
			Draw(ref buffer, p, x, y, z, height, type, extType, invert);
		}
예제 #27
0
 public MapSettings(string name)
 {
     this.name = name;
     fast = 0;
     killer = 100;
     destroy = 0;
     water = 0;
     layer = 0;
     layerHeight = 3;
     layerCount = 10;
     layerInterval = 2;
     roundTime = 15;
     floodTime = 5;
     blockFlood = new Pos();
     blockLayer = new Pos();
     safeZone = new Pos[] { new Pos(), new Pos() };
 }
예제 #28
0
 public CString(Pos tp, string value) : base(tp, value)
 {
 }
예제 #29
0
파일: CmdSpheroid.cs 프로젝트: 303i/MCDek
        public void Blockchange2(Player p, ushort x, ushort y, ushort z, byte type)
        {
            p.ClearBlockchange();
            byte b = p.level.GetTile(x, y, z);
            p.SendBlockchange(x, y, z, b);
            CatchPos cpos = (CatchPos)p.blockchangeObject;
            if (cpos.type != Block.Zero) { type = cpos.type; }
            List<Pos> buffer = new List<Pos>();

            if (!cpos.vertical)
            {
                /* Courtesy of fCraft's awesome Open-Source'ness :D */

                // find start/end coordinates
                int sx = Math.Min(cpos.x, x);
                int ex = Math.Max(cpos.x, x);
                int sy = Math.Min(cpos.y, y);
                int ey = Math.Max(cpos.y, y);
                int sz = Math.Min(cpos.z, z);
                int ez = Math.Max(cpos.z, z);

                // find axis lengths
                double rx = (ex - sx + 1) / 2 + .25;
                double ry = (ey - sy + 1) / 2 + .25;
                double rz = (ez - sz + 1) / 2 + .25;

                double rx2 = 1 / (rx * rx);
                double ry2 = 1 / (ry * ry);
                double rz2 = 1 / (rz * rz);

                // find center points
                double cx = (ex + sx) / 2;
                double cy = (ey + sy) / 2;
                double cz = (ez + sz) / 2;
                int totalBlocks = (int)(Math.PI * 0.75 * rx * ry * rz);

                if (totalBlocks > p.group.maxBlocks)
                {
                    Player.SendMessage(p, "You tried to spheroid " + totalBlocks + " blocks.");
                    Player.SendMessage(p, "You cannot spheroid more than " + p.group.maxBlocks + ".");
                    return;
                }

                Player.SendMessage(p, totalBlocks + " blocks.");

                for (int xx = sx; xx <= ex; xx += 8)
                    for (int yy = sy; yy <= ey; yy += 8)
                        for (int zz = sz; zz <= ez; zz += 8)
                            for (int z3 = 0; z3 < 8 && zz + z3 <= ez; z3++)
                                for (int y3 = 0; y3 < 8 && yy + y3 <= ey; y3++)
                                    for (int x3 = 0; x3 < 8 && xx + x3 <= ex; x3++)
                                    {
                                        // get relative coordinates
                                        double dx = (xx + x3 - cx);
                                        double dy = (yy + y3 - cy);
                                        double dz = (zz + z3 - cz);

                                        // test if it's inside ellipse
                                        if ((dx * dx) * rx2 + (dy * dy) * ry2 + (dz * dz) * rz2 <= 1)
                                        {
                                            p.level.Blockchange(p, (ushort)(x3 + xx), (ushort)(yy + y3), (ushort)(zz + z3), type);
                                        }
                                    }
            }
            else
            {
                int radius = Math.Abs(cpos.x - x) / 2;
                int f = 1 - radius;
                int ddF_x = 1;
                int ddF_y = -2 * radius;
                int xx = 0;
                int zz = radius;

                int x0 = Math.Min(cpos.x, x) + radius;
                int z0 = Math.Min(cpos.z, z) + radius;

                Pos pos = new Pos();
                pos.x = (ushort)x0; pos.z = (ushort)(z0 + radius); buffer.Add(pos);
                pos.z = (ushort)(z0 - radius); buffer.Add(pos);
                pos.x = (ushort)(x0 + radius); pos.z = (ushort)z0; buffer.Add(pos);
                pos.x = (ushort)(x0 - radius); buffer.Add(pos);

                while (xx < zz)
                {
                    if (f >= 0)
                    {
                        zz--;
                        ddF_y += 2;
                        f += ddF_y;
                    }
                    xx++;
                    ddF_x += 2;
                    f += ddF_x;

                    pos.z = (ushort)(z0 + zz);
                    pos.x = (ushort)(x0 + xx); buffer.Add(pos);
                    pos.x = (ushort)(x0 - xx); buffer.Add(pos);
                    pos.z = (ushort)(z0 - zz);
                    pos.x = (ushort)(x0 + xx); buffer.Add(pos);
                    pos.x = (ushort)(x0 - xx); buffer.Add(pos);
                    pos.z = (ushort)(z0 + xx);
                    pos.x = (ushort)(x0 + zz); buffer.Add(pos);
                    pos.x = (ushort)(x0 - zz); buffer.Add(pos);
                    pos.z = (ushort)(z0 - xx);
                    pos.x = (ushort)(x0 + zz); buffer.Add(pos);
                    pos.x = (ushort)(x0 - zz); buffer.Add(pos);
                }

                int ydiff = Math.Abs(y - cpos.y) + 1;

                if (buffer.Count * ydiff > p.group.maxBlocks)
                {
                    Player.SendMessage(p, "You tried to spheroid " + buffer.Count * ydiff + " blocks.");
                    Player.SendMessage(p, "You cannot spheroid more than " + p.group.maxBlocks + ".");
                    return;
                }
                Player.SendMessage(p, buffer.Count * ydiff + " blocks.");

                foreach (Pos Pos in buffer)
                {
                    for (ushort yy = Math.Min(cpos.y, y); yy <= Math.Max(cpos.y, y); yy++)
                    {
                        p.level.Blockchange(p, Pos.x, yy, Pos.z, type);
                    }
                }
            }

            if (p.staticCommands) p.Blockchange += new Player.BlockchangeEventHandler(Blockchange1);
        }
예제 #30
0
        static void Main(string[] args)
        {
            Application.Init();
            var top = Application.Top;

            // Creates the top-level window to show
            var win = new Window("Fencing Score Board")
            {
                X = 0,
                Y = 1, // Leave one row for the toplevel menu

                // By using Dim.Fill(), it will automatically resize without manual intervention
                Width  = Dim.Fill(),
                Height = Dim.Fill()
            };

            top.Add(win);

            // Creates a menubar, the item "New" has a help menu.
            var menu = new MenuBar(new MenuBarItem[] {
                new MenuBarItem("_File", new MenuItem [] {
                    //new MenuItem ("_New", "Creates new file", NewFile),
                    //new MenuItem ("_Close", "", () => Close ()),
                    new MenuItem("_Quit", "", () => { if (Quit())
                                                      {
                                                          top.Running = false;
                                                      }
                                 })
                }),
                //new MenuBarItem ("_Edit", new MenuItem [] {
                //    new MenuItem ("_Copy", "", null),
                //    new MenuItem ("C_ut", "", null),
                //    new MenuItem ("_Paste", "", null)
                //})
            });

            top.Add(menu);

            var ms        = new MemoryStream();
            var hexViewer = new HexView(ms);

            IParseScoreMachineState parser = new FaveroStateParser();
            var provider = new SerialPortProvider(data =>
            {
                Debug.WriteLine(data);
                ms.Write(data.ToArray(), 0, data.Length);

                return(Task.FromResult(0));
            });

            var deviceTypes     = new ListView(new[] { "SG", "Favero" }.ToList());
            var deviceTypeFrame = new FrameView("Devices")
            {
                Height = Dim.Percent(50),
                Width  = Dim.Percent(25),
            };

            deviceTypeFrame.Add(deviceTypes);

            var ports     = new ListView(provider.ListPorts().ToList());
            var portFrame = new FrameView("Serial Ports")
            {
                Y      = Pos.Percent(50),
                Height = Dim.Percent(100),
                Width  = Dim.Percent(25),
            };

            portFrame.Add(ports);

            //var connect = new Button("Open")
            //{
            //    Y = Pos.Bottom(portFrame),
            //};
            //connect.Clicked = () =>
            //{
            //    var portName = ports.Source is List<string> names ? names[ports.SelectedItem] : null;
            //    Debug.WriteLine(portName);
            //    if (!string.IsNullOrWhiteSpace(portName))
            //        provider.Open(portName);
            //};
            //portFrame.Add(connect);

            var scoreFrame = new FrameView("Scores")
            {
                X      = Pos.Percent(25),
                Height = Dim.Percent(85),
                Width  = Dim.Percent(100),
            };

            var dataFrame = new FrameView("Data")
            {
                X      = Pos.Percent(25),
                Y      = Pos.Percent(85),
                Height = Dim.Percent(100),
                Width  = Dim.Percent(100),
            };


            win.Add(deviceTypeFrame);
            win.Add(portFrame);
            win.Add(scoreFrame);
            win.Add(dataFrame);


            //var ports =  provider.ListPorts();
            // foreach(var port in ports)
            // {
            //     Console.WriteLine(port);
            // }

            Application.Run();
        }
예제 #31
0
 public class SquareOpen : Token { public SquareOpen(Pos tp) : base(tp)
                                   {
                                   }
예제 #32
0
 public class CurlyClose : Token { public CurlyClose(Pos tp) : base(tp)
                                   {
                                   }
 private void TriggerRecalculate(ColData.Trigger[] Triggers, List <ColData.GroupInfo> Groups, List <ColData.ColTri> Indexes, List <Pos> Vertexes, int index)
 {
     if (Triggers[index].Flag1 >= 0)
     {
         float pad = 0;
         TriggerRecalculate(Triggers, Groups, Indexes, Vertexes, Triggers[index].Flag1);
         TriggerRecalculate(Triggers, Groups, Indexes, Vertexes, Triggers[index].Flag2);
         Triggers[index].X1 = Math.Min(Triggers[Triggers[index].Flag1].X1, Triggers[Triggers[index].Flag2].X1) - pad;
         Triggers[index].Y1 = Math.Min(Triggers[Triggers[index].Flag1].Y1, Triggers[Triggers[index].Flag2].Y1) - pad;
         Triggers[index].Z1 = Math.Min(Triggers[Triggers[index].Flag1].Z1, Triggers[Triggers[index].Flag2].Z1) - pad;
         Triggers[index].X2 = Math.Max(Triggers[Triggers[index].Flag1].X2, Triggers[Triggers[index].Flag2].X2) + pad;
         Triggers[index].Y2 = Math.Max(Triggers[Triggers[index].Flag1].Y2, Triggers[Triggers[index].Flag2].Y2) + pad;
         Triggers[index].Z2 = Math.Max(Triggers[Triggers[index].Flag1].Z2, Triggers[Triggers[index].Flag2].Z2) + pad;
     }
     else
     {
         float x1 = 0f, x2 = 0f, y1 = 0f, y2 = 0f, z1 = 0f, z2 = 0f;
         float pad = 0;
         for (int i = (int)Groups[-Triggers[index].Flag1 - 1].Offset; i < Groups[-Triggers[index].Flag1 - 1].Offset + Groups[-Triggers[index].Flag1 - 1].Size; ++i)
         {
             Pos a = Vertexes[Indexes[i].Vert1], b = Vertexes[Indexes[i].Vert2], c = Vertexes[Indexes[i].Vert3];
             if (x1 == 0)
             {
                 x1 = Math.Min(a.X, Math.Min(b.X, c.X)) - pad;
             }
             else
             {
                 x1 = Math.Min(x1, Math.Min(a.X, Math.Min(b.X, c.X))) - pad;
             }
             if (y1 == 0)
             {
                 y1 = Math.Min(a.Y, Math.Min(b.Y, c.Y)) - pad;
             }
             else
             {
                 y1 = Math.Min(y1, Math.Min(a.Y, Math.Min(b.Y, c.Y))) - pad;
             }
             if (z1 == 0)
             {
                 z1 = Math.Min(a.Z, Math.Min(b.Z, c.Z)) - pad;
             }
             else
             {
                 z1 = Math.Min(z1, Math.Min(a.Z, Math.Min(b.Z, c.Z))) - pad;
             }
             if (x2 == 0)
             {
                 x2 = Math.Max(a.X, Math.Max(b.X, c.X)) + pad;
             }
             else
             {
                 x2 = Math.Max(x2, Math.Max(a.X, Math.Max(b.X, c.X))) + pad;
             }
             if (y2 == 0)
             {
                 y2 = Math.Max(a.Y, Math.Max(b.Y, c.Y)) + pad;
             }
             else
             {
                 y2 = Math.Max(y2, Math.Max(a.Y, Math.Max(b.Y, c.Y))) + pad;
             }
             if (z2 == 0)
             {
                 z2 = Math.Max(a.Z, Math.Max(b.Z, c.Z));
             }
             else
             {
                 z2 = Math.Max(z2, Math.Max(a.Z, Math.Max(b.Z, c.Z))) + pad;
             }
         }
         Triggers[index].X1 = x1;
         Triggers[index].Y1 = y1;
         Triggers[index].Z1 = z1;
         Triggers[index].X2 = x2;
         Triggers[index].Y2 = y2;
         Triggers[index].Z2 = z2;
     }
 }
예제 #34
0
 public Token(Pos tp)
 {
     pos = tp;
 }
예제 #35
0
 public virtual bool IsSolid(Chunk chunk, Pos pos, Block block, Direction direction)
 {
     return(solid);
 }
예제 #36
0
 public Region(Pos position, int tool, bool toolChange = false)
 {
     Position   = position;
     Tool       = tool;
     ToolChange = toolChange;
 }
예제 #37
0
        public void Blockchange1(Player p, ushort x, ushort y, ushort z, byte type)
        {
            try
            {
                if (!p.level.allowguns)
                {
                }
                byte by = p.level.GetTile(x, y, z);
                p.SendBlockchange(x, y, z, by);
                Pos bp = (Pos)p.blockchangeObject;

                double a = Math.Sin(((double)(128 - p.rot[0]) / 256) * 2 * Math.PI);
                double b = Math.Cos(((double)(128 - p.rot[0]) / 256) * 2 * Math.PI);
                double c = Math.Cos(((double)(p.rot[1] + 64) / 256) * 2 * Math.PI);
                double d = Math.Cos(((double)(p.rot[1]) / 256) * 2 * Math.PI);

                double bigDiag = Math.Sqrt(Math.Sqrt(p.level.width * p.level.width + p.level.height * p.level.height) + p.level.depth * p.level.depth + p.level.width * p.level.width);

                List <CatchPos> previous  = new List <CatchPos>();
                List <CatchPos> allBlocks = new List <CatchPos>();
                CatchPos        pos;

                if (p.modeType != Block.air)
                {
                    type = p.modeType;
                }

                Thread gunThread = new Thread(new ThreadStart(delegate
                {
                    try
                    {
                        if (!p.level.allowguns)
                        {
                            Player.SendMessage(p, "Gun use is not allowed on this level."); p.aiming = false; return;
                        }
                        ushort startX = (ushort)(p.pos[0] / 32);
                        ushort startY = (ushort)(p.pos[1] / 32);
                        ushort startZ = (ushort)(p.pos[2] / 32);

                        pos.x = (ushort)Math.Round(startX + (double)(a * 3 * d));
                        pos.y = (ushort)Math.Round(startY + (double)(c * 3));
                        pos.z = (ushort)Math.Round(startZ + (double)(b * 3 * d));

                        for (double t = 4; bigDiag > t; t++)
                        {
                            pos.x = (ushort)Math.Round(startX + (double)(a * t * d));
                            pos.y = (ushort)Math.Round(startY + (double)(c * t));
                            pos.z = (ushort)Math.Round(startZ + (double)(b * t * d));

                            by = p.level.GetTile(pos.x, pos.y, pos.z);

                            if (by != Block.air && !allBlocks.Contains(pos))
                            {
                                if (p.level.physics < 2 || bp.ending <= 0)
                                {
                                    break;
                                }
                                else
                                {
                                    if (bp.ending == 1)
                                    {
                                        if ((!Block.LavaKill(by) && !Block.NeedRestart(by)) && by != Block.glass)
                                        {
                                            break;
                                        }
                                    }
                                    else if (p.level.physics >= 3 && p.level.physics != 5)
                                    {
                                        if (by != Block.glass)
                                        {
                                            p.level.MakeExplosion(pos.x, pos.y, pos.z, 1);
                                            break;
                                        }
                                    }
                                    else
                                    {
                                        break;
                                    }
                                }
                            }

                            p.level.Blockchange(pos.x, pos.y, pos.z, type);
                            previous.Add(pos);
                            allBlocks.Add(pos);

                            bool comeOut = false;
                            foreach (Player pl in Player.players)
                            {
                                if (pl.level == p.level)
                                {
                                    if ((ushort)(pl.pos[0] / 32) == pos.x || (ushort)(pl.pos[0] / 32 + 1) == pos.x || (ushort)(pl.pos[0] / 32 - 1) == pos.x)
                                    {
                                        if ((ushort)(pl.pos[1] / 32) == pos.y || (ushort)(pl.pos[1] / 32 + 1) == pos.y || (ushort)(pl.pos[1] / 32 - 1) == pos.y)
                                        {
                                            if ((ushort)(pl.pos[2] / 32) == pos.z || (ushort)(pl.pos[2] / 32 + 1) == pos.z || (ushort)(pl.pos[2] / 32 - 1) == pos.z)
                                            {
                                                if (p.level.ctfmode && !p.level.ctfgame.friendlyfire && p.team == pl.team)
                                                {
                                                    comeOut = true;
                                                    break;
                                                }
                                                if (p.level.ctfmode)
                                                {
                                                    pl.health = pl.health - 25;
                                                    if (pl.health > 0)
                                                    {
                                                        pl.SendMessage("You have been shot!  You have &c" + pl.health + "&g health remaining.");
                                                        comeOut = true;
                                                        break;
                                                    }
                                                }


                                                if ((p.level.physics >= 3 && pl.level.physics != 5) && (bp.ending == 2 || bp.ending == 3))
                                                {
                                                    pl.HandleDeath(Block.stone, " was blown up by " + p.color + p.name, true);
                                                }
                                                else if (bp.ending == 4)
                                                {
                                                    Player.GlobalChat(null, pl.color + pl.name + "&g was shot by the freezegun.", false);
                                                    Command.all.Find("freeze").Use(p, pl.name);
                                                }
                                                else if (bp.ending == 5)
                                                {
                                                    Player.GlobalChat(null, pl.color + pl.name + "&g was shot by the cagegun.", false);
                                                    Command.all.Find("cage").Use(p, pl.name);
                                                }
                                                else if (bp.ending == 6)
                                                {
                                                    Player.GlobalChat(null, pl.color + pl.name + "&g was shot by the botgun.", false);
                                                    Command.all.Find("botadd").Use(pl, p.name);
                                                }
                                                else if (bp.ending == 7)
                                                {
                                                    Player.GlobalChat(null, pl.color + pl.name + "&g was shot by the maingun.", false);
                                                    Command.all.Find("main").Use(pl, "");
                                                }
                                                else if (bp.ending == 8)
                                                {
                                                    Player.GlobalChat(null, pl.color + pl.name + "&g was shot by the demotegun.", false);
                                                    Command.all.Find("demote").Use(p, pl.name);
                                                }
                                                else if (bp.ending == 9)
                                                {
                                                    Player.GlobalChat(null, pl.color + pl.name + "&g was shot by the promotegun.", false);
                                                    Command.all.Find("promote").Use(p, pl.name);
                                                }
                                                else if (bp.ending == 10)
                                                {
                                                    Player.GlobalChat(null, pl.color + pl.name + "&g was shot by the jokergun.", false);
                                                    Command.all.Find("joker").Use(p, pl.name);
                                                }
                                                else if (bp.ending == 11)
                                                {
                                                    try
                                                    {
                                                        Player.GlobalChat(null, pl.color + pl.name + "&g was shot by the kickgun.", false);
                                                        Command.all.Find("kick").Use(p, pl.name);
                                                        break;
                                                    }
                                                    catch { }
                                                }
                                                else if (bp.ending == 12)
                                                {
                                                    Player.GlobalChat(null, pl.color + pl.name + "&g was shot by the undogun.", false);
                                                    Command.all.Find("undo").Use(pl, "");
                                                }
                                                else if (bp.ending == 13)
                                                {
                                                    Player.GlobalChat(null, pl.color + pl.name + "&g was shot by the redogun.", false);
                                                    Command.all.Find("redo").Use(pl, "");
                                                }
                                                else if (bp.ending == 14)
                                                {
                                                    try
                                                    {
                                                        Player.GlobalChat(null, pl.color + pl.name + "&g was shot by the xbangun.", false);
                                                        Command.all.Find("xban").Use(p, pl.name);
                                                        break;
                                                    }
                                                    catch { }
                                                }
                                                else if (bp.ending == 15)
                                                {
                                                    Player.GlobalChat(null, pl.color + pl.name + "&g was shot by the rulesgun.", false);
                                                    Command.all.Find("rules").Use(p, pl.name);
                                                }
                                                else
                                                {
                                                    pl.HandleDeath(Block.stone, " was shot by " + p.color + p.name);
                                                }
                                                comeOut = true;

                                                // freeze, cage, bot, main, demote, promote, joker, kick, undo, redo, xban, rules");
                                            }
                                        }
                                    }
                                }
                            }
                            if (comeOut)
                            {
                                break;
                            }

                            if (t > 12 && bp.ending != 3)
                            {
                                pos = previous[0];
                                p.level.Blockchange(pos.x, pos.y, pos.z, Block.air);
                                previous.Remove(pos);
                            }

                            if (bp.ending != 3)
                            {
                                Thread.Sleep(20);
                            }
                        }

                        if (bp.ending == -1)
                        {
                            try
                            {
                                unchecked { p.SendPos((byte)-1, (ushort)(previous[previous.Count - 3].x * 32), (ushort)(previous[previous.Count - 3].y * 32 + 32), (ushort)(previous[previous.Count - 3].z * 32), p.rot[0], p.rot[1]); }
                            }
                            catch { }
                        }
                        if (bp.ending == 3)
                        {
                            Thread.Sleep(400);
                        }

                        foreach (CatchPos pos1 in previous)
                        {
                            p.level.Blockchange(pos1.x, pos1.y, pos1.z, Block.air);
                            if (bp.ending != 3)
                            {
                                Thread.Sleep(20);
                            }
                        }
                    }
                    catch (Exception e) { Server.ErrorLog(e); }
                }));
                gunThread.Start();
            }
            catch { }
        }
예제 #38
0
        public override void Setup()
        {
            Win.Title  = this.GetName();
            Win.Y      = 1;           // menu
            Win.Height = Dim.Fill(1); // status bar
            Top.LayoutSubviews();

            this.tableView = new TableView()
            {
                X      = 0,
                Y      = 0,
                Width  = Dim.Fill(),
                Height = Dim.Fill(1),
            };

            var menu = new MenuBar(new MenuBarItem [] {
                new MenuBarItem("_File", new MenuItem [] {
                    new MenuItem("_Open CSV", "", () => Open()),
                    new MenuItem("_Save", "", () => Save()),
                    new MenuItem("_Quit", "", () => Quit()),
                }),
                new MenuBarItem("_Edit", new MenuItem [] {
                    new MenuItem("_New Column", "", () => AddColumn()),
                    new MenuItem("_New Row", "", () => AddRow()),
                    new MenuItem("_Rename Column", "", () => RenameColumn()),
                    new MenuItem("_Delete Column", "", () => DeleteColum()),
                    new MenuItem("_Move Column", "", () => MoveColumn()),
                    new MenuItem("_Move Row", "", () => MoveRow()),
                    new MenuItem("_Sort Asc", "", () => Sort(true)),
                    new MenuItem("_Sort Desc", "", () => Sort(false)),
                }),
                new MenuBarItem("_View", new MenuItem [] {
                    miLeft     = new MenuItem("_Align Left", "", () => Align(TextAlignment.Left)),
                    miRight    = new MenuItem("_Align Right", "", () => Align(TextAlignment.Right)),
                    miCentered = new MenuItem("_Align Centered", "", () => Align(TextAlignment.Centered)),

                    // Format requires hard typed data table, when we read a CSV everything is untyped (string) so this only works for new columns in this demo
                    miCentered = new MenuItem("_Set Format Pattern", "", () => SetFormat()),
                })
            });

            Top.Add(menu);

            var statusBar = new StatusBar(new StatusItem [] {
                new StatusItem(Key.CtrlMask | Key.O, "~^O~ Open", () => Open()),
                new StatusItem(Key.CtrlMask | Key.S, "~^S~ Save", () => Save()),
                new StatusItem(Key.CtrlMask | Key.Q, "~^Q~ Quit", () => Quit()),
            });

            Top.Add(statusBar);

            Win.Add(tableView);

            selectedCellLabel = new Label()
            {
                X             = 0,
                Y             = Pos.Bottom(tableView),
                Text          = "0,0",
                Width         = Dim.Fill(),
                TextAlignment = TextAlignment.Right
            };

            Win.Add(selectedCellLabel);

            tableView.SelectedCellChanged += OnSelectedCellChanged;
            tableView.CellActivated       += EditCurrentCell;
            tableView.KeyPress            += TableViewKeyPress;

            SetupScrollBar();
        }
예제 #39
0
 public Number(Pos tp, string value) : base(tp, value)
 {
 }
예제 #40
0
        public override void Setup()
        {
            var statusBar = new StatusBar(new StatusItem[] {
                //new StatusItem(Key.ControlR, "~CTRL-R~ Refresh Data", () => RefreshScreen()),
                new StatusItem(Key.ControlQ, "~CTRL-Q~ Back/Quit", () => Quit())
            });

            LeftPane = new Window("Installed Apps")
            {
                X           = 0,
                Y           = 0, // for menu
                Width       = 40,
                Height      = Dim.Fill(),
                CanFocus    = false,
                ColorScheme = Colors.TopLevel,
            };

            try
            {
                if (STClient.GetAllInstalledApps().Items?.Count > 0)
                {
                    _viewInstalledApps = STClient.GetAllInstalledApps().Items
                                         .OrderBy(t => t.DisplayName)
                                         .Select(t => new KeyValuePair <string, InstalledApp>(t.DisplayName, t))
                                         .ToDictionary(t => t.Key, t => t.Value);
                }
                else
                {
                    SetErrorView($"You have no installed apps");
                }
            }
            catch (SmartThingsNet.Client.ApiException exp)
            {
                SetErrorView($"Error calling API: {exp.Source} {exp.ErrorCode} {exp.Message}");
            }
            catch (System.Exception exp)
            {
                SetErrorView($"Unknown error calling API: {exp.Message}");
            }

            ClassListView = new ListView(_viewInstalledApps?.Keys?.ToList())
            {
                X             = 0,
                Y             = 0,
                Width         = Dim.Fill(0),
                Height        = Dim.Fill(), // for status bar
                AllowsMarking = false,
                ColorScheme   = Colors.TopLevel,
            };

            if (_viewInstalledApps?.Keys?.Count > 0)
            {
                ClassListView.SelectedItemChanged += (args) =>
                {
                    ClearClass(CurrentView);
                    var selectedItem = _viewInstalledApps.Values.ToArray()[ClassListView.SelectedItem];
                    CurrentView = CreateJsonView(selectedItem.ToJson());
                };
            }
            LeftPane.Add(ClassListView);

            HostPane = new FrameView("")
            {
                X = Pos.Right(LeftPane),
                //Y = Pos.Bottom(_settingsPane),
                Width       = Dim.Fill(),
                Height      = Dim.Fill(1), // + 1 for status bar
                ColorScheme = Colors.Dialog,
            };

            Top.Add(LeftPane, HostPane);
            Top.Add(statusBar);

            if (_viewInstalledApps?.Count > 0)
            {
                CurrentView = CreateJsonView(_viewInstalledApps?.FirstOrDefault().Value?.ToJson());
            }

            DisplayErrorView();
        }
예제 #41
0
 protected virtual void PostRender(Chunk chunk, Pos pos, Block block)
 {
 }
예제 #42
0
 get => new Rectangle(Pos, Size);
예제 #43
0
        private bool InteractMashContainer(IPlayer byPlayer, BlockSelection blockSel)
        {
            ItemSlot  handslot  = byPlayer.InventoryManager.ActiveHotbarSlot;
            ItemStack handStack = handslot.Itemstack;

            if (CompressAnimActive)
            {
                (Api as ICoreClientAPI)?.TriggerIngameError(this, "compressing", "Release the screw first to add/remove fruit");
                return(false);
            }

            // Put items
            if (!handslot.Empty)
            {
                var hprops = getJuiceableProps(handStack);
                if (hprops == null)
                {
                    return(false);
                }

                var pressedStack = hprops.PressedStack.ResolvedItemstack.Clone();
                if (MashSlot.Empty)
                {
                    MashSlot.Itemstack = pressedStack;
                }
                else if (mashStack.StackSize >= 10)
                {
                    (Api as ICoreClientAPI)?.TriggerIngameError(this, "fullcontainer", "Container is full, press out juice and remove the mash before adding more");
                    return(false);
                }

                if (!mashStack.Equals(Api.World, pressedStack, GlobalConstants.IgnoredStackAttributes.Append("juiceableLitresLeft", "juiceableLitresTransfered", "squeezeRel")))
                {
                    (Api as ICoreClientAPI)?.TriggerIngameError(this, "fullcontainer", "Cannot mix fruit");
                    return(false);
                }


                float transferableLitres;
                int   removeItems;
                if (hprops.LitresPerItem == null)
                {
                    float availableLitres = (float)handStack.Attributes.GetDecimal("juiceableLitresLeft");
                    transferableLitres = (float)Math.Min(availableLitres, juiceableLitresCapacity - juiceableLitresLeft);

                    float litresPerItem = availableLitres / handStack.StackSize;

                    // Round down to closest full stack sizes
                    removeItems        = (int)(transferableLitres / litresPerItem);
                    transferableLitres = removeItems * litresPerItem;

                    if (transferableLitres > 0)
                    {
                        handStack.Attributes.SetDouble("juiceableLitresLeft", availableLitres - transferableLitres);
                    }
                }
                else
                {
                    float desiredTransferSizeLitres = byPlayer.Entity.Controls.Sneak ? (float)hprops.LitresPerItem : 4 * (float)hprops.LitresPerItem;
                    transferableLitres = (float)Math.Min(desiredTransferSizeLitres, juiceableLitresCapacity - juiceableLitresLeft);

                    removeItems = (int)(transferableLitres / hprops.LitresPerItem);
                }

                if (transferableLitres > 0)
                {
                    handslot.TakeOut(removeItems);

                    mashStack.Attributes.SetDouble("juiceableLitresLeft", juiceableLitresLeft += transferableLitres);
                    mashStack.StackSize = 1;
                    handslot.MarkDirty();
                    MarkDirty(true);
                    renderer?.reloadMeshes(hprops, true);
                    (byPlayer as IClientPlayer)?.TriggerFpAnimation(EnumHandInteract.HeldItemInteract);
                }

                return(true);
            }

            // Take out mash
            if (MashSlot.Empty)
            {
                return(false);
            }

            if (!byPlayer.InventoryManager.TryGiveItemstack(mashStack, true))
            {
                Api.World.SpawnItemEntity(mashStack, Pos.ToVec3d().Add(0.5, 0.5, 0.5));
            }

            MashSlot.Itemstack = null;
            renderer?.reloadMeshes(null, true);

            if (Api.Side == EnumAppSide.Server)
            {
                MarkDirty(true);
            }

            return(true);
        }
예제 #44
0
        static void Main(string[] args)
        {
            _client = new IpcClient(new DefaultIpcEndpoint());
            var answer = _client.GetRepositories();

            var repositoryCount = answer?.Repositories?.Length ?? 0;

            if (repositoryCount == 0)
            {
                if (!string.IsNullOrEmpty(answer?.Answer))
                {
                    Console.WriteLine(answer.Answer);
                }
                else
                {
                    Console.WriteLine("No repositories yet");
                }

                return;
            }

            _repositoriesView = new RepositoriesView(answer.Repositories);

            Application.Init();

            var filterLabel = new Label(1, 1, "Filter: ");

            _filterField = new TextField("")
            {
                X     = Pos.Right(filterLabel) + 2,
                Y     = Pos.Top(filterLabel),
                Width = Dim.Fill(margin: 1),
            };
            _filterField.Changed += FilterField_Changed;

            _repositoryList = new ListView(_repositoriesView.Repositories)
            {
                X      = Pos.Left(filterLabel),
                Y      = Pos.Bottom(filterLabel) + 1,
                Width  = Dim.Fill(margin: 1),
                Height = Dim.Fill() - 2
            };

            var win = new KeyPreviewWindow("grr: Git repositories of RepoZ")
            {
                filterLabel,
                _filterField,
                _repositoryList
            };

            var buttonX = Pos.Left(filterLabel);

            var navigationButton = new Button("Navigate")
            {
                Clicked  = Navigate,
                X        = buttonX,
                Y        = Pos.AnchorEnd(1),
                CanFocus = false
            };

            if (!CanNavigate)
            {
                navigationButton.Text    = "Copy navigation command";
                navigationButton.Clicked = CopyNavigationCommandAndQuit;
            }

            buttonX = buttonX + navigationButton.Text.Length + BUTTON_BORDER + BUTTON_DISTANCE;
            var browseButton = new Button("Browse")
            {
                Clicked  = Browse,
                X        = buttonX,
                Y        = Pos.AnchorEnd(1),
                CanFocus = false
            };

            var quitButton = new Button("Quit")
            {
                Clicked  = Application.RequestStop,
                X        = Pos.AnchorEnd("Quit".Length + BUTTON_BORDER + BUTTON_DISTANCE),
                Y        = Pos.AnchorEnd(1),
                CanFocus = false
            };

            win.Add(navigationButton, browseButton, quitButton);

            win.DefineKeyAction(Key.Enter, () => win.SetFocus(_repositoryList));
            win.DefineKeyAction(Key.Esc, () =>
            {
                if (_filterField.HasFocus)
                {
                    SetFilterText("");
                }
                else
                {
                    win.SetFocus(_filterField);
                }
            });

            if (args?.Length > 0)
            {
                SetFilterText(String.Join(" ", args));
            }

            Application.Top.Add(win);
            Application.Run();
        }
예제 #45
0
 public class CurlyOpen : Token { public CurlyOpen(Pos tp) : base(tp)
                                  {
                                  }
예제 #46
0
        public override void Setup()
        {
            const string IdenticalSign = "\u2261";
            const string ArrowUpSign   = "\u2191";
            const string ArrowDownSign = "\u2193";
            const string EllipsesSign  = "\u2026";
            const string StashSign     = "\u205E";

            //string text = "Hello world, how are you today? Pretty neat!\nSecond line\n\nFourth Line.";
            string unicode = "Τὴ γλῶσσα μοῦ ἔδωσαν ἑλληνικὴ\nτὸ σπίτι φτωχικὸ στὶς ἀμμουδιὲς τοῦ Ὁμήρου.\nΜονάχη ἔγνοια ἡ γλῶσσα μου στὶς ἀμμουδιὲς τοῦ Ὁμήρου.";

            string gitString = $"gui.cs master {IdenticalSign} {ArrowDownSign}18 {ArrowUpSign}10 {StashSign}1 {EllipsesSign}";

            var menu = new MenuBar(new MenuBarItem [] {
                new MenuBarItem("_Файл", new MenuItem [] {
                    new MenuItem("_Создать", "Creates new file", null),
                    new MenuItem("_Открыть", "", null),
                    new MenuItem("Со_хранить", "", null),
                    new MenuItem("_Выход", "", () => Application.RequestStop())
                }),
                new MenuBarItem("_Edit", new MenuItem [] {
                    new MenuItem("_Copy", "", null),
                    new MenuItem("C_ut", "", null),
                    new MenuItem("_Paste", "", null)
                })
            });

            Top.Add(menu);

            var label = new Label("Label:")
            {
                X = 0, Y = 1
            };

            Win.Add(label);
            var testlabel = new Label(gitString)
            {
                X = 20, Y = Pos.Y(label), Width = Dim.Percent(50),
            };

            Win.Add(testlabel);

            label = new Label("Label (CanFocus):")
            {
                X = Pos.X(label), Y = Pos.Bottom(label) + 1
            };
            Win.Add(label);
            testlabel = new Label("Стоял &он, дум великих полн")
            {
                X = 20, Y = Pos.Y(label), Width = Dim.Percent(50), CanFocus = true, HotKeySpecifier = new System.Rune('&')
            };
            Win.Add(testlabel);

            label = new Label("Button:")
            {
                X = Pos.X(label), Y = Pos.Bottom(label) + 1
            };
            Win.Add(label);
            var button = new Button("A123456789♥♦♣♠JQK")
            {
                X = 20, Y = Pos.Y(label)
            };

            Win.Add(button);

            label = new Label("CheckBox:")
            {
                X = Pos.X(label), Y = Pos.Bottom(label) + 1
            };
            Win.Add(label);
            var checkBox = new CheckBox(gitString)
            {
                X = 20, Y = Pos.Y(label), Width = Dim.Percent(50)
            };

            Win.Add(checkBox);

            label = new Label("ComboBox:")
            {
                X = Pos.X(label), Y = Pos.Bottom(label) + 1
            };
            Win.Add(label);
            var comboBox = new ComboBox()
            {
                X     = 20,
                Y     = Pos.Y(label),
                Width = Dim.Percent(50),
            };

            comboBox.SetSource(new List <string> ()
            {
                gitString, "Со_хранить"
            });

            Win.Add(comboBox);
            comboBox.Text = gitString;

            label = new Label("HexView:")
            {
                X = Pos.X(label), Y = Pos.Bottom(label) + 2
            };
            Win.Add(label);
            var hexView = new HexView(new System.IO.MemoryStream(Encoding.ASCII.GetBytes(gitString + " Со_хранить")))
            {
                X      = 20,
                Y      = Pos.Y(label),
                Width  = Dim.Percent(60),
                Height = 5
            };

            Win.Add(hexView);

            label = new Label("ListView:")
            {
                X = Pos.X(label), Y = Pos.Bottom(hexView) + 1
            };
            Win.Add(label);
            var listView = new ListView(new List <string> ()
            {
                "item #1", gitString, "Со_хранить", unicode
            })
            {
                X      = 20,
                Y      = Pos.Y(label),
                Width  = Dim.Percent(60),
                Height = 3,
            };

            Win.Add(listView);

            label = new Label("RadioGroup:")
            {
                X = Pos.X(label), Y = Pos.Bottom(listView) + 1
            };
            Win.Add(label);
            var radioGroup = new RadioGroup(new ustring [] { "item #1", gitString, "Со_хранить" }, selected: 0)
            {
                X     = 20,
                Y     = Pos.Y(label),
                Width = Dim.Percent(60),
            };

            Win.Add(radioGroup);

            label = new Label("TextField:")
            {
                X = Pos.X(label), Y = Pos.Bottom(radioGroup) + 1
            };
            Win.Add(label);
            var textField = new TextField(gitString + " = Со_хранить")
            {
                X = 20, Y = Pos.Y(label), Width = Dim.Percent(60)
            };

            Win.Add(textField);

            label = new Label("TextView:")
            {
                X = Pos.X(label), Y = Pos.Bottom(textField) + 1
            };
            Win.Add(label);
            var textView = new TextView()
            {
                X      = 20,
                Y      = Pos.Y(label),
                Width  = Dim.Percent(60),
                Height = 5,
                Text   = unicode,
            };

            Win.Add(textView);

            // Move Win down to row 1, below menu
            Win.Y = 1;
            Top.LayoutSubviews();
        }
예제 #47
0
 public class SquareClose : Token { public SquareClose(Pos tp) : base(tp)
                                    {
                                    }
예제 #48
0
        /// <summary>
        /// Design and show View
        /// </summary>
        public void ShowModal()
        {
            var ntop = new Toplevel();

            // StatusBar
            var statusBar = new StatusBar(new StatusItem[] {
                new StatusItem(Key.Enter, "~Enter~ Backup", StartBackup),
                new StatusItem(Key.Esc, "~Esc~ Return", () => { Application.RequestStop(); })
            });

            ntop.Add(statusBar);
            ntop.StatusBar = statusBar;

            // Windows
            var win = new Window("Backup")
            {
                X      = 0,
                Y      = 0,
                Width  = Dim.Fill(),
                Height = Dim.Fill() - 1
            };

            ntop.Add(win);

            // Header
            var header = new Label()
            {
                X      = 0,
                Y      = 0,
                Width  = Dim.Fill(),
                Height = 3
            };
            var msg = "Path to repository : " + Program.dataManager.config.RepoPath + "\n";

            msg        += "Sources to backup : " + Program.dataManager.config.SourcesBackupPath + "\n";
            header.Text = msg.Replace("\r", "");
            win.Add(header);

            // Information
            info = new Label()
            {
                X      = 0,
                Y      = Pos.Bottom(header),
                Width  = Dim.Fill(),
                Height = Dim.Fill() - 4
            };
            info.Text = "";
            win.Add(info);

            // Current
            current = new Label()
            {
                X             = 0,
                Y             = Pos.Bottom(info),
                Width         = Dim.Fill(),
                Height        = 3,
                TextAlignment = TextAlignment.Centered
            };
            win.Add(current);

            // Progressbar
            pBar = new ProgressBar()
            {
                X = 0,

                Y        = Pos.Bottom(current),
                Width    = Dim.Fill(),
                Height   = 1,
                Fraction = 1
            };
            win.Add(pBar);

            Application.Run(ntop);
        }
예제 #49
0
 public class ParClose : Token { public ParClose(Pos tp) : base(tp)
                                 {
                                 }
예제 #50
0
 public virtual string GetName(Chunk chunk, Pos pos, Block block)
 {
     return(blockName);
 }
예제 #51
0
 public class ParOpen : Token { public ParOpen(Pos tp) : base(tp)
                                {
                                }
예제 #52
0
 public void Render(Chunk chunk, Pos pos, Block block, MeshData meshData)
 {
     PreRender(chunk, pos, block);
     AddMeshData(chunk, pos, block, ref meshData);
     PostRender(chunk, pos, block);
 }
예제 #53
0
 public virtual Block OnCreate(Chunk chunk, Pos pos, Block block)
 {
     return(block);
 }
예제 #54
0
 public virtual void OnDestroy(Chunk chunk, Pos pos, Block block, int destroyer)
 {
 }
예제 #55
0
 internal static string Show(ParseError err, Pos pos)
 {
     return toErrorStr(err, pos);
 }
예제 #56
0
 public virtual void RandomUpdate(Chunk chunk, Pos pos, Block block)
 {
 }
예제 #57
0
 public bool InSafeZone(Pos pos)
 {
     return InSafeZone(pos.x, pos.y, pos.z);
 }
예제 #58
0
 protected virtual void AddMeshData(Chunk chunk, Pos pos, Block block, ref MeshData meshData)
 {
 }
예제 #59
0
파일: SendKeys.cs 프로젝트: hong1990/gui.cs
        public override void Setup()
        {
            var label = new Label("Insert the text to send:")
            {
                X = Pos.Center(),
                Y = Pos.Center() - 6
            };

            Win.Add(label);

            var txtInput = new TextField("MockKeyPresses")
            {
                X     = Pos.Center(),
                Y     = Pos.Center() - 5,
                Width = 20
            };

            Win.Add(txtInput);

            var ckbShift = new CheckBox("Shift")
            {
                X = Pos.Center(),
                Y = Pos.Center() - 4
            };

            Win.Add(ckbShift);

            var ckbAlt = new CheckBox("Alt")
            {
                X = Pos.Center(),
                Y = Pos.Center() - 3
            };

            Win.Add(ckbAlt);

            var ckbControl = new CheckBox("Control")
            {
                X = Pos.Center(),
                Y = Pos.Center() - 2
            };

            Win.Add(ckbControl);

            label = new Label("Result keys:")
            {
                X = Pos.Center(),
                Y = Pos.Center() + 1
            };
            Win.Add(label);

            var txtResult = new TextField()
            {
                X     = Pos.Center(),
                Y     = Pos.Center() + 2,
                Width = 20,
            };

            Win.Add(txtResult);

            var rKeys        = "";
            var rControlKeys = "";
            var IsShift      = false;
            var IsAlt        = false;
            var IsCtrl       = false;

            txtResult.KeyPress += (e) => {
                rKeys += (char)e.KeyEvent.Key;
                if (!IsShift && e.KeyEvent.IsShift)
                {
                    rControlKeys += " Shift ";
                    IsShift       = true;
                }
                if (!IsAlt && e.KeyEvent.IsAlt)
                {
                    rControlKeys += " Alt ";
                    IsAlt         = true;
                }
                if (!IsCtrl && e.KeyEvent.IsCtrl)
                {
                    rControlKeys += " Ctrl ";
                    IsCtrl        = true;
                }
            };

            var lblShippedKeys = new Label()
            {
                X        = Pos.Center(),
                Y        = Pos.Center() + 3,
                AutoSize = true
            };

            Win.Add(lblShippedKeys);

            var lblShippedControlKeys = new Label()
            {
                X        = Pos.Center(),
                Y        = Pos.Center() + 5,
                AutoSize = true
            };

            Win.Add(lblShippedControlKeys);

            var button = new Button("Process keys")
            {
                X         = Pos.Center(),
                Y         = Pos.Center() + 7,
                IsDefault = true
            };

            Win.Add(button);

            void ProcessInput()
            {
                rKeys          = "";
                rControlKeys   = "";
                txtResult.Text = "";
                IsShift        = false;
                IsAlt          = false;
                IsCtrl         = false;
                txtResult.SetFocus();
                foreach (var r in txtInput.Text.ToString())
                {
                    var ck = char.IsLetter(r)
                                                ? (ConsoleKey)char.ToUpper(r) : (ConsoleKey)r;
                    Application.Driver.SendKeys(r, ck, ckbShift.Checked,
                                                ckbAlt.Checked, ckbControl.Checked);
                }
                lblShippedKeys.Text        = rKeys;
                lblShippedControlKeys.Text = rControlKeys;
                txtInput.SetFocus();
            }

            button.Clicked += () => ProcessInput();

            Win.KeyPress += (e) => {
                if (e.KeyEvent.Key == Key.Enter)
                {
                    ProcessInput();
                    e.Handled = true;
                }
            };
        }
예제 #60
0
 public Literal(Pos tp, string value) : base(tp)
 {
     this.value = value;
 }