示例#1
0
        public static BasicObject CreateInstanceOf(BasicObjectCreator Creator, Level level)
        {
            BasicObject NewObject = null;

            if (!Creator.HasLoaded)
            {
                Creator.Load();
            }

            NewObject = Creator.ReturnObject();

            if (NewObject != null)
            {
                NewObject.CreatorString = Creator.MyObjectName;

                if (NewObject.GetType().Equals(typeof(TimeBasic)))
                {
                    level.TimeEvents.Add((TimeBasic)NewObject);
                    SetAsTime((TimeBasic)NewObject, Creator);
                }
                else
                {
                    level.AddObject(NewObject);
                }
            }


            return(NewObject);
        }
示例#2
0
        public override bool HitObject(BasicObject Object, GameTime gameTime)
        {
            if (Object != Creator)
            {
                if (LifeTime < 400)
                {
                    Object.TakeDamage((float)Damage * gameTime.ElapsedGameTime.Milliseconds / 1000f * 60f, this, Direction);
                    if (Object.GetType().IsSubclassOf(typeof(DynamicObject)))
                    {
                        for (int i = 0; i < 3; i++)
                        {
                            ParticleSystem.Add(ParticleType.Spark, (Position + Size / 2 + Object.Position + Object.Size / 2) / 2, Bullet.RandomSpeed(0.35f) * new Vector2(1, 5), 0, new Color(1f, 1, 1f), 1.5f);
                        }
                        ParticleSystem.Add(ParticleType.Spark, (Position + Size / 2 + Object.Position + Object.Size / 2) / 2, Bullet.RandomSpeed(0.1f) * new Vector2(1, 5), 0, new Color(1f, 1, 1f), 5);

                        if (Vector2.Distance(Position + Size / 2, Object.Position + Object.Size / 2) < 25)
                        {
                            Slash();
                        }
                        else
                        {
                            Speed = Vector2.Normalize((Object.Position + Object.Size / 2) - (Position + Size / 2)) * Vector2.Distance(Vector2.Zero, Speed);
                        }
                    }
                }
            }
            return(false);
        }
示例#3
0
        public override bool HitObject(BasicObject Object, GameTime gameTime)
        {
            if (Object.GetType().IsSubclassOf(typeof(DynamicObject)))
            {
                return(base.HitObject(Object, gameTime));
            }

            return(false);
        }
示例#4
0
 public override bool HitObject(BasicObject Object, GameTime gameTime)
 {
     if (Object.GetType().IsSubclassOf(typeof(DynamicObject)))
     {
         return(base.HitObject(Object, gameTime));
     }
     else
     {
         Object.TakeDamage(gameTime.ElapsedGameTime.Milliseconds / 1000f * 60f * Damage, this, Vector2.Normalize(Speed));
         return(false);
     }
 }
示例#5
0
 public override bool HitObject(BasicObject Object, GameTime gameTime)
 {
     if (Object.GetType().IsSubclassOf(typeof(DynamicObject)))
     {
         return(base.HitObject(Object, gameTime));
     }
     else
     {
         //if (LifeTime < MaxLifeTime - CollisionLifeTime)
         LifeTime = MaxLifeTime - CollisionLifeTime;
         return(false);
     }
 }
示例#6
0
 public override bool HitObject(BasicObject Object, GameTime gameTime)
 {
     if (Object.GetType().Equals(typeof(Block)))
     {
         if (Vector2.Distance(Vector2.Zero, Speed) < MaxSpeed)
         {
             Speed = Vector2.Zero;
             StickTo(Object);
         }
         else
         {
             Speed *= 0.85f;
             Speed  = Object.Bounce(MyRectangle, Speed, (int)Math.Max(Speed.X, Speed.Y) * gameTime.ElapsedGameTime.Milliseconds);
         }
     }
     return(true);
 }
 public override bool HitObject(BasicObject Object, GameTime gameTime)
 {
     if (Object.Damage < Object.Life)
     {
         if (Hits > 0 && Object.GetType().Equals(typeof(Block)) && Vector2.Distance(Position, GameManager.MyLevel.GetNearestEnemy(this).Position) > Range)
         {
             Hits--;
             Object.TakeDamage(1000, this, Vector2.Zero);
             Speed *= 0.5f;
         }
         else
         {
             Destroy();
         }
     }
     return(true);
 }
示例#8
0
        public static BasicObject CreateInstanceOf(string Type, Level level)
        {
            BasicObject NewObject = null;

            foreach (BasicObjectCreator Creator in BasicObjectCreator.BasicObjectTypes)
            {
                if (Type == Creator.MyObjectName)
                {
                    if (!Creator.HasLoaded)
                    {
                        Creator.Create();
                    }
                    NewObject = Creator.ReturnObject();



                    if (NewObject != null)
                    {
                        NewObject.CreatorString = Creator.MyObjectName;

                        if (NewObject.GetType().Equals(typeof(TimeBasic)))
                        {
                            level.TimeEvents.Add((TimeBasic)NewObject);
                            SetAsTime((TimeBasic)NewObject, Creator);
                        }
                        else
                        {
                            level.AddObject(NewObject);
                        }
                    }
                }
            }
            Console.Write(Type);



            return(NewObject);
        }
