Example #1
0
        private void Update_Physics_GL_Top(NetNavi_Type navi)
        {
            //Top
            int Top   = (int)(navi.Navi_Location().Top / 16);
            int Left  = (int)(navi.Navi_Location().Left / 16);
            int Right = (int)(navi.Navi_Location().Right / 16);

            //always does hightmap on tile colleciton
            for (int x = Left; x <= Right; x++)
            {
                RectangleF rct = navi.Navi_Location();
                if (stage.CollisionMap.ContainsKey(new Point(x, Top)))
                {
                    StageCollisionTile tile = stage.CollisionMap[new Point(x, Top)];
                    tile.Active = true;

                    //set to Top
                    if (rct.Top - (Top * 16 + 16) >= -1)
                    {
                        navi.Set_LocationY(Top * 16 + 16 + navi.Navi_Location().Height);
                        navi.Speed.Y        = 0;
                        navi.StepMovement.Y = 0;
                    }
                }
            }
        }
Example #2
0
        private void Update_Physics_GL_Left(NetNavi_Type navi)
        {
            //Top
            int Top    = (int)((navi.Navi_Location().Top + 2) / 16);
            int Bottom = (int)((navi.Navi_Location().Bottom - 2) / 16);
            int Left   = (int)(navi.Navi_Location().Left / 16);

            //always does hightmap on tile colleciton
            for (int y = Top; y <= Bottom; y++)
            {
                RectangleF rct = navi.Navi_Location();
                if (stage.CollisionMap.ContainsKey(new Point(Left, y)))
                {
                    StageCollisionTile tile = stage.CollisionMap[new Point(Left, y)];
                    tile.Active = true;

                    if (rct.Bottom - (y * 16 + 16 - tile.HeightRight) >= 4)
                    {
                        //set to Left
                        if (rct.Left - (Left * 16 + 16) >= -1)
                        {
                            navi.Set_LocationX(Left * 16 + 16);
                            navi.Speed.X        = 0;
                            navi.StepMovement.X = 0;
                        }
                    }
                }
            }
        }
Example #3
0
        private void Update_Physics_Projectiles_Hit_Host(Projectiles_Type p, NetNavi_Type navi)
        {
            if (p.Owner != "Host")
            {
                Point point = new Point((int)p.Location.X, (int)p.Location.Y);
                if (navi.Navi_Location().Contains(point))
                {
                    if (p.Speed.X < 0)
                    {
                        navi.Speed.X -= 15;
                    }
                    else
                    {
                        navi.Speed.X += 15;
                    }

                    Projectile_List.Remove(p);
                }
            }
        }
Example #4
0
        private void Update_Physics_GDI_Bounds(NetNavi_Type navi)
        {
            //Bounds
            if (navi.FaceLeft == true)
            {
                if (navi.Navi_Location().Left <= Screen.PrimaryScreen.WorkingArea.Left)
                {
                    navi.Location.X = Screen.PrimaryScreen.WorkingArea.Left - (navi.GetSize().X - navi.GetHitBox().Right); navi.Speed.X = 0;
                }
            }
            else
            {
                if (navi.Navi_Location().Left <= Screen.PrimaryScreen.WorkingArea.Left)
                {
                    navi.Location.X = Screen.PrimaryScreen.WorkingArea.Left - navi.GetHitBox().Left; navi.Speed.X = 0;
                }
            }

            if (navi.FaceLeft == true)
            {
                if (navi.Navi_Location().Right >= Screen.PrimaryScreen.WorkingArea.Right)
                {
                    navi.Location.X = Screen.PrimaryScreen.WorkingArea.Right - (navi.GetSize().X - navi.GetHitBox().Left); navi.Speed.X = 0;
                }
            }
            else
            {
                if (navi.Navi_Location().Right >= Screen.PrimaryScreen.WorkingArea.Right)
                {
                    navi.Location.X = Screen.PrimaryScreen.WorkingArea.Right - navi.GetHitBox().Right; navi.Speed.X = 0;
                }
            }

            if (navi.Navi_Location().Bottom > Screen.PrimaryScreen.WorkingArea.Bottom)
            {
                navi.Location.Y = Screen.PrimaryScreen.WorkingArea.Bottom - navi.GetHitBox().Bottom;
            }
            if (navi.Navi_Location().Bottom == Screen.PrimaryScreen.WorkingArea.Bottom)
            {
                navi.OnGround = true; navi.Speed.Y = 0;
            }
            else
            {
                navi.OnGround = false;
            }
        }
