Esempio n. 1
0
void Map::DigChannel(MapCoordinates Coordinates)
{
    Dig(Coordinates);
    setCubeShape(Coordinates, DATA->getLabelIndex("TILESHAPE_EMPTY"));

    // reveal tiles around
    for(Direction DirectionType = COMPASS_DIRECTIONS_START; DirectionType < NUM_COMPASS_DIRECTIONS; ++DirectionType)
    {
        setCubeHidden(MapCoordinates(Coordinates, DirectionType), false);
    }

    Dig(MapCoordinates(Coordinates, DIRECTION_DOWN));

    removeFace(Coordinates, DIRECTION_DOWN);
}
Esempio n. 2
0
void Zone::addSelection(VolumeSelection* Selection)
{
	MapCoordinates Origin = Selection->OriginLocation;
	MapCoordinates Terminal = Selection->TerminalLocation;

	for (int x = Origin.X; x < Terminal.X; x++)
	{
		for (int y = Origin.Y; y < Terminal.Y; y++)
		{
			for (int z = Origin.Z; z < Terminal.Z; z++)
			{
				MapCoordinates ZoneCube = MapCoordinates(x, y, z);
				CellCoordinates ZoneCell = CellCoordinates(ZoneCube);

				std::map< uint64_t, bitset <CUBESPERCELL>* >::iterator it = ZoneMap.find(ZoneCell.Key());
				if (it != ZoneMap.end())
				{
					bitset<CUBESPERCELL>* Bits = it->second;
					Bits->set(ZoneCube.Cube(), true);
				} else {
					bitset<CUBESPERCELL>* Bits = new bitset<CUBESPERCELL>;
					Bits->set(ZoneCube.Cube(), true);
					ZoneMap[ZoneCell.Key()] = Bits;
				}
			}
		}
	}
}
Esempio n. 3
0
void Map::DigSlope(MapCoordinates Coordinates)
{
    static int16_t RampID = DATA->getLabelIndex("TILESHAPE_RAMP");

    Dig(Coordinates);

    // reveal tiles around
    for(Direction DirectionType = COMPASS_DIRECTIONS_START; DirectionType < NUM_COMPASS_DIRECTIONS; ++DirectionType)
    {
        setCubeHidden(MapCoordinates(Coordinates, DirectionType), false);
    }

    DigChannel(MapCoordinates(Coordinates, DIRECTION_UP));
    setCubeShape(Coordinates, RampID);

    setCubeMaterial(Coordinates, getFaceMaterial(Coordinates, DIRECTION_DOWN));
    setCubeSurfaceType(Coordinates, getFaceSurfaceType(Coordinates, DIRECTION_DOWN));
}
bool Projectile::_hasCollisionOnTile(MapTile* MapTile)
{
	set<int> tileLivingEntityIndices = MapTile->currentLivingEntityIndices;

	set<int>::iterator setIterator;

	for (setIterator = tileLivingEntityIndices.begin(); setIterator != tileLivingEntityIndices.end(); setIterator++) {

		int livingEntityIndex = *setIterator;

		WorldObject* LivingEntity = GlobalLivingEntitiesList.getAtIndex(livingEntityIndex);

		//Really it should be seeing if topLeft x, topLeft y, bottomRight x, or bottomRight y are outside the LivingEntity rectangle, but since
		//our bullet is very small we'll just treat it as a point
		if (LivingEntity->isPositionInObjectHitbox(this->Position)) {
			
			MapCoordinates BloodPosition = MapCoordinates();
			switch (this->_facing) {

				case ENTITY_FACING_EAST:
				case ENTITY_FACING_WEST:
					BloodPosition.x = this->Position.x - SPRITE_SIZE_MEDIUM/2;
					BloodPosition.y = this->Position.y  - SPRITE_SIZE_MEDIUM/2;
					break;
				default:
					BloodPosition.x = this->Position.x;
					BloodPosition.y = this->Position.y;
					break;
			}

			AnimatedEffectCreator::createBleedingEffect(BloodPosition);

			LivingEntity->damage(this->_attackPower, this->_damageType, this->_facing);
			this->_functional = false;

			return true;
		}
	}

	return false;
}
Esempio n. 5
0
void Map::_setMapTileNeighbors(MapTile *GivenMapTile)
{

    //Clear old connections
    for(int i = 0; i < 8; i++) {
        GivenMapTile->NeighborMapTiles[i] = NULL;
    }

    int x = GivenMapTile->TileCoordinates.x;
    int y = GivenMapTile->TileCoordinates.y;

    //Possible neighbors' (8) positions
    MapCoordinates NeighborCoordinates[] = {
        MapCoordinates(x-1, y-1),
        MapCoordinates(x, y-1),
        MapCoordinates(x+1, y-1),
        MapCoordinates(x-1, y),
        MapCoordinates(x+1, y),
        MapCoordinates(x-1, y+1),
        MapCoordinates(x, y+1),
        MapCoordinates(x+1, y+1)
    };

    int numberOfNeighbors = 0;

    //For each neighbor
    for (int i = 0 ; i < 8; i++) {

        if (this->coordinatesAreWithinMap(NeighborCoordinates[i])) {

            MapTile *Neighbor = this->getTileAtCoordinates(NeighborCoordinates[i].x, NeighborCoordinates[i].y);

            if (Neighbor != NULL && Neighbor->walkable) {
                GivenMapTile->NeighborMapTiles[i] = Neighbor;
            }
        }
    }//end for
}
Esempio n. 6
0
void Map::Dig(MapCoordinates Coordinates)
{
    static int16_t FloorID = DATA->getLabelIndex("TILESHAPE_FLOOR");
    static int16_t RoughWallID = DATA->getLabelIndex("SURFACETYPE_ROUGH_WALL");
    static int16_t RoughFloorID = DATA->getLabelIndex("SURFACETYPE_ROUGH_FLOOR_1");

    if (isCubeInited(Coordinates))
    {
        if(isCubeSolid(Coordinates) || isCubeSloped(Coordinates))
        {
            for(Direction DirectionType = AXIAL_DIRECTIONS_START; DirectionType < NUM_AXIAL_DIRECTIONS; ++DirectionType)
            {
                MapCoordinates ModifiedCoordinates = Coordinates;
                ModifiedCoordinates.TranslateMapCoordinates(DirectionType);

                if (DirectionType == DIRECTION_DOWN)
                {
                    if (isCubeSolid(ModifiedCoordinates))
                    {
                        Face* TargetFace = getFace(Coordinates, DirectionType);
                        if (TargetFace == NULL)
                        {
                            TargetFace = addFace(Coordinates, DIRECTION_DOWN);
                        }

                        TargetFace->MaterialTypeID = getCubeMaterial(ModifiedCoordinates);
                        TargetFace->NegativeAxisSurfaceTypeID = RoughFloorID;
                        TargetFace->PositiveAxisSurfaceTypeID = RoughFloorID;
                    }
                    else
                    {
                        removeFace(Coordinates, DirectionType);
                    }
                }
                else
                {
                    if (isCubeSolid(ModifiedCoordinates))
                    {
                        Face* TargetFace = getFace(Coordinates, DirectionType);
                        if (TargetFace == NULL)
                        {
                            TargetFace = addFace(Coordinates, DirectionType);
                        }

                        TargetFace->MaterialTypeID = getCubeMaterial(ModifiedCoordinates);
                        TargetFace->NegativeAxisSurfaceTypeID = getCubeSurfaceType(ModifiedCoordinates);
                        TargetFace->PositiveAxisSurfaceTypeID = getCubeSurfaceType(ModifiedCoordinates);
                    }
                    else
                    {
                        removeFace(Coordinates, DirectionType);
                    }
                }
            }

            setCubeHidden(Coordinates, false);
            setCubeShape(Coordinates, FloorID);

            setCubeMaterial(Coordinates, -1);
        }

        // reveal tiles around
        for(Direction DirectionType = COMPASS_DIRECTIONS_START; DirectionType < NUM_COMPASS_DIRECTIONS; ++DirectionType)
        {
            setCubeHidden(MapCoordinates(Coordinates, DirectionType), false);
        }
    }
}
Esempio n. 7
0
void Cell::BuildFaceData()
{
	Map* ParentMap = GAME->getMap();
    MapCoordinates TargetMapCoordinates;
    bool Debug = true;

    CubeCoordinates TargetCube = 0;
    do
    {
        CubeShape Shape = getCubeShape(TargetCube);
        int16_t CubeMaterial = getCubeMaterial(TargetCube);

        //static int16_t NEHEMaterial = DATA->getLabelIndex("MATERIAL_UNINITIALIZED");
        static int16_t WallSurface = DATA->getLabelIndex("SURFACETYPE_ROUGH_WALL");
        static int16_t FloorSurface = DATA->getLabelIndex("SURFACETYPE_ROUGH_FLOOR_1");

        for (uint8_t i = 0, DirectionType = Direction::AXIAL_DIRECTIONS[i]; i < NUM_AXIAL_DIRECTIONS; ++i, DirectionType = Direction::AXIAL_DIRECTIONS[i])
        {
            FaceCoordinates FaceLocation = FaceCoordinates(TargetCube, DirectionType);
            MapCoordinates ModifiedCoordinates = MapCoordinates(thisCellCoordinates, TargetCube);
            ModifiedCoordinates.TranslateMapCoordinates(DirectionType);

            CubeShape AdjacentShape = ParentMap->getCubeShape(ModifiedCoordinates);

            if (!Shape.isSky())
            {
                if (ParentMap->isCubeInited(ModifiedCoordinates) && AdjacentShape.isSky())
                {
                    if (Shape.hasFace(DirectionType))
                    {
                        Face* NewFace = ParentMap->addFace(MapCoordinates(thisCellCoordinates, TargetCube), DirectionType);

                        NewFace->setFaceMaterialType(CubeMaterial);
                        NewFace->setFaceSurfaceType(WallSurface);
                        NewFace->setFaceShapeType(FaceShape(Shape, DirectionType));
                    }
                }

                if (!AdjacentShape.isEmpty())
                {
                    if (DirectionType == DIRECTION_DOWN && Shape.hasFloor())
                    {
                        Face* NewFace = ParentMap->addFace(MapCoordinates(thisCellCoordinates, TargetCube), DirectionType);

                        NewFace->setFaceMaterialType(ParentMap->getCubeMaterial(ModifiedCoordinates));
                        NewFace->setFaceSurfaceType(FloorSurface);
                        NewFace->setFaceShapeType(FaceShape(Shape, DirectionType));
                    }
                }
            }
        }

        if (!Shape.isEmpty() && !Shape.isSolid())
        {
            Face* NewFace = addFace(FaceCoordinates(TargetCube, DIRECTION_NONE));

            NewFace->setFaceMaterialType(CubeMaterial);
            NewFace->setFaceSurfaceType(FloorSurface);
            NewFace->setFaceShapeType(FaceShape(Shape, DIRECTION_NONE));
        }

        TargetCube++;

    }
    while (TargetCube != 0);  // End Loop when Byte rolls over
	Render->setDirty();
}