示例#9
0
        public override void Update(GameTime gameTime)
        {
            ParticleTime += gameTime.ElapsedGameTime.Milliseconds;
            while (ParticleTime > MaxParticleTime)
            {
                ParticleTime -= MaxParticleTime;
                ParticleSystem.Add(ParticleType.Circle, Position + Size / 2, Vector2.Zero, (float)MathHelper.ToRadians((float)Bullet.NewRandom.NextDouble() * 360), new Color(0.25f, 1, 0.5f), 2);

                if (LifeTime > MaxLifeTime - StuckDetonateTime)
                {
                    ParticleSystem.Add(ParticleType.Glow, Position + Size / 2, Vector2.Zero, (float)MathHelper.ToRadians((float)Bullet.NewRandom.NextDouble() * 360), new Color(0.25f, 1, 0.5f), (LifeTime - (MaxLifeTime - StuckDetonateTime)) / (StuckDetonateTime) * 10);
                }
            }

            PreviousPosition = Position;
            if (!Stuck)
            {
                BasicObject Enemy = GameManager.MyLevel.GetNearestEnemy(this);

                if (Enemy != null)
                {
                    float Distance = Vector2.Distance(Enemy.Position + Enemy.Size / 2, Position + Size / 2);

                    if (Distance < Range)
                    {
                        Speed = Vector2.Distance(Speed, Vector2.Zero) * Vector2.Normalize((Enemy.Position + Enemy.Size / 2) - (Position + Size / 2));
                    }
                    {
                        if (Distance < 24)
                        {
                            StickTo(Enemy);
                        }
                    }
                }
            }
            else
            {
                if (StuckTo != null)
                {
                    bool Go = true;
                    if (StuckTo.GetType().Equals(typeof(Player)))
                    {
                        Player p = StuckTo as Player;
                        if (p.IsDashing)
                        {
                            Go = false;
                        }
                    }

                    if (Go)
                    {
                        Position = StuckTo.Position - StuckOffset;
                        Speed    = Vector2.Zero;
                        Gravity  = Vector2.Zero;
                        Reps     = 0;
                        ChangePosition();
                        LifeTime = (int)Math.Max(LifeTime, MaxLifeTime - StuckDetonateTime);
                    }
                    else
                    {
                        Stuck = false;
                    }
                }
            }

            base.Update(gameTime);
        }
示例#10
0
        public override void Update(GameTime gameTime)
        {
            PushTime -= 1f * (float)gameTime.ElapsedGameTime.Milliseconds / (1000f / 60f);
            if (PushTime < 0)
            {
                if (MyGun != null)
                {
                    MyGun.Update(gameTime);

                    if (MyGun.Primary != null)
                    {
                        MyGun.Primary.Shoot(Position + Size / 2, Direction);
                    }
                    if (MyGun.Secondary != null)
                    {
                        MyGun.Secondary.Shoot(Position + Size / 2, Direction);
                    }
                }
            }

            Vector2   ToPosition  = Position + ((Speed * gameTime.ElapsedGameTime.Milliseconds));
            int       Reps        = 1;
            Rectangle ToRectangle = new Rectangle((int)ToPosition.X, (int)ToPosition.Y, (int)Size.X, (int)Size.Y);

            if (GameManager.MyLevel.CheckForSolidCollision(ToRectangle) != null)
            {
                Reps = Math.Max(1, (int)Vector2.Distance(Vector2.Zero, Speed * gameTime.ElapsedGameTime.Milliseconds));
            }

            bool CountedBounce = false;

            for (int i = 1; i < Reps + 1; i++)
            {
                ToPosition  = Position + ((Speed * gameTime.ElapsedGameTime.Milliseconds) / Reps);
                ToRectangle = new Rectangle((int)ToPosition.X, (int)ToPosition.Y, (int)Size.X, (int)Size.Y);


                BasicObject Other2 = GameManager.MyLevel.CheckForSolidCollision(ToRectangle);

                if (Other2 == null)
                {
                    Position = ToPosition;
                }
                else
                {
                    if (!CountedBounce && Other2.GetType().Equals(typeof(Block)))
                    {
                        Other2.TakeDamage(DamageToBlock, null, Vector2.Zero);
                        CountedBounce = true;
                        Bounces++;
                    }

                    Speed *= 0.75f;
                    if (Other2.Damage <= Other2.Life)
                    {
                        Speed = Other2.Bounce(MyRectangle, Speed, (int)Math.Max(Speed.X, Speed.Y) * gameTime.ElapsedGameTime.Milliseconds / Reps);
                    }
                    Position = ToPosition;
                }
            }

            ChangePosition();

            foreach (BasicObject Object in GameManager.MyLevel.DynamicCollidables)
            {
                if (Object.Team != Team)
                {
                    if (Object.MyRectangle.Intersects(MyRectangle))
                    {
                        CollideWithEnemy(Object);
                        break;
                    }
                }
            }

            base.Update(gameTime);
        }