コード例 #1
0
        public bool CanSee(NPC npc, Obstacle obs)
        {
            Vector2 viewDir = npc.visions[numVisions/2].viewDirection;
            double angle1 = 2 * Math.PI + Math.Atan2(-1*(double)viewDir.Y, (double)viewDir.X);
            Vector2 obsDir = obs.position - npc.position;
            double angle2 = 2 * Math.PI + Math.Atan2(-1*(double)obsDir.Y, (double) obsDir.X);
            double diff = angle1 - angle2;
            if (Math.Abs(diff) > Math.PI)
                diff = Math.Abs(diff) - 2 * Math.PI;

            if (Math.Abs(diff) < viewWidth + Math.PI / 2)
            {
                if (distance2((Entity)npc, (Entity)obs) < viewDistance * viewDistance + 30000)
                    return true;
            }
            return false;
        }
コード例 #2
0
 public void CreateObstacle(ObstacleType type, Vector2 pos)
 {
     Obstacle obstacle = new Obstacle();
     obstacle.position = pos;
     obstacle.tag = type;
     switch (type)
     {
         case ObstacleType.Bush:
             obstacle.sprite = bushTexture;
             obstacle.canOverlapWith = true;
             obstacle.canSeeThrough = false;
             obstacle.rectangleBounds = new Point(BUSH_SPRITE_SIZE_X, BUSH_SPRITE_SIZE_Y);
             break;
         case ObstacleType.Tree:
             obstacle.sprite = treeTexture;
             obstacle.canOverlapWith = false;
             obstacle.canSeeThrough = false;
             obstacle.rectangleBounds = new Point(TREE_SPRITE_SIZE_X, TREE_SPRITE_SIZE_Y);
             break;
         case ObstacleType.Fountain:
             obstacle.sprite = fountainTextureOff;
             obstacle.canOverlapWith = false;
             obstacle.canSeeThrough = true;
             obstacle.rectangleBounds = new Point(FOUNTAIN_SPRITE_SIZE_X, FOUNTAIN_SPRITE_SIZE_Y);
             break;
         case ObstacleType.Pond:
             obstacle.sprite = pondTexture;
             obstacle.canOverlapWith = false;
             obstacle.canSeeThrough = true;
             obstacle.rectangleBounds = new Point(POND_SPRITE_SIZE_X, POND_SPRITE_SIZE_Y);
             break;
         case ObstacleType.Trash:
             obstacle.sprite = trashTexture;
             obstacle.canOverlapWith = false;
             obstacle.canSeeThrough = true;
             obstacle.rectangleBounds = new Point(TRASH_SPRITE_SIZE_X, TRASH_SPRITE_SIZE_Y);
             break;
         case ObstacleType.Border:
             obstacle.sprite = treeTexture;
             obstacle.canOverlapWith = false;
             obstacle.canSeeThrough = true;
             obstacle.rectangleBounds = new Point(TREE_SPRITE_SIZE_X, TREE_SPRITE_SIZE_Y);
             break;
     }
     this.AddObstacle(obstacle);
 }
コード例 #3
0
        public void interacts(Player p, Obstacle o)
        {
            switch(o.tag)
            {
                case ObstacleType.Bush:
                    // set player invisible
                    p.isVisible = false;
                    break;
                case ObstacleType.Fountain:

                        p.currentThirst = p.maxThirst;
                       // slurp.play();

                    break;
                case ObstacleType.Pond:
                    // do nothing
                    break;
                case ObstacleType.Tree:
                    // do nothing
                    break;
            }
        }
コード例 #4
0
 public void AddObstacle(Obstacle obstacle)
 {
     obstacles.Add(obstacle);
     tileController.Add(obstacle);
 }
コード例 #5
0
 public void TurnFountainOn(Obstacle fountain)
 {
     fountain.sprite = fountainTextureOn;
 }
コード例 #6
0
 public void RemoveObstacle(Obstacle obstacle)
 {
     obstacles.Remove(obstacle);
     tileController.Remove(obstacle);
 }