Пример #1
0
        public bool CollideRight(SquareObject sq, bool isLazer = false)
        {
            int counter = 0;

            if (isLazer)
            {
                return(false);
            }
            HitRight = true;

            Velocity = new Vector2(-Math.Abs(Velocity.X / 5f) - (0.1f * sq.bounce.Left), Velocity.Y / (1.03f + (0.0015f * sq.frictionforce)));


            while (rect.Intersects(sq.LeftEdge))
            {
                counter++;
                if (counter > 0x1388)
                {
                    return(true);
                }
                Position -= new Vector2(0.01f, 0f);
            }

            //if (Velocity.X > 0)
            //    Velocity = new Vector2(sq.Position.X - this.rect.Right, Velocity.Y);
            //Position -= new Vector2(0.01f, 0f);
            Position += new Vector2(sq.Position.X - this.rect.Right, 0);

            return(false);
        }
Пример #2
0
        public static void Update_Static()
        {
            string texture = Textures.LabelTextToStaticTexture(EditorPauseMenu.LabelList[0].Text);

            BrushSize    = int.Parse(EditorPauseMenu.LabelList[3].Text, CultureInfo.InvariantCulture);
            CurrentBlock = new SquareObject(texture, new Vector2(80f, 420f), 0.98f, 0.25f);
        }
Пример #3
0
 public PPlayer(string texture, string walktexture, string jumptexture, float size)
 {
     this._JumpAnim = jumptexture;
     this.sqobject  = new SquareObject(texture, new Vector2(400f, 300f), 0.85f, size);
     this._WalkAnim = walktexture;
     DeathCountdown = -1;
 }
Пример #4
0
        public static void Draw(SpriteBatch spriteBatch, GameTime gameTime, bool IsHidingUI)
        {
            if (ScreenManager.Ingame || (ScreenManager.Paused && !ScreenManager.Editing))
            {
                if (ScreenManager.Paused)
                {
                    if (!IsHidingUI)
                    {
                        PauseMenu.Draw(spriteBatch);
                    }
                }
                Level.DrawBackground(spriteBatch);
                if (PPlayer.DeathCountdown != 0)
                {
                    PPlayer.Player.Draw(spriteBatch, gameTime);
                    SquareObject.DrawSquares(SquareObject.sqObjectArray, spriteBatch, 17, 16);

                    foreach (Entity entity in Entity.EntityList)
                    {
                        if (entity.Active)
                        {
                            entity.Draw(spriteBatch, gameTime);
                        }
                    }
                    if (MessageBox.GameMessage != null)
                    {
                        if (!IsHidingUI)
                        {
                            MessageBox.GameMessage.Draw(spriteBatch);
                        }
                    }
                    for (int w = 0; w < Checkpoint.checkpointList.Count; w++)
                    {
                        if (((Checkpoint.checkpointList[w] != null) && (Vector2.Distance(Checkpoint.checkpointList[w].collectable.Position + Level.Offset, new Vector2(400f, 300f)) < 550f)) && (Checkpoint.checkpointList[w].collectable != null))
                        {
                            if (PPlayer.CurrentCheckpoint == Checkpoint.checkpointList[w].ID)
                            {
                                Checkpoint.checkpointList[w].collectable.Draw(spriteBatch, Color.Red);
                            }
                            else
                            {
                                Checkpoint.checkpointList[w].collectable.Draw(spriteBatch);
                            }
                        }
                    }
                    foreach (Collectable Cobject in Collectable.collectableList)
                    {
                        if ((Cobject != null) && (Vector2.Distance(Cobject.Position + Level.Offset, new Vector2(400f, 300f)) < 550f))
                        {
                            Cobject.Draw(spriteBatch);
                        }
                    }
                    for (int i = 0; i < Level.ChaliceList.Count; i++)
                    {
                        Level.ChaliceList[i].Draw(spriteBatch);
                    }
                }
            }
        }
