示例#1
0
 public void CreatePieces(Vector2 position, Texture2D texture)
 {
     for (int i = 0; i < Globals.Randomizer.Next(10, 15); i++)
     {
         ToAdd.Add(new Piece(new Vector2(position.X + Globals.Randomizer.Next(-20, 20), position.Y + Globals.Randomizer.Next(-20, 20)), texture, 60, 1));
     }
 }
        private void addPointExecute()
        {
            TECPoint newPoint = new TECPoint();

            newPoint.Type     = PointType;
            newPoint.Quantity = PointQuantity;
            newPoint.Label    = PointName;
            ToAdd.AddPoint(newPoint);
            PointName = "";
            updateConnectVMWithQuantity(Quantity);
        }
示例#3
0
 /// <summary>
 /// Adds a child to this element.
 /// </summary>
 /// <param name="child">The element to be parented.</param>
 public void AddChild(UIElement child)
 {
     if (child.Parent != null)
     {
         throw new Exception("Tried to add a child that already has a parent!");
     }
     if (!Children.Contains(child))
     {
         ToAdd.Add(child);
     }
     else
     {
         throw new Exception("Tried to add a child that already belongs to this element!");
     }
 }
        public static string Write(object One, ref LswCSharp.CSharpPositions CSharpPosition)
        {
            string    Return = "";
            LsBracket Two    = (LsBracket)One;

            Return += Two.BracketTypesPears[Two.BracketType][0];
            int Point = 0;

            while (Two.BaseProperties.Count + Two.StringProperties.Count > Point)
            {
                object ToAdd;
                LsName ToAdd2;
                if (Two.BaseProperties.TryGetValue(Point, out ToAdd))
                {
                    if (ToAdd.GetType() == typeof(string))
                    {
                        Return += (ToAdd.ToString().Contains("\"")) ? "@" + '"' + DoubleSpeatch(ToAdd.ToString()) + '"' : '"' + ToAdd.ToString() + @"""";
                    }
                    else if (ToAdd.GetType() == typeof(char))
                    {
                        Return += (ToAdd.ToString().Contains("'")) ? "'\\''" : "'" + ToAdd.ToString() + @"''";
                    }
                    else if (ToAdd.GetType() == typeof(int))
                    {
                        Return += ToAdd.ToString() + "{int}";
                    }
                    else if (ToAdd.GetType() == typeof(bool))
                    {
                        Return += ToAdd.ToString().ToLower();
                    }
                    else if (ToAdd.GetType() == typeof(LsBracket))
                    {
                        Return += Write(ToAdd, ref CSharpPosition);
                    }
                    Return += Seperater(Two.BracketType) + " ";
                }
                else if (Two.StringProperties.TryGetValue(Point, out ToAdd2))
                {
                    Return += ToAdd2.Name + Seperater(Two.BracketType) + " ";
                }
                Point++;
            }
            Return  = Return.TrimEnd();
            Return  = Return.Substring(0, Return.Length - 1);
            Return += ")";
            return(Return);
        }
示例#5
0
 /// <summary>
 /// Removes a child from this element.
 /// </summary>
 /// <param name="child">The element to be unparented.</param>
 public void RemoveChild(UIElement child)
 {
     if (Children.Contains(child))
     {
         if (!ToRemove.Contains(child))
         {
             ToRemove.Add(child);
         }
     }
     else if (ToAdd.Contains(child))
     {
         ToAdd.Remove(child);
     }
     else
     {
         throw new Exception("Tried to remove a child that does not belong to this element!");
     }
 }
示例#6
0
        public override XmlNode ToXml(XmlDocument doc)
        {
            XmlElement root = doc.CreateElement("secDNS:update", "urn:ietf:params:xml:ns:secDNS-1.1");

            root.SetAttribute("xmlns:secDNS", "urn:ietf:params:xml:ns:secDNS-1.1");

            XmlAttribute xsd = doc.CreateAttribute("xsi", "schemaLocation", "http://www.w3.org/2001/XMLSchema-instance");

            xsd.Value = "urn:ietf:params:xml:ns:secDNS-1.1 secDNS-1.1.xsd";
            root.Attributes.Append(xsd);

            if (ToRemove.Any())
            {
                XmlElement removeNode = doc.CreateElement("secDNS:rem", "urn:ietf:params:xml:ns:secDNS-1.1");

                foreach (SecDNSData data in ToRemove)
                {
                    removeNode.AppendChild(data.ToXml(doc));
                }

                root.AppendChild(removeNode);
            }

            if (ToAdd.Any())
            {
                XmlElement addNode = doc.CreateElement("secDNS:add", "urn:ietf:params:xml:ns:secDNS-1.1");

                foreach (SecDNSData data in ToAdd)
                {
                    addNode.AppendChild(data.ToXml(doc));
                }

                root.AppendChild(addNode);
            }

            return(root);
        }
示例#7
0
        public void Update()
        {
            // Update tiles
            if (Started && !Player.Dead)
            {
                // Hull flash possible match
                timeSinceLastMatch++;
                if (Player.ShipHull.FlashPossibleTiles && timeSinceLastMatch > 240)
                {
                    timeSinceLastMatch = 0;
                    List <Tile> possibleMatches = CheckPossibleMatches();
                    possibleMatches[Globals.Randomizer.Next(0, possibleMatches.Count())].Flash = 145;
                }

                bool canSelect = true;
                for (int i = 0; i < Tiles.Count; i++)
                {
                    for (int j = 0; j < Tiles[i].Count; j++)
                    {
                        Tiles[i][j].TilePosition = new Point(i, j);
                        Tiles[i][j].UpdateLevel(this);

                        if (!Tiles[i][j].Hidden)
                        {
                            // Above hidden
                            if (j < BoardSize.Y - 1 && Tiles[i][j + 1].Hidden && Tiles[i][j + 1].Size < 0.1)
                            {
                                if (Tiles[i][j].Mine)
                                {
                                    Tiles[i][j].Mine = false;
                                }

                                Tile temp = Tiles[i][j];
                                Tiles[i][j]     = Tiles[i][j + 1];
                                Tiles[i][j + 1] = temp;
                            }

                            // Select
                            if (canSelect && Globals.MState.LeftButton == ButtonState.Pressed && Globals.PrevMState.LeftButton == ButtonState.Released && Globals.MRectangle.Intersects(Tiles[i][j].Box) && !Tiles.Any(Column => Column.Any(item => item.Moving == true)))
                            {
                                canSelect = false;
                                if (Selected == null)
                                {
                                    Selected = Tiles[i][j];
                                }
                                else if (Selected == Tiles[i][j])
                                {
                                    Selected = null;
                                }
                                else
                                {
                                    // Check if pressed tile next to selected
                                    if (CheckAdjacent(i, j))
                                    {
                                        Tile temp = Tiles[i][j];
                                        Tiles[i][j]               = Selected;
                                        Tiles[i][j].Moving        = true;
                                        Tiles[i][j].ManuallyMoved = 180;
                                        Tiles[Selected.TilePosition.X][Selected.TilePosition.Y]               = temp;
                                        Tiles[Selected.TilePosition.X][Selected.TilePosition.Y].Moving        = true;
                                        Tiles[Selected.TilePosition.X][Selected.TilePosition.Y].ManuallyMoved = 180;

                                        // Check if swap is matching
                                        if (!CheckSingleMatch(i, j, Tiles) && !CheckSingleMatch(Selected.TilePosition.X, Selected.TilePosition.Y, Tiles))
                                        {
                                            Tiles[i][j]        = Tiles[Selected.TilePosition.X][Selected.TilePosition.Y];
                                            Tiles[i][j].Moving = false;
                                            Tiles[Selected.TilePosition.X][Selected.TilePosition.Y]        = Selected;
                                            Tiles[Selected.TilePosition.X][Selected.TilePosition.Y].Moving = false;
                                            GameObjects.Add(new Text(Tiles[i][j].Position - (Tiles[i][j].Position - Tiles[Selected.TilePosition.X][Selected.TilePosition.Y].Position), "Invalid Swap!", Color.Red, 60, 2, false, TextureManager.SpriteFont20));
                                        }
                                        Selected = null;
                                    }
                                    else
                                    {
                                        Selected = Tiles[i][j];
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (Tiles[i][j].ManuallyMoved >= 0)
                            {
                                Tiles[i][j].ManuallyMoved = -1;
                            }

                            // "New" tile if hidden on top layer
                            if (j == 0)
                            {
                                Player player = (Player)GameObjects.First(item => item is Player);
                                Tiles[i][j].UnHide(player);
                            }
                        }
                    }
                }

                CheckMatch();

                // Modifiers

                if (HasModifier(Modifier.Asteroid))
                {
                    modifierTimer--;
                    // spawn rock if possible to move
                    if (modifierTimer < 0 && Globals.Randomizer.Next(0, 1001) < 3 && !(Player.ShipLocation == Location.left && !CheckPossibleMatches().Any(item => item.Type == TileType.right)) &&
                        !(Player.ShipLocation == Location.right && !CheckPossibleMatches().Any(item => item.Type == TileType.left)) &&
                        !(Player.ShipLocation == Location.middle && !CheckPossibleMatches().Any(item => item.Type == TileType.left) && !CheckPossibleMatches().Any(item => item.Type == TileType.right)))
                    {
                        modifierTimer = 120;
                        ToAdd.Add(new Rock(Player, this));
                    }
                }
                if (HasModifier(Modifier.Sun))
                {
                    modifierTimer--;
                    if (modifierTimer < 0 && Globals.Randomizer.Next(0, 1001) < 3)
                    {
                        modifierTimer = 120;
                        CombatText("The sun is heating up!");
                        Player.SetDamageOverTime(3, 6, 0);
                        if (GameObjects.Any(item => item is Enemy))
                        {
                            Enemy enemy = (Enemy)GameObjects.First(item => item is Enemy);
                            enemy.SetDamageOverTime(1, 6, 0);
                        }
                    }
                }
                if (HasModifier(Modifier.Satellite))
                {
                    Player.Energy.Change(0.04f);
                }
                if (HasModifier(Modifier.BlackHole))
                {
                    modifierTimer--;
                    if (modifierTimer < 0 && Globals.Randomizer.Next(0, 1001) < 4)
                    {
                        modifierTimer = 300;
                        CombatText("The tiles are heating up!");
                        for (int i = 0; i < Globals.Randomizer.Next(3, 7); i++)
                        {
                            while (true)
                            {
                                Point randomTile  = new Point(Globals.Randomizer.Next(0, BoardSize.X), Globals.Randomizer.Next(0, BoardSize.Y));
                                Point randomTile2 = new Point(Globals.Randomizer.Next(0, BoardSize.X), Globals.Randomizer.Next(0, BoardSize.Y));
                                while (randomTile.X == randomTile2.X && randomTile.Y == randomTile2.Y)
                                {
                                    randomTile2 = new Point(Globals.Randomizer.Next(0, BoardSize.X), Globals.Randomizer.Next(0, BoardSize.Y));
                                }
                                Tile temp = Tiles[randomTile.X][randomTile.Y];
                                Tiles[randomTile.X][randomTile.Y]   = Tiles[randomTile2.X][randomTile2.Y];
                                Tiles[randomTile2.X][randomTile2.Y] = temp;
                                if (!CheckSingleMatch(randomTile.X, randomTile.Y, Tiles) && !CheckSingleMatch(randomTile2.X, randomTile2.Y, Tiles))
                                {
                                    break;
                                }
                                else
                                {
                                    Tiles[randomTile2.X][randomTile2.Y] = Tiles[randomTile.X][randomTile.Y];
                                    Tiles[randomTile.X][randomTile.Y]   = temp;
                                }
                            }
                        }
                    }
                }
            }
            else if (Globals.KState.IsKeyDown(Keys.Enter))
            {
                Started = true;
            }

            // Game objects
            foreach (GameObject go in GameObjects)
            {
                go.UpdateLevel(this);
            }

            // Add
            foreach (GameObject toAdd in ToAdd)
            {
                GameObjects.Add(toAdd);
            }
            ToAdd.Clear();

            // Remove
            for (int i = GameObjects.Count - 1; i >= 0; i--)
            {
                if (GameObjects[i].Dead && !(GameObjects[i] is Player))
                {
                    if (GameObjects[i] is Enemy)
                    {
                        Player.GainExperience((int)EnemyDifficulty * 45 + 50 + Globals.Randomizer.Next(5, 10));
                        if (Rewards.Count() > 0)
                        {
                            foreach (Item reward in Rewards)
                            {
                                Player.AddItem(reward);
                            }
                            SceneManager.mapScene.NewItems.Flash = 10;
                        }
                        Player.Move = true;
                        Player.Health.Change(1);
                    }
                    GameObjects.RemoveAt(i);
                }
            }

            // Infobuttons
            ModuleInfo.Update();
            TileboardInfo.Update();
            EnergyInfo.Update();

            // Flee
            Flee.Update();
            if (Flee.Press() && EnemyDifficulty != Difficulty.Boss)
            {
                if (Player.ItemInInventory("Flee"))
                {
                    Player.GetItemInInventory("Flee").UseItem(Player, Player.GetItemInInventory("Flee"));
                }
            }
            if (Player.OutsideScreen())
            {
                Player.Move      = false;
                Player.Speed     = 0;
                Player.Position  = new Vector2(300, Globals.ScreenSize.Y - Player.Texture.Height);
                Player.Direction = Player.StandardDirection;
                LeaveLevel(GameObjects.Any(item => item is Enemy));
                Player.BonusDamageOneFight = 0;
            }
        }
示例#8
0
 public void CombatText(string text)
 {
     ToAdd.Add(new Text(new Vector2(Globals.CombatScreenSize.X / 2, Globals.CombatScreenSize.Y / 2), text, Color.Red, 180, 1.5f, false, TextureManager.SpriteFont20));
 }
示例#9
0
        public void Draw(Vector3 playerpos)
        {
            this.playerpos = playerpos;
            AllocateLists();
            //Create display lists, which were saved with Add() call
            //in another thread.
            lock (toadd)
            {
                while (toadd.Count > 0)
                {
                    ToAdd t = toadd.Dequeue();
                    GL.NewList(GetList(t.id), ListMode.Compile);

                    GL.EnableClientState(EnableCap.TextureCoordArray);
                    GL.EnableClientState(EnableCap.VertexArray);
                    GL.EnableClientState(EnableCap.ColorArray);
                    unsafe
                    {
                        fixed(VertexPositionTexture *p = t.vertices)
                        {
                            GL.VertexPointer(3, VertexPointerType.Float, StrideOfVertices, (IntPtr)(0 + (byte *)p));
                            GL.TexCoordPointer(2, TexCoordPointerType.Float, StrideOfVertices, (IntPtr)(12 + (byte *)p));
                            GL.ColorPointer(4, ColorPointerType.UnsignedByte, StrideOfVertices, (IntPtr)(20 + (byte *)p));
                            GL.DrawElements(BeginMode.Triangles, t.indicesCount, DrawElementsType.UnsignedShort, t.indices);
                        }
                    }
                    GL.DisableClientState(EnableCap.TextureCoordArray);
                    GL.DisableClientState(EnableCap.VertexArray);
                    GL.DisableClientState(EnableCap.ColorArray);

                    GL.EndList();
                    ListInfo li = GetListInfo(t.id);
                    li.indicescount = t.indicesCount;
                    li.center       = t.center;
                    li.radius       = t.radius;
                    li.transparent  = t.transparent;
                    li.empty        = false;
                    li.texture      = GetTextureId(t.texture);
                }
            }
            UpdateCulling();

            //Group display lists by used texture to minimize
            //number of GL.BindTexture() calls.
            SortListsByTexture();

            //Need to first render all solid lists (to fill z-buffer), then transparent.
            for (int i = 0; i < texturesCount; i++)
            {
                if (tocallSolid[i].Count == 0)
                {
                    continue;
                }
                if (BindTexture)
                {
                    GL.BindTexture(TextureTarget.Texture2D, glTextures[i]);
                }
                GL.CallLists(tocallSolid[i].Count, ListNameType.Int, tocallSolid[i].Lists);
            }
            GL.Disable(EnableCap.CullFace);//for water.
            for (int i = 0; i < texturesCount; i++)
            {
                if (tocallTransparent[i].Count == 0)
                {
                    continue;
                }
                if (BindTexture)
                {
                    GL.BindTexture(TextureTarget.Texture2D, glTextures[i]);
                }
                GL.CallLists(tocallTransparent[i].Count, ListNameType.Int, tocallTransparent[i].Lists);
            }
            GL.Enable(EnableCap.CullFace);
        }
 public void SetUserRole(UserRole model)
 {
     ToAdd.Add(model.RoleId);
 }
示例#11
0
 public void AddShot(Shot shot)
 {
     ToAdd.Add(shot);
 }
示例#12
0
文件: SystemMap.cs 项目: dncep/Woofer
 public void Add(ComponentSystem system)
 {
     ToAdd.Add(system);
 }