예제 #1
0
        public override void Update(GameTime gameTime)
        {
            foreach (BaseGameObject go in GameApp.instance.InGameList)
            {
                if (go.Equals(this))
                {
                    continue;
                }

                Vector2 Direction = this.Position - go.Position;
                float   Length    = Direction.Length();
                Direction.Normalize();

                if (Length >= go.Position.Length())
                {
                    Gravity %= 50;
                }

                go.Velocity += Gravity * Direction;
                if (Collison.Intersects(go.Collison))
                {
                    go.TakeDamage(1f);
                }
            }
        }
        public virtual void CheckCollision()
        {
            foreach (BaseGameObject obj in GameApp.instance.SceneList)
            {
                if (obj == this)
                {
                    continue;
                }

                if (Collison.Intersects(obj.Collison))
                {
                    //if player
                    if (obj is PlayerShip)
                    {
                        obj.Destroy();
                        this.Destroy();
                        Console.WriteLine("Player Destroyed");
                    }

                    //if projectile

                    if (obj is Torpedo)
                    {
                        obj.Destroy();
                        this.Destroy();
                    }
                }
            }
        }
        public override void Update(GameTime gameTime)
        {
            // check against everythign in the scene list instead.
            foreach (BaseGameObject go in GameApp.instance.InGameList)
            {
                if (go.Equals(owner) || go.Equals(this))
                {
                    continue;
                }

                ///Console.WriteLine("*****");

                if (Collison.Intersects(go.Collison))
                {
                    Destroy();
                    go.TakeDamage(1f);
                }
            }
        }