Пример #5
0
        public static void Update_Items()
        {
            string item = EditorPauseMenu.LabelList[0].Text;

            BrushSize = int.Parse(EditorPauseMenu.LabelList[3].Text, CultureInfo.InvariantCulture);
            if (item != null)
            {
                if (item != "Player")
                {
                    if (item == "Chalice")
                    {
                        CurrentBlock       = new SquareObject("Chalice", new Vector2(80f, 420f), 0.98f, 0.8f);
                        CurrentCollectable = null;
                    }
                    else if (item == "Checkpoint")
                    {
                        CurrentBlock       = new SquareObject("Checkpoint", new Vector2(80f, 420f), 0.98f, 0.5f);
                        CurrentCollectable = null;
                    }
                    else if (item == "Coaster")
                    {
                        CurrentBlock       = new SquareObject("Coaster", new Vector2(80f, 420f), 0.98f, 1);
                        CurrentCollectable = null;
                    }
                    else if (item == "Sign")
                    {
                        CurrentCollectable = new Collectable("Sign", new Vector2(80f, 420f), 1f, 2, 0.91f);
                        CurrentBlock       = null;
                    }
                    else if (item == "RedKey")
                    {
                        CurrentBlock       = new SquareObject("RedKey", new Vector2(80f, 420f), 0.98f, 1);
                        CurrentCollectable = null;
                    }
                    else if (item == "BlueKey")
                    {
                        CurrentBlock       = new SquareObject("BlueKey", new Vector2(80f, 420f), 0.98f, 1);
                        CurrentCollectable = null;
                    }
                    else if (item == "GreenKey")
                    {
                        CurrentBlock       = new SquareObject("GreenKey", new Vector2(80f, 420f), 0.98f, 1);
                        CurrentCollectable = null;
                    }
                    else if (item == "YellowKey")
                    {
                        CurrentBlock       = new SquareObject("YellowKey", new Vector2(80f, 420f), 0.98f, 1);
                        CurrentCollectable = null;
                    }
                }
                else
                {
                    CurrentBlock       = new SquareObject("A", new Vector2(80f, 420f), 0.98f, 1f);
                    CurrentCollectable = null;
                }
            }
        }
Пример #6
0
 private bool LeftSquareCollision(SquareObject squareobject, bool isLazer = false)
 {
     if (this.sqobject.LeftEdge.Intersects(squareobject.RightEdge) && !sqobject.HitLeft)
     {
         this.sqobject.CollideLeft(squareobject, isLazer);
         this.VariableB = 180f;
         return(true);
     }
     return(false);
 }
Пример #7
0
 private bool RightSquareCollision(SquareObject squareobject, bool isLazer = false)
 {
     if (sqobject.rect.Intersects(squareobject.LeftEdge) && !sqobject.HitRight)
     {
         sqobject.CollideRight(squareobject, isLazer);
         VariableB = 180f;
         return(true);
     }
     return(false);
 }
Пример #8
0
        private bool TopSquareCollision(SquareObject squareobject, bool isLazer = false)
        {
            if (this.sqobject.TopEdge.Intersects(squareobject.BottomEdge))
            {
                this.VariableA = 180f;
                this.sqobject.CollideTop(squareobject, isLazer);
                return(true);
            }

            return(false);
        }
Пример #9
0
        public Entity(string texture, string jumpAnimation, string walkAnimation, Vector2 position, int lives, float size,
                      string job, SquareObject.Damage dmg, SquareObject.Bounce bnce, float speed, int friction, string OppositeDir,
                      bool staticTexture, int id, byte startCheckpoint, byte endCheckpoint, Color?colour = null, int startDelay = 0)
        {
            if (colour == null)
            {
                colour = Color.White;
            }
            if (job == "Lazer")
            {
                Sounds.Play("lazer", position);
            }
            StartPoint = position;
            _lives     = lives;
            Job        = job;
            sqobject   = new SquareObject(texture, position, dmg, bnce, 0.9f, size, friction, (Color)colour);
            Speed      = speed;
            _walkAnim  = walkAnimation;
            _jumpAnim  = jumpAnimation;
            if (OppositeDir == "t")
            {
                this.sqobject.Flipeffect = SpriteEffects.FlipHorizontally;
            }
            this.StaticTexture = staticTexture;
            this.ID            = id;
            Active             = true;

            DeathTimer         = -1;
            StartDelay         = startDelay;
            PreviousStartDelay = startDelay;
            JumpTimeout        = -1;
            MaxID        = 1;
            VariableA    = 0f;
            VariableB    = 0f;
            VariableC    = 0f;
            VariableD    = 0f;
            VariableE    = -1;
            VariableF    = 0;
            OnGround     = false;
            Walking      = false;
            timer        = -1;
            currentFrame = 0;

            SaveStatus();
            OriginalColour     = sqobject.Colour;
            OriginalFlipEffect = this.sqobject.Flipeffect;

            StartCheckpoint = startCheckpoint;
            EndCheckpoint   = endCheckpoint;

            TopEdgePlus = new Rectangle(this.sqobject.TopEdge.X, this.sqobject.TopEdge.Y - 20, this.sqobject.TopEdge.Width, this.sqobject.TopEdge.Height + 20);
        }
Пример #10
0
 public static void Reset()
 {
     CurrentBlock        = null;
     CurrentCollectable  = null;
     CurrentEntity       = null;
     MovingEntity        = false;
     SelectedBlock       = null;
     SelectedCheckpoint  = -1;
     SelectedEntity      = -1;
     SelectedCollectable = -1;
     Mouse_Move          = true;
     BrushSize           = 1;
 }
