Пример #1
0
 public GenericFace(BasicCube cube, ModelManager modelManager, int faceId)
 {
     parentCube = cube;
     this.faceId = faceId;
     this.modelManager = modelManager;
     this.game = modelManager.getGame();
 }
Пример #2
0
        public AStar(BasicCube[] mapArray, int width, int height, int depth, int orientation, Vector3 enemyPos)
        {
            int max = Math.Max(Math.Max(width, height), depth);
            currentOrientation = (SpectrumEnums.Orientation)orientation;
            switch ((SpectrumEnums.Orientation)orientation)
            {
                case SpectrumEnums.Orientation.posX:
                case SpectrumEnums.Orientation.negX:
                    searchMapWidth = max;
                    searchMapHeight = max;
                    break;
                case SpectrumEnums.Orientation.posY:
                case SpectrumEnums.Orientation.negY:
                    searchMapWidth = max;
                    searchMapHeight = max;
                    break;
                case SpectrumEnums.Orientation.posZ:
                case SpectrumEnums.Orientation.negZ:
                    searchMapWidth = max;
                    searchMapHeight = max;
                    break;
            }

            this.enemyPos = enemyPos;
            map = new BasicCube[searchMapWidth, searchMapHeight];
            ResetSearchNodes();
            buildMapFromArray(mapArray);
            InititializeSearchNodes(map);
        }
Пример #3
0
 public MudFace(BasicCube cube, ModelManager modelManager, int faceId)
     : base(cube, modelManager, faceId)
 {
     this.parentCube = cube;
     this.setHarmful(false);
     this.faceId = faceId;
     this.modelManager = modelManager;
 }
Пример #4
0
        public Bubble(Model model, Game game, Camera camera, OctTree octTree, Vector3 startPosition, Vector3 startDirection, Vector3 startUp, BasicCube[] worldMap, ScreenManager screenManager)
            : base(model, game)
        {
            this.octTree = octTree;
            //  shadow = game.Content.Load<Effect>(@"Shader/Shadow");
            movementHandler = new MovementAndInputHandler(game, this);
            collisionHandler = new CollisionHandler(game, this, screenManager, worldMap);
            effect = ((Spectrum)game).effect;
            texture = screenManager.texManager.getBubbleTexture();
            this.camera = camera;
            this.currentPosition = startPosition;
            this.game = game;
            this.bubble = model;
            this.startPosition = startPosition;
            this.currentPosition = startPosition;
            movementHandler.setStartValues(startPosition, Vector3.Backward, Vector3.Up, Quaternion.Identity, SpectrumEnums.Orientation.posY);

            this.soundManager = ((Spectrum)game).soundManager;

            this.screenManager = screenManager;
            this.screenManager.setPlayer(this);
        }
Пример #5
0
 public void setAStar(BasicCube[] mapArray, Vector3 mapResolution)
 {
     pathfinding = new AStar(mapArray, (int)mapResolution.X, (int)mapResolution.Y, (int)mapResolution.Z, face, position);
 }
Пример #6
0
 public void setCurrentWorldMap(BasicCube[] map)
 {
     worldMap = map;
     foreach (BasicCube cube in worldMap)
     {
         models.Add(cube);
     }
 }
Пример #7
0
        private void InititializeSearchNodes(BasicCube[,] map)
        {
            searchNodes = new SearchNode[searchMapWidth, searchMapHeight];
            for (int x = 0 ; x < searchMapWidth; x++)
            {
                for (int y = 0; y < searchMapHeight; y++)
                {
                    SearchNode node = new SearchNode();
                    node.position = new Point(x,y);
                    //logic here to detect if face is free
                    node.isOccupied = checkForObstacles(map[x, y]);

                    if (node.isOccupied == false)
                    {
                        node.neighbours = new SearchNode[4];
                        searchNodes[x, y] = node;
                    }
                }
            }

            for (int x = 0; x < searchMapWidth; x++)
            {
                for (int y = 0; y < searchMapHeight; y++)
                {
                    SearchNode node = searchNodes[x, y];

                    // if there is no node, or the node is occupied by an obstacle, continue
                    if (node == null || node.isOccupied == true)
                    {
                        continue;
                    }

                    // TODO maybe change this to make it work for x,y and z,
                    // or put that logic outside and work only in x and y here
                    Point[] neighbours = new Point[]
                    {
                        new Point(x, y-1),
                        new Point(x, y+1),
                        new Point(x-1, y),
                        new Point(x+1, y)
                    };

                    // loop through neighbours
                    for (int i = 0; i < neighbours.Length; i++)
                    {
                        Point position = neighbours[i];

                        // make sure neighbour is part of the level
                        if (position.X < 0 || position.X > searchMapWidth - 1 ||
                            position.Y < 0 || position.Y > searchMapHeight - 1)
                        {
                            continue;
                        }

                        SearchNode neighbour = searchNodes[position.X, position.Y];

                        if (neighbour == null || neighbour.isOccupied == true)
                        {
                            continue;
                        }

                        node.neighbours[i] = neighbour;
                    }
                }
            }
        }
Пример #8
0
 private Vector3 getRealPosition(BasicCube[,] cubeMap)
 {
     return Vector3.Zero;
 }
Пример #9
0
 private Vector2 GetPseudoPosition(BasicCube cube)
 {
     Vector3 realPosition = cube.getOffset();
     switch (currentOrientation)
     {
         case SpectrumEnums.Orientation.posX:
         case SpectrumEnums.Orientation.negX:
             if (cube.offset.X == enemyPos.X)
             {
                 return new Vector2(realPosition.Y / 2, realPosition.Z / 2);
             }
             return Vector2.Zero;
         case SpectrumEnums.Orientation.posY:
         case SpectrumEnums.Orientation.negY:
             //cube offset different than enemyPos, Investigate
             if (cube.offset.Y == enemyPos.Y)
             {
                 return new Vector2(realPosition.X / 2, realPosition.Z / 2);
             }
             return Vector2.Zero;
         case SpectrumEnums.Orientation.posZ:
         case SpectrumEnums.Orientation.negZ:
             if (cube.offset.Z == enemyPos.Z)
             {
                 return new Vector2(realPosition.X / 2, realPosition.Y / 2);
             }
             return Vector2.Zero;
         default:
             return Vector2.Zero;
     }
 }
Пример #10
0
 private bool checkForObstacles(BasicCube cube)
 {
     if (cube == null)
     {
         return true;
     }
     GenericFace face = cube.getFace((int)currentOrientation);
     if (face.isHarmful())
     {
         return true;
     }
     else
     {
         return false;
     }
 }
Пример #11
0
 private void buildMapFromArray(BasicCube[] mapArray)
 {
     foreach(BasicCube cube in mapArray)
     {
         Vector2 pseudeoPos = GetPseudoPosition(cube);
         map[(int)pseudeoPos.X, (int)pseudeoPos.Y] = cube;
     }
 }