Example #1
0
 public bool IsCollided(Projectile projectile)
 {
     if (this.RecArea.Intersects(projectile.RecArea)) {
         this.HitPoint -= projectile.Damage;
         return true;
     }
     return false;
 }
 public void AddProjectile(Projectile projectile)
 {
     this.projectile = projectile;
     this.projectile.onDecay = true;
 }
        /* Draw */
        public void StartGame()
        {
            /*
            Sprite test;
            LinearEquation linear = new LinearEquation(40, 40, 100, 200);
            List<Vector2> tempList = linear.GetVectorPoint(20.0f);
            for (int n = 0; n < tempList.Count; n++) {
                spriteList.AddSprite(new Sprite(textDict.Get("box_debug"), tempList[n], Color.White));
            }
            spriteList.AddSprite(new AnimatedSprite(textDict.Get("block_face"), 30, 10, new Vector2(500, 100)));
            GravityProjection pro1 = new GravityProjection(new Vector2(200, 200),50,-9.8f,30,0);
            List<Tuple<Vector2, float>> tempList2 = new List<Tuple<Vector2, float>>(123);
            tempList2 = pro1.GetMotionVector(1.0f);
            Debug.WriteLine("Debug Start");
            Debug.WriteLine("Length "+tempList2.Count);
            for (int n = 0; n < tempList2.Count; n++)
            {
                spriteList.AddSprite(new Sprite(textDict.Get("box_debug"), tempList2[n].Item1, Color.White));
                Debug.WriteLine(tempList2[n].Item1.ToString()+" "+tempList2[n].Item2);
            }
             */

            powerbar = new Bar(textDict.Get("bar"), new Vector2(100, 100), SharedGraphicsDeviceManager.Current.GraphicsDevice);
            spriteList.AddSprite(powerbar);
            projectileBase = new ProjectileBase(50, 250, powerbar);
            for (int i = 0; i < 50; i++)
            {
                projectile = new Projectile(textDict.Get("box_debug"), new Vector2(-100, -100), Color.Black);
                spriteList.AddSprite(projectile);
                projectileBase.addProjectile(projectile);
            }
        }
        public void InitGame()
        {
            Sprite backsprite = new Sprite(textDict.Get("background"));
            spriteList.AddSprite(backsprite);
            pauseButton = new Sprite(textDict.Get("pausebtn_button"));
            spriteList.AddSprite(pauseButton);
            powerbar = new Bar(textDict.Get("bar"), new Vector2(100, 100), SharedGraphicsDeviceManager.Current.GraphicsDevice);
            spriteList.AddSprite(powerbar);
            AnimatedSprite hero = new AnimatedSprite(textDict.Get("hero"), 1, 7, new Vector2(50, 200), 100);
            spriteList.AddSprite(hero);
            AnimatedSprite plane = new AnimatedSprite(textDict.Get("plane"), 1, 5, new Vector2(10, 300), 100);
            spriteList.AddSprite(plane);

            closeButton = new Sprite(textDict.Get("pausebtn_close"), new Vector2(600 - 70, 320 - 70), Color.White);
            restartButton = new Sprite(textDict.Get("pausebtn_restart"), new Vector2(200 - 70, 320 - 70), Color.White);
            resumeButton = new Sprite(textDict.Get("pausebtn_resume"), new Vector2(400 - 70, 160 - 70), Color.White);
            pauseSpriteList.AddSprite(closeButton);
            pauseSpriteList.AddSprite(restartButton);
            pauseSpriteList.AddSprite(resumeButton);

            projectileBase = new ProjectileBase(90, 240, powerbar, hero, plane);
            for (int i = 0; i < 1; i++)
            {
                projectile = new Projectile(textDict.Get("nut"), new Vector2(-100, -100), Color.White);
                spriteList.AddSprite(projectile);
                projectileBase.AddProjectile(projectile);
            }
        }