Пример #11
0
 public bool RightSquareCollision(SquareObject sq)
 {
     if (Player.MiddleRectangle.Intersects(sq.LeftEdge) || this.ArmsRectangle.Intersects(sq.LeftEdge))
     {
         if (this.sqobject.CollideRight(sq) || sq.damage.Left)
         {
             this.Die();
         }
         this.sqobject.HitRight = true;
         return(true);
     }
     return(false);
 }
Пример #12
0
        private bool BottomSquareCollision(SquareObject squareobject, bool isLazer = false)
        {
            if (sqobject.BottomEdge.Intersects(squareobject.TopEdge))
            {
                //if ((this.sqobject.rect.Bottom) - squareobject.Position.Y <= 5)
                {
                    this.Walking  = true;
                    this.OnGround = true;
                    this.sqobject.CollideBottom(squareobject, isLazer);
                    this.VariableA = 180f;
                    return(true);
                }
            }

            return(false);
        }
Пример #13
0
        public bool CollideBottom(SquareObject sq, bool isLazer = false)
        {
            int counter = 0;

            if (isLazer)
            {
                return(false);
            }
            HitFeet = true;


            if (this.Velocity.Y >= sq.Velocity.Y || sq.bounce.Top > 0)
            {
                Velocity = new Vector2(Velocity.X, Math.Abs(Velocity.Y / 8f) - (0.1f * sq.bounce.Top));
            }

            if (this.Velocity.Y < sq.Velocity.Y && sq.bounce.Top <= 0)
            {
                Velocity = new Vector2(Velocity.X, sq.Velocity.Y);
            }


            if ((Velocity.X > (0.001f * sq.frictionforce)) || (Velocity.X < (-0.001f * sq.frictionforce)))
            {
                Velocity -= new Vector2((Math.Sign(Velocity.X) * 0.001f) * sq.frictionforce, 0);
            }
            else
            {
                Velocity = new Vector2(0, Velocity.Y);
            }


            while (this.rect.Intersects(sq.TopEdge))
            {
                Position -= new Vector2(0, 0.01f);
                counter++;
                if (counter > 0x1388)
                {
                    return(true);
                }
            }
            return(false);
        }
Пример #14
0
        public static bool Static_ClickCheck(int x, int y)
        {
            if (((((x >= 0) && (x <= SquareObject.sqObjectArray.GetLength(0))) && (y >= 0)) && (y <= SquareObject.sqObjectArray.GetLength(1))) && ((SelectedCollectable == -1) && (SelectedEntity == -1)))
            {
                if ((SquareObject.sqObjectArray[x, y] != null) && (SelectedBlock == null))
                {
                    if (SquareObject.sqObjectArray[x, y].texturename == "Checkpoint")
                    {
                        for (int i = 0; i < Checkpoint.checkpointList.Count; i++)
                        {
                            if (Checkpoint.checkpointList[i].ID == SquareObject.sqObjectArray[x, y].frictionforce)
                            {
                                Checkpoint.checkpointList.RemoveAt(i);
                                break;
                            }
                        }
                    }
                    SelectedBlock = SquareObject.sqObjectArray[x, y];
                    SquareObject.sqObjectArray[x, y] = null;

                    return(true);
                }
                if (SelectedBlock != null)
                {
                    if (SelectedBlock.texturename == "A")
                    {
                        foreach (Checkpoint checkpoint in Checkpoint.checkpointList)
                        {
                            if (checkpoint.ID == 0)
                            {
                                checkpoint.collectable.Position = new Vector2(x * 25f, y * 25f);
                            }
                        }
                    }
                    PlaceBlock(SelectedBlock, x, y);
                    SelectedBlock = null;
                    return(true);
                }
            }
            return(false);
        }
Пример #15
0
 public static void Draw(SpriteBatch spriteBatch, GameTime gameTime, bool IsHidingUI)
 {
     if (ScreenManager.Editing && !ScreenManager.Levelselect)
     {
         DrawBackGrounds(spriteBatch, IsHidingUI);
         if (PPlayer.DeathCountdown < 0)
         {
             SquareObject.DrawSquares(SquareObject.sqObjectArray, spriteBatch, 17, 16);
             DrawEntities(spriteBatch, gameTime);
             if (!IsHidingUI)
             {
                 DrawMisc(spriteBatch);
             }
             DrawCollectables(spriteBatch);
             if (!IsHidingUI)
             {
                 DrawAttachedItems(spriteBatch);
             }
         }
     }
 }
