예제 #1
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (paperTimer >= 2.0f && target != null)
            {
                Paper paper = new Paper(paperTexture, paperBreakTexture, Vector2.Subtract(center,
                    new Vector2(paperTexture.Width / 2)), rotation, 5, damage);

                paperList.Add(paper);
                paperTimer = 0;
            }

            for (int i = 0; i < paperList.Count; i++)
            {
                Paper paper = paperList[i];

                paper.SetRotation(rotation);
                paper.Update(gameTime);

                if (!IsInRange(paper.Center))
                    paper.Kill(PaperState.MISS);

                // If the paper hits a target,
                if (target != null && Vector2.Distance(paper.Center, target.Center) < 12)
                {
                    // destroy the paper and hurt the target.
                    if (paper.Paperstate == PaperState.FLYING)
                    {
                        target.CurrentHealth -= paper.Damage;
                    }
                    
                    paper.Kill(PaperState.HIT);

                    // Apply our speed modifier if it is better than
                    // the one currently affecting the target :
                    if (target.SpeedModifier <= speedModifier)
                    {
                        target.SpeedModifier = speedModifier;
                        target.ModifierDuration = modifierDuration;
                    }
                }
                if (target == null)
                {
                    paper.Kill(PaperState.MISS);
                }
                if (paper.IsDead())
                {
                    paperList.Remove(paper);
                    i--;
                }
            }
        }
예제 #2
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (paperTimer >= 0.75f && target != null)
            {
                Paper paper = new Paper(paperTexture, paperBreakTexture, Vector2.Subtract(center,
                    new Vector2(paperTexture.Width / 2)), rotation, 5, damage);

                paperList.Add(paper);
                paperTimer = 0;
            }

            for (int i = 0; i < paperList.Count; i++)
            {
                Paper paper = paperList[i];

                paper.SetRotation(rotation);
                paper.Update(gameTime);

                if (!IsInRange(paper.Center))
                    paper.Kill(PaperState.MISS);

                if (target != null && Vector2.Distance(paper.Center, target.Center) < 12)
                {
                    if (target.StudentType != 2 && paper.Paperstate == PaperState.FLYING)
                    {
                        target.CurrentHealth -= paper.Damage;
                    }
                        
                    paper.Kill(PaperState.HIT);
                }
                if (target == null)
                {
                    paper.Kill(PaperState.MISS);
                }
                if (paper.IsDead())
                {
                    paperList.Remove(paper);
                    i--;
                }
            }
        }
예제 #3
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            // Decide if it is time to shoot.
            if (paperTimer >= 1.5f && targets.Count != 0)
            {
 
                // For every direction the teacher can shoot,
                for (int i = 0; i < directions.Length; i++)
                {
                    // create a new paper that moves in that direction.
                    Paper paper = new Paper(paperTexture, paperBreakTexture, Vector2.Subtract(center,
                        new Vector2(paperTexture.Width / 2)), directions[i], 5, damage);

                    paperList.Add(paper);
                }

                paperTimer = 0;
            }

            // Loop through all the papers.
            for (int i = 0; i < paperList.Count; i++)
            {
                Paper paper = paperList[i];
                paper.Update(gameTime);

                // Kill the paper when it is out of range.
                if (!IsInRange(paper.Center))
                {
                    paper.Kill(PaperState.MISS);
                }

                // Loop through all the possible targets
                for (int t = 0; t < targets.Count; t++)
                {
                    // If this paper hits a target and is in range,
                    if (targets[t] != null && Vector2.Distance(paper.Center, targets[t].Center) < 12)
                    {
                        // hurt the student.
                        if (paper.Paperstate == PaperState.FLYING)
                        {
                            targets[t].CurrentHealth -= paper.Damage;
                        }
                        
                        paper.Kill(PaperState.HIT);

                        // This paper can't kill anyone else.
                        break;
                    }
                }
                
                // Remove the paper if it is dead.
                if (paper.IsDead())
                {
                    paperList.Remove(paper);
                    i--;
                }

            }
            if (paperList.Count > 0)
            {
                RefreshSpeed = 4;
            }
            else { RefreshSpeed = 0; }
        }