Example #5
0
        private void Update_Physics_GL_Bounds(NetNavi_Type navi)
        {
            bool OnGround = false;

            if (navi.Navi_Location().Left < 0)
            {
                navi.Set_LocationX(0); navi.Speed.X = 0; navi.StepMovement.X = 0;
            }

            if (navi.Navi_Location().Right > stage.Bounds.Width)
            {
                navi.Set_LocationX(stage.Bounds.Width - navi.Navi_Location().Width); navi.Speed.X = 0; navi.StepMovement.X = 0;
            }


            if (navi.Navi_Location().Bottom > stage.Bounds.Height)
            {
                navi.Location.Y = stage.Bounds.Height - navi.GetHitBox().Bottom;
            }
            if (navi.Navi_Location().Bottom == stage.Bounds.Height)
            {
                OnGround = true; navi.Speed.Y = 0; navi.StepMovement.Y = 0;
            }

            //Top bounds
            if (navi.Navi_Location().Top < 0)
            {
                navi.Location.Y = 0 - navi.GetHitBox().Top; navi.Speed.Y = 0; navi.StepMovement.Y = 0;
            }

            //CollisionMap
            foreach (StageCollisionTile tile in stage.CollisionMap.Values)
            {
                tile.Active = false;
            }

            Update_Physics_GL_Left(navi);
            Update_Physics_GL_Right(navi);

            Update_Physics_GL_Top(navi);
            Update_Physics_GL_Bottom(navi, OnGround);
        }
Example #6
0
        private void Update_Physics_GL_Bottom(NetNavi_Type navi, bool OnGround)
        {
            //Bottom
            int Top    = (int)(navi.Navi_Location().Top / 16);
            int Bottom = (int)(navi.Navi_Location().Bottom / 16);
            int Left   = (int)(navi.Navi_Location().Left / 16);
            int Right  = (int)(navi.Navi_Location().Right / 16);

            //always does hightmap on tile colleciton
            for (int y = Top; y <= Bottom; y++)
            {
                for (int x = Left; x <= Right; x++)
                {
                    //int x;//, y;
                    //x = Right;// y = Bottom;
                    RectangleF rct = navi.Navi_Location();
                    if (stage.CollisionMap.ContainsKey(new Point(x, y)))
                    {
                        StageCollisionTile tile = stage.CollisionMap[new Point(x, y)];
                        tile.Active = true;

                        //Slope collision with a center tile
                        float point, pointL, pointR, ratioL, ratioR;
                        point = 16;
                        if (x != Left && x != Right)
                        {
                            if (tile.HeightLeft > tile.HeightRight)
                            {
                                point = tile.HeightLeft;
                            }
                            else
                            {
                                point = tile.HeightRight;
                            }
                        }
                        else
                        //Slope collision with leftmost or rightmost tile
                        {
                            pointL = 16;
                            pointR = 16;

                            ratioR = (navi.Navi_Location().Right - x * 16) / 16;
                            ratioL = (navi.Navi_Location().Left - x * 16) / 16;
                            if (ratioL >= 0 && ratioL <= 1)
                            {
                                pointL = tile.HeightLeft + (tile.HeightRight - tile.HeightLeft) * ratioL;
                            }
                            if (ratioR >= 0 && ratioR <= 1)
                            {
                                pointR = tile.HeightLeft + (tile.HeightRight - tile.HeightLeft) * ratioR;
                            }
                            if (pointL < pointR)
                            {
                                point = pointL;
                            }
                            else
                            {
                                point = pointR;
                            }
                        }

                        //set to ground
                        if (rct.Bottom > (y * 16) + 16 - point)
                        {
                            if (rct.Bottom - (y * 16) - (16 - point) <= 4)
                            {
                                if (navi.Navi_Location().Top < (y * 16 + (16 - point)))
                                {
                                    navi.Set_LocationY(y * 16 + (16 - point));
                                    navi.Speed.Y        = 0;
                                    navi.StepMovement.Y = 0;
                                    OnGround            = true;
                                }
                            }
                        }

                        if (navi.Navi_Location().Bottom + 1 >= (y * 16) + 16 - point)
                        {
                            OnGround = true;
                        }
                    }
                    navi.OnGround = OnGround;
                }
            }
        }