Пример #16
0
        public bool CollideTop(SquareObject sq, bool isLazer = false)
        {
            int counter = 0;

            if (isLazer)
            {
                return(false);
            }
            HitHead = true;


            Velocity = new Vector2(Velocity.X, Math.Abs(Velocity.Y / 8f) + (0.1f * sq.bounce.Bottom));


            if ((Velocity.X > (0.002f * sq.frictionforce)) || (Velocity.X < (-0.002f * sq.frictionforce)))
            {
                Velocity -= new Vector2((Math.Sign(Velocity.X) * 0.002f) * sq.frictionforce, 0f);
            }
            else
            {
                Velocity = new Vector2(0f, Velocity.Y);
            }

            //if (Velocity.Y < 0)
            //    Velocity = new Vector2(Velocity.X, this.Position.Y - sq.rect.Bottom);
            //Position += new Vector2(0, Math.Abs(Velocity.Y));
            this.Position += new Vector2(0, sq.rect.Bottom - this.Position.Y + 0.01f);


            while (rect.Intersects(sq.BottomEdge))
            {
                Position += new Vector2(0f, 0.1f);
                counter++;
                if (counter > 0x1388)
                {
                    return(true);
                }
            }
            return(false);
        }
Пример #17
0
        public bool TopSquareCollision(SquareObject sq)
        {
            if (this.MiddleRectangle.Intersects(sq.BottomEdge) && !this.MiddleRectangle.Intersects(sq.TopEdge))
            {
                if (Player.sqobject.CollideTop(sq) || sq.damage.Bottom)
                {
                    this.Die();
                }
                return(true);
            }

            /*if (!sqobject.HitHead && !Walking)
             * {
             *  if (sqobject.TopEdge.Intersects(sq.rect))
             *  {
             *      while (sqobject.TopEdge.Intersects(sq.rect))
             *          sqobject.Position += new Vector2(0, 0.01f);
             *      sqobject.HitHead = true;
             *  }
             * }
             */
            return(false);
        }
Пример #18
0
        public bool BottomSquareCollision(SquareObject sq)
        {
            if (this.MiddleRectangle.Intersects(sq.TopEdge) && !this.MiddleRectangle.Intersects(sq.BottomEdge))
            {
                if ((this.sqobject.rect.Bottom) - sq.Position.Y <= 10)
                {
                    this.OnGround = true;
                    if (Player.sqobject.CollideBottom(sq) || sq.damage.Top)
                    {
                        this.Die();
                    }
                    if ((InputManager.Keystate[0].IsKeyDown(Keys.W) || InputManager.Keystate[0].IsKeyDown(Keys.Up)) && (sq.bounce.Top > 0f))
                    {
                        this.sqobject.Velocity += new Vector2(0f, -(2f + (0.02f * sq.bounce.Top)));
                        this.OnGround           = false;
                    }
                    Player.sqobject.frictionforce = sq.frictionforce;
                    this.sqobject.HitFeet         = true;

                    return(true);
                }
            }

            /*
             * if (!sqobject.HitFeet && !Walking)
             * {
             *  if (sqobject.BottomEdge.Intersects(sq.rect))
             *  {
             *      while (sqobject.BottomEdge.Intersects(sq.rect))
             *          sqobject.Position -= new Vector2(0, 0.01f);
             *      sqobject.HitFeet = true;
             *  }
             * }
             */
            return(false);
        }
Пример #19
0
        public static void MoveAllObjects(int deltaX, int deltaY)
        {
            Vector2 positionDelta = new Vector2(25 * deltaX, 25 * deltaY);

            SquareObject[,] sq = new SquareObject[2000, 2000];
            for (int i = Math.Max(0, -deltaX); i < Math.Min(2000, SquareObject.sqObjectArray.GetLength(0) - deltaX); i++)
            {
                for (int j = Math.Max(0, -deltaY); j < Math.Min(2000, SquareObject.sqObjectArray.GetLength(1) - deltaY); j++)
                {
                    sq[i + deltaX, j + deltaY] = SquareObject.sqObjectArray[i, j];
                    if (sq[i + deltaX, j + deltaY] != null)
                    {
                        sq[i + deltaX, j + deltaY].Position = sq[i + deltaX, j + deltaY].Position + positionDelta;
                    }
                }
            }
            SquareObject.sqObjectArray = sq;

            foreach (Checkpoint checkpoint in Checkpoint.checkpointList)
            {
                checkpoint.collectable.Position = checkpoint.collectable.Position + positionDelta;
            }

            foreach (Collectable chalice in ChaliceList)
            {
                chalice.Position = chalice.Position + positionDelta;
            }
            foreach (Collectable collectable in Collectable.collectableList)
            {
                collectable.Position = collectable.Position + positionDelta;
            }
            foreach (Entity entity in Entity.EntityList)
            {
                entity.sqobject.Position = entity.sqobject.Position + positionDelta;
            }
        }
