コード例 #1
0
        public void Visit(IQuadTree aQuadTree)
        {
            IUserObject insertedUserObject = this.insertedPoint.GetUserObject();
            IShape      insertedShape      = insertedUserObject.GetShape();
            IRectangle  targetBoundary     = CalculateTargetBoundary(insertedShape);

            if (null != aQuadTree.GetRootPoints())
            {
                List <IPoint <IUserObject> > pointsToBeDeleted = new List <IPoint <IUserObject> > ();
                foreach (IPoint <IUserObject> currentPoint in aQuadTree.GetRootPoints())
                {
                    Visit(currentPoint);
                    if (currentPoint.GetUserObject().GetHealth() < 1)
                    {
                        pointsToBeDeleted.Add(currentPoint);
                        this.userObjectSpawner.PushBackDeadObject(currentPoint.GetUserObject());
                    }
                    if (insertedUserObject.GetHealth() < 1)
                    {
                        this.userObjectSpawner.PushBackDeadObject(insertedUserObject);
                        break;
                    }
                }
                aQuadTree.RemovePointsFromRoot(pointsToBeDeleted);
            }
        }
コード例 #2
0
        private void ChangeTransparencyAccordingToHealth(IUserObject aUserObject)
        {
            Color objectColor = aUserObject.GetGameObject().GetComponent <SpriteRenderer> ().material.color;

            objectColor.a = ((float)aUserObject.GetHealth()) / aUserObject.GetInitialHealth();
            aUserObject.GetGameObject().GetComponent <SpriteRenderer> ().material.color = objectColor;
        }
コード例 #3
0
 public void Visit(IQuadTree aQuadTree)
 {
     if (null != this.insertedPoint)
     {
         IUserObject insertedUserObject             = this.insertedPoint.GetUserObject();
         IShape      insertedShape                  = insertedUserObject.GetShape();
         IRectangle  targetBoundary                 = calculateTargetBoundary(insertedShape);
         ICollection <IPoint <IUserObject> > points = aQuadTree.GetPoints(targetBoundary, false);
         foreach (IPoint <IUserObject> currentPoint in points)
         {
             visit(currentPoint);
             if (currentPoint.GetUserObject().GetHealth() < 1)
             {
                 aQuadTree.RemovePointFromRoot(currentPoint);
                 this.userObjectSpawner.PushBackDeadObject(currentPoint.GetUserObject());
             }
             if (insertedUserObject.GetHealth() < 1)
             {
                 aQuadTree.RemovePointFromRoot(this.insertedPoint);
                 this.userObjectSpawner.PushBackDeadObject(insertedUserObject);
                 break;
             }
         }
     }
 }