Example #7
0
        public void Process_Navi_Commands()
        {
            if (Direct_Control == false)
            {
                if (Math.Abs(targetlocation - Host_Navi.Navi_Location().Left) > 100)
                {
                    Host_Navi.Running = true;
                }
                else
                {
                    Host_Navi.Running = false;
                }

                if (Host_Navi.Navi_Location().Right <= targetlocation)
                {
                    Host_Navi.FaceLeft = false;
                }
                if (Host_Navi.Navi_Location().Left >= targetlocation)
                {
                    Host_Navi.FaceLeft = true;
                }
            }


            #region Movement
            //Move Navies
            if (Host_Navi.OnGround == true)
            {
                if (Host_Navi.Running == true)
                {
                    //Check for dashing
                    if (Host_Navi.Dashing == true)
                    {
                        //Dashing
                        if (Host_Navi.FaceLeft == true)
                        {
                            Host_Navi.Speed.X -= Host_Navi.DashSpeed;
                        }
                        else
                        {
                            Host_Navi.Speed.X += Host_Navi.DashSpeed;
                        }
                    }
                    else
                    {
                        //Running
                        if (Host_Navi.FaceLeft == true)
                        {
                            Host_Navi.Speed.X -= Host_Navi.GroundSpeed;
                        }
                        else
                        {
                            Host_Navi.Speed.X += Host_Navi.GroundSpeed;
                        }
                    }
                }
                //Jumping
                if (Host_Navi.Jumping == true && Host_Navi.HasJumped == true)
                {
                    Host_Navi.Speed.Y -= Host_Navi.Acrobatics; Host_Navi.HasJumped = false;
                }
            }
            else
            {
                //Air moving
                if (Host_Navi.Running == true)
                {
                    if (Host_Navi.FaceLeft == true)
                    {
                        Host_Navi.Speed.X -= Host_Navi.AirSpeed;
                    }
                    else
                    {
                        Host_Navi.Speed.X += Host_Navi.AirSpeed;
                    }
                }
            }
            #endregion
            if (Host_Navi.Shooting == true)
            {
                if (Host_Navi.ShootCharge > 20)
                {
                    Color4 color = new Color4();
                    Host_Navi.ShootCharge    = 0;
                    Host_Navi.Shoot_Advance += 1;
                    if (Host_Navi.Shoot_Advance > 3)
                    {
                        Host_Navi.Shoot_Advance = 1;
                    }
                    Host_Navi.Activated_Ability = Host_Navi.Shoot_Advance;

                    if (Host_Navi.Shoot_Advance == 1)
                    {
                        color.R = 255; color.G = 0; color.B = 0; color.A = 255;
                    }
                    if (Host_Navi.Shoot_Advance == 2)
                    {
                        color.R = 0; color.G = 255; color.B = 0; color.A = 255;
                    }
                    if (Host_Navi.Shoot_Advance == 3)
                    {
                        color.R = 0; color.G = 0; color.B = 255; color.A = 255;
                    }

                    Point  loc = new Point();
                    PointF Shoot_Point;
                    PointF Speed = new PointF();
                    Shoot_Point = Host_Navi.Get_Shoot_Point();
                    if (Host_Navi.FaceLeft)
                    {
                        loc.X = (int)Shoot_Point.X - (int)(8 * Host_Navi.Scale);
                    }
                    else
                    {
                        loc.X = (int)Shoot_Point.X;
                    }
                    loc.Y = (int)Shoot_Point.Y - (int)((6 / 2) * Host_Navi.Scale);
                    if (Host_Navi.FaceLeft)
                    {
                        Speed.X = -10;
                    }
                    else
                    {
                        Speed.X = 10;
                    }
                    Projectile_List.Add(new Projectiles_Type(loc, Speed, 100, Host_Navi.Scale, color, "Host"));
                }
            }
        }