Пример #20
0
        public bool CollideLeft(SquareObject sq, bool isLazer = false)
        {
            if (isLazer)
            {
                return(false);
            }
            HitLeft = true;

            Velocity = new Vector2(Math.Abs(Velocity.X / 5f) + (0.1f * sq.bounce.Right), Velocity.Y / (1.03f + (0.0015f * sq.frictionforce)));


            /*while (rect.Intersects(sq.RightEdge))
             * {
             *  Position += new Vector2(0.01f, 0f);
             *  counter++;
             *  if (counter > 0x1388)
             *  {
             *      return true;
             *  }
             * }*/

            Position += new Vector2(sq.rect.Right - this.Position.X, 0);
            return(false);
        }
Пример #21
0
        public static void PlaceBlock(SquareObject sq, int x, int y)
        {
            if ((((((x >= 0) && (x <= (SquareObject.sqObjectArray.GetLength(0) - 1))) && (y >= 0)) && (y <= (SquareObject.sqObjectArray.GetLength(1) - 1))) && (!mouse_Static || (CurrentBlock != null))) && ((SquareObject.sqObjectArray[x, y] == null) || (SquareObject.sqObjectArray[x, y].texturename != "A")))
            {
                if (sq.texturename == "Checkpoint")
                {
                    if (SquareObject.sqObjectArray[x, y] != null &&
                        SquareObject.sqObjectArray[x, y].texturename == "Checkpoint")
                    {
                        return;
                    }

                    for (int id = 1; id < 99999; id++)
                    {
                        bool flag = false;
                        foreach (Checkpoint check in Checkpoint.checkpointList)
                        {
                            if (id == check.ID)
                            {
                                flag = true;
                            }
                        }
                        if (!flag)
                        {
                            Checkpoint.checkpointList.Add(new Checkpoint(new Collectable("Checkpoint", new Vector2(x * 0x19, y * 0x19), 0, 1, 0), id));
                            SquareObject.sqObjectArray[x, y] = new SquareObject("Checkpoint", new Vector2(x * 0x19, y * 0x19), 0.039f, 0.5f, id);
                            return;
                        }
                    }
                }
                SquareObject.sqObjectArray[x, y] = null;
                if (sq.texturename == "e") //Lava
                {
                    SquareObject.sqObjectArray[x, y] = new SquareObject(sq.texturename, new Vector2((float)(x * 0x19), (float)(y * 0x19)) + new Vector2(0f, 5f), 0.039f, 0.25f);
                }
                if (sq.texturename == "j") //SpikesUP
                {
                    SquareObject.sqObjectArray[x, y] = new SquareObject(sq.texturename, new Vector2((float)(x * 0x19), (float)(y * 0x19)) + new Vector2(0f, 10f), 0.039f, 0.25f);
                }
                if (sq.texturename == "l") //SpikesLEFT
                {
                    SquareObject.sqObjectArray[x, y] = new SquareObject(sq.texturename, new Vector2((float)(x * 0x19), (float)(y * 0x19)) + new Vector2(10f, 0f), 0.039f, 0.25f);
                }
                if (sq.texturename == "n") //Bouncer
                {
                    SquareObject.sqObjectArray[x, y] = new SquareObject(sq.texturename, new Vector2((float)(x * 0x19), (float)(y * 0x19)) + new Vector2(0f, 7.5f), 0.039f, 0.25f);
                }
                if (sq.texturename == "Coaster")
                {
                    int coastersPlaced = 0;
                    foreach (SquareObject square in SquareObject.sqObjectArray)
                    {
                        if (square != null)
                        {
                            if (square.texturename == "Coaster")
                            {
                                coastersPlaced++;
                            }
                        }
                    }
                    if (coastersPlaced == 3)
                    {
                        MessageBox.StatusMessage = new MessageBox("3 coasters have been placed already. You can't place more than 3 in one level.", new Vector2(50, 50), 150);
                        return;
                    }
                    else
                    {
                        coastersPlaced++;
                        MessageBox.StatusMessage = new MessageBox(coastersPlaced.ToString() + " Coasters Placed Now!", new Vector2(50, 50), 150);
                    }
                }
                if (SquareObject.sqObjectArray[x, y] == null)
                {
                    SquareObject.sqObjectArray[x, y] = new SquareObject(sq.texturename, new Vector2((float)(x * 0x19), (float)(y * 0x19)), 0.4f, sq.Size);
                }
            }
        }
Пример #22
0
        private void CheckSquareCollisions(int x, int y)
        {
            try
            {
                if (this.sqobject.rect.Intersects(SquareObject.sqObjectArray[x, y].rect))
                {
                    SquareObject sq = SquareObject.sqObjectArray[x, y];
                    if (this.sqobject.Velocity.Y >= 0 && !sqobject.HitFeet)
                    {
                        if (y == 0)
                        {
                            this.BottomSquareCollision(sq);
                        }
                        else if (SquareObject.sqObjectArray[x, y - 1] == null)
                        {
                            this.BottomSquareCollision(sq);
                        }
                    }

                    if (this.sqobject.Velocity.Y <= Level.Gravity.Y / 2 && !sqobject.HitHead)
                    {
                        if (y > (SquareObject.sqObjectArray.GetLength(1) - 1))
                        {
                            this.TopSquareCollision(sq);
                        }
                        else if (SquareObject.sqObjectArray[x, y + 1] == null)
                        {
                            this.TopSquareCollision(sq);
                        }
                    }

                    if (x == 0 && !sqobject.HitLeft)
                    {
                        this.RightSquareCollision(sq);
                    }
                    else if (SquareObject.sqObjectArray[x - 1, y] == null)
                    {
                        this.RightSquareCollision(sq);
                    }
                    else if (SquareObject.sqObjectArray[x - 1, y].texturename.Contains("Spk"))
                    {
                        this.RightSquareCollision(sq);
                    }

                    if (x == (SquareObject.sqObjectArray.GetLength(0)) && !sqobject.HitRight)
                    {
                        this.LeftSquareCollision(sq);
                    }
                    else if (SquareObject.sqObjectArray[x + 1, y] == null)
                    {
                        this.LeftSquareCollision(sq);
                    }
                    else if (SquareObject.sqObjectArray[x + 1, y].texturename.Contains("Spk"))
                    {
                        this.LeftSquareCollision(sq);
                    }
                }
            }
            catch (Exception e)
            {
                ErrorReporter.LogException(new string[] { "Failed to check static collisions for an entity", e.Message, "MethodName = " + e.TargetSite.Name, e.StackTrace });
                throw e;
            }
        }
Пример #23
0
        public static void LoadStaticObjects(XmlDocument doc)
        {
            XmlNode node = doc.DocumentElement;

            Objectdata[] datalist = new Objectdata[0];
            if (node != null)
            {
                datalist = GetStaticObjectData(node.FirstChild.NextSibling.NextSibling);
            }
            if (datalist != null)
            {
                try
                {
                    SquareObject[,] sq = new SquareObject[((int)datalist[0].Position.X) + 1, ((int)datalist[0].Position.Y) + 1];
                    if (ScreenManager.Editing)
                    {
                        sq = new SquareObject[2000, 2000];
                    }
                    Collectable.collectableList = new List <Collectable>();
                    Checkpoint.checkpointList   = new List <Checkpoint>();
                    Level.ChaliceList           = new List <Collectable>();

                    for (int i = 1; i < (datalist.Length - 1); i++)
                    {
                        Objectdata od = datalist[i];
                        int        x  = (int)od.Position.X;
                        int        y  = (int)od.Position.Y;
                        byte       q  = 0;
                        if (od.Texturename != null)
                        {
                            if (od.Texturename.StartsWith("Checkpoint") && byte.TryParse(od.Texturename.Substring(10), out q))
                            {
                                Collectable coll = new Collectable("Checkpoint", od.Position * 25f, 0.5f, 3, 0.5f);
                                Checkpoint.checkpointList.Add(new Checkpoint(coll, q));
                            }
                            else
                            {
                                switch (od.Texturename)
                                {
                                case "a":     //Grass
                                    sq[x, y] = new SquareObject("a", (Vector2)(od.Position * 25f), 0.04f, 0.25f, 85);
                                    break;

                                case "b":     //Soil
                                    sq[x, y] = new SquareObject("b", (Vector2)(od.Position * 25f), 0.04f, 0.25f, 60);
                                    break;

                                case "Mag":
                                    sq[x, y] = new SquareObject("Mag", (Vector2)(od.Position * 25f), 0.04f, 0.25f, 150);
                                    break;

                                case "UMag":
                                    sq[x, y] = new SquareObject("UMag", (Vector2)(od.Position * 25f), 0.04f, 0.25f, 150);
                                    break;

                                case "c":     //IceGrass
                                    sq[x, y] = new SquareObject("c", (Vector2)(od.Position * 25f), 0.04f, 0.25f, 10);
                                    break;

                                case "d":     //Ice
                                    sq[x, y] = new SquareObject("d", (Vector2)(od.Position * 25f), 0.04f, 0.25f, 1);
                                    break;

                                case "e":     //Lava
                                    sq[x, y] = new SquareObject("e", ((Vector2)(od.Position * 25f)) + new Vector2(0f, 5f), new SquareObject.Damage(1, 1, 1, 1), new SquareObject.Bounce(0, 0, 0, 0), 0.039f, 0.25f, 150, Color.White);
                                    break;

                                case "f":     //Magma
                                    sq[x, y] = new SquareObject("f", (Vector2)(od.Position * 25f), new SquareObject.Damage(1, 1, 1, 1), new SquareObject.Bounce(50, 30, 30, 30), 0.039f, 0.25f, 150, Color.White);
                                    break;

                                case "g":     //Sand
                                    sq[x, y] = new SquareObject("g", (Vector2)(od.Position * 25f), new SquareObject.Damage(0, 0, 0, 0), new SquareObject.Bounce(0, 0, 0, 0), 0.04f, 0.25f, 50, Color.White);
                                    break;

                                case "h":     //Metal
                                    sq[x, y] = new SquareObject("h", (Vector2)(od.Position * 25f), 0.04f, 0.25f, 60);
                                    break;

                                case "i":     //Gravel
                                    sq[x, y] = new SquareObject("i", (Vector2)(od.Position * 25f), 0.04f, 0.25f, 100);
                                    break;

                                case "j":     //SpikesUP
                                    sq[x, y] = new SquareObject("j", (od.Position * 25f) + new Vector2(0f, 10f), new SquareObject.Damage(1, 0, 0, 0), new SquareObject.Bounce(0, 0, 0, 0), 0.039f, 0.25f, 200, Color.White);
                                    break;

                                case "k":     //SpikesDOWN
                                    sq[x, y] = new SquareObject("k", od.Position * 25f, new SquareObject.Damage(0, 1, 0, 0), new SquareObject.Bounce(0, 0, 0, 0), 0.039f, 0.25f, 200, Color.White);
                                    break;

                                case "l":     //SpikesLEFT
                                    sq[x, y] = new SquareObject("l", od.Position * 25f + new Vector2(10f, 0f), new SquareObject.Damage(0, 0, 1, 0), new SquareObject.Bounce(0, 0, 0, 0), 0.039f, 0.25f, 200, Color.White);
                                    break;

                                case "m":     //SpikesRIGHT
                                    sq[x, y] = new SquareObject("m", od.Position * 25f, new SquareObject.Damage(0, 0, 0, 1), new SquareObject.Bounce(0, 0, 0, 0), 0.039f, 0.25f, 200, Color.White);
                                    break;

                                case "n":     //Bouncer
                                    sq[x, y] = new SquareObject("n", od.Position * 25f + new Vector2(0f, 7.5f), new SquareObject.Damage(0, 0, 0, 0), new SquareObject.Bounce(100, 0, 0, 0), 0.039f, 0.25f, 80, Color.White);
                                    break;


                                case "A":
                                    PPlayer.Player.sqobject.Position = od.Position * 25f;
                                    break;

                                case "Coaster":
                                {
                                    Collectable.collectableList.Add(new Collectable("Coaster", od.Position * 25f, 1, 4, 0.5f));
                                }
                                break;

                                case "Chalice":
                                {
                                    Level.ChaliceList.Add(new Collectable("Chalice", od.Position * 25f, 0.8f, 1, 0.65f));
                                    break;
                                }

                                case "RedKey":
                                {
                                    Collectable.collectableList.Add(new Collectable("RedKey", od.Position * 25f, 1, 5, 0.5f));
                                }
                                break;

                                case "BlueKey":
                                {
                                    Collectable.collectableList.Add(new Collectable("BlueKey", od.Position * 25f, 1, 6, 0.5f));
                                }
                                break;

                                case "GreenKey":
                                {
                                    Collectable.collectableList.Add(new Collectable("GreenKey", od.Position * 25f, 1, 7, 0.5f));
                                }
                                break;

                                case "YellowKey":
                                {
                                    Collectable.collectableList.Add(new Collectable("YellowKey", od.Position * 25f, 1, 8, 0.5f));
                                }
                                break;

                                default:
                                    Collectable.collectableList.Add(new Collectable("Sign", od.Position * 25f, 1f, 2, 0.5f, od.Texturename.TrimStart('{')));
                                    break;
                                }
                            }
                        }
                    }

                    Checkpoint.checkpointList.Add(new Checkpoint(new Collectable("", new Vector2(PPlayer.Player.sqobject.Position.X, PPlayer.Player.sqobject.Position.Y), 0f, 3, 0.5f), 0));
                    PPlayer.CurrentCheckpoint = 0;


                    PPlayer.Player.Setup();
                    SquareObject.sqObjectArray = sq;
                }
                catch (Exception e)
                {
                    ErrorReporter.LogException(new string[] { "Failed to load player and/or blocks", e.Message, "MethodName = " + e.TargetSite.Name, e.StackTrace });
                    throw e;
                }
            }
        }
Пример #24
0
        public static void Entity_ClickCheck()
        {
            for (int i = 0; i < Entity.EntityList.Count; i++)
            {
                if (Entity.EntityList[i] != null)
                {
                    if (MouseClick.Rect.Intersects(new Rectangle((int)(Entity.EntityList[i].sqobject.Position.X + Level.Offset.X), (int)(Entity.EntityList[i].sqobject.Position.Y + Level.Offset.Y), (int)(Entity.EntityList[i].sqobject.Texture.Width * Entity.EntityList[i].sqobject.Size), (int)(Entity.EntityList[i].sqobject.Texture.Height * Entity.EntityList[i].sqobject.Size))))
                    {
                        SelectedEntity      = i;
                        MovingEntity        = false;
                        Editor.LabelList    = new List <TextSprite>();
                        TextSprite.TextList = new List <TextSprite>();
                        Button.ButtonList   = new List <Button>();

                        TextSprite.TextList.Add(new TextSprite("Job:", "Tiny", new Vector2(550, 20), Color.White));
                        TextSprite.TextList.Add(new TextSprite("Start Direction:", "Tiny", new Vector2(550, 60), Color.White));
                        TextSprite.TextList.Add(new TextSprite("Checkpoint born:", "Tiny", new Vector2(550, 100), Color.White));
                        TextSprite.TextList.Add(new TextSprite("Checkpoint die:", "Tiny", new Vector2(550, 140), Color.White));
                        TextSprite.TextList.Add(new TextSprite("Start Delay:", "Tiny", new Vector2(550, 180), Color.White));

                        LabelList.Add(new TextSprite(Entity.EntityList[i].Job.Substring(1), "Tiny", new Vector2(650, 20), Color.White));
                        LabelList.Add(new TextSprite(GetDirection(Entity.EntityList[i]), "Tiny", new Vector2(650, 60), Color.White));
                        LabelList.Add(new TextSprite(Entity.EntityList[i].StartCheckpoint.ToString(), "Tiny", new Vector2(650, 100), Color.White));
                        LabelList.Add(new TextSprite(Entity.EntityList[i].EndCheckpoint.ToString(), "Tiny", new Vector2(650, 140), Color.White));
                        LabelList.Add(new TextSprite(Entity.EntityList[i].StartDelay.ToString(), "Tiny", new Vector2(650, 180), Color.White));

                        TextSprite ts = new TextSprite("+", "Small", new Vector2(740, 20), Color.Red);
                        Button.ButtonList.Add(new Button(ts, new Vector2(740, 20), 5));
                        ts = new TextSprite("-", "Small", new Vector2(760, 20), Color.Red);
                        Button.ButtonList.Add(new Button(ts, new Vector2(760, 20), 5));

                        ts = new TextSprite("+", "Small", new Vector2(740, 60), Color.Red);
                        Button.ButtonList.Add(new Button(ts, new Vector2(740, 60), 5));
                        ts = new TextSprite("-", "Small", new Vector2(760, 60), Color.Red);
                        Button.ButtonList.Add(new Button(ts, new Vector2(760, 60), 5));

                        ts = new TextSprite("+", "Small", new Vector2(740, 100), Color.Red);
                        Button.ButtonList.Add(new Button(ts, new Vector2(740, 100), 5));
                        ts = new TextSprite("-", "Small", new Vector2(760, 100), Color.Red);
                        Button.ButtonList.Add(new Button(ts, new Vector2(760, 100), 5));

                        ts = new TextSprite("+", "Small", new Vector2(740, 140), Color.Red);
                        Button.ButtonList.Add(new Button(ts, new Vector2(740, 140), 5));
                        ts = new TextSprite("-", "Small", new Vector2(760, 140), Color.Red);
                        Button.ButtonList.Add(new Button(ts, new Vector2(760, 140), 5));

                        ts = new TextSprite("+", "Small", new Vector2(740, 180), Color.Red);
                        Button.ButtonList.Add(new Button(ts, new Vector2(740, 180), 5));
                        ts = new TextSprite("-", "Small", new Vector2(760, 180), Color.Red);
                        Button.ButtonList.Add(new Button(ts, new Vector2(760, 180), 5));

                        ts = new TextSprite("Move", "Medium", Vector2.Zero, Color.Red);
                        Button.ButtonList.Add(new Button(ts, new Vector2(650, 220), 4));

                        return;
                    }
                }
            }
            if (SelectedEntity > -1 && MovingEntity)
            {
                SquareObject sq = Entity.EntityList[SelectedEntity].sqobject;
                Entity.EntityList[SelectedEntity].sqobject.Position = new Vector2(InputManager.Mousestate[0].X - (sq.Texture.Width * sq.Size), InputManager.Mousestate[0].Y - (sq.Texture.Height * sq.Size)) - Level.Offset;
                MovingEntity = false;
                return;
            }

            if (LabelList != null)
            {
                bool ButtonClicked = false;

                for (int i = 0; i < Button.ButtonList.Count; i++)
                {
                    if (Button.ButtonList[i].Rect.Intersects(MouseClick.Rect))
                    {
                        ButtonClicked = true;
                    }
                }

                if (!ButtonClicked)
                {
                    SelectedEntity      = -1;
                    MovingEntity        = false;
                    LabelList           = null;
                    Button.ButtonList   = new List <Button>();
                    TextSprite.TextList = new List <TextSprite>();
                }
            }
        }