Skip to content

Commit

Permalink
Commit1
Browse files Browse the repository at this point in the history
  • Loading branch information
OumaimaBoughdad committed Jun 8, 2024
1 parent d67cc91 commit 254024d
Show file tree
Hide file tree
Showing 10 changed files with 10,293 additions and 7,131 deletions.
48 changes: 48 additions & 0 deletions Assets/BossSpawner.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Tilemaps;

public class BossSpawner : MonoBehaviour
{
public Tilemap floorTilemap; // Reference to the tilemap containing floor tiles

// Start is called before the first frame update
void Start()
{
SpawnBossAtRandomPosition();
}

void SpawnBossAtRandomPosition()
{
BoundsInt bounds = floorTilemap.cellBounds;
List<Vector3Int> validFloorPositions = new List<Vector3Int>();

// Iterate through all cells in the bounds to find floor tiles
for (int x = bounds.xMin; x < bounds.xMax; x++)
{
for (int y = bounds.yMin; y < bounds.yMax; y++)
{
Vector3Int currentPos = new Vector3Int(x, y, 0);
if (floorTilemap.HasTile(currentPos))
{
validFloorPositions.Add(currentPos);
}
}
}

// Select a random floor position
if (validFloorPositions.Count > 0)
{
Vector3Int randomFloorPosition = validFloorPositions[Random.Range(0, validFloorPositions.Count)];
Vector3 spawnPosition = floorTilemap.CellToWorld(randomFloorPosition) + new Vector3(0.5f, 0.5f, 0f); // Adjust for tile center

// Move the boss to the selected position
transform.position = spawnPosition;
}
else
{
Debug.LogWarning("No valid floor positions found for boss spawn.");
}
}
}
2 changes: 2 additions & 0 deletions Assets/BossSpawner.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 34 additions & 2 deletions Assets/Prefabs/Enemy.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ GameObject:
- component: {fileID: 2918295985344359354}
- component: {fileID: -2957314058659404076}
- component: {fileID: 1844906813745709531}
- component: {fileID: 7496125882379246537}
- component: {fileID: 8637686118705625460}
m_Layer: 0
m_Name: Enemy
m_TagString: Enemy
Expand Down Expand Up @@ -119,7 +121,7 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5942605033862811311}
m_Enabled: 1
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 46baf7b8974711b4b844afbe61d82066, type: 3}
m_Name:
Expand All @@ -133,7 +135,7 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5942605033862811311}
m_Enabled: 0
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4f018353afe7e584ea50da4bbc2fd68b, type: 3}
m_Name:
Expand Down Expand Up @@ -178,3 +180,33 @@ CapsuleCollider2D:
m_Offset: {x: 0, y: 0}
m_Size: {x: 1.9375, y: 2.1875}
m_Direction: 0
--- !u!114 &7496125882379246537
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5942605033862811311}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ea11a6b6faa14e445a3cf50dbbb7fd76, type: 3}
m_Name:
m_EditorClassIdentifier:
TheFollowed: {fileID: 0}
followerSpeed: 5
animator: {fileID: 0}
--- !u!114 &8637686118705625460
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5942605033862811311}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ae0cdfc5f82c08d47ac0f5fa406acc6a, type: 3}
m_Name:
m_EditorClassIdentifier:
floorTilemap: {fileID: 470011611176001873, guid: 18a0b476819c3f64daca9204e0851e36, type: 3}
wallTilemap: {fileID: 0}
cellSize: 1
277 changes: 277 additions & 0 deletions Assets/Prefabs/Player 1.prefab
Original file line number Diff line number Diff line change
@@ -0,0 +1,277 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &1982641947073638671
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8611562969287616908}
- component: {fileID: 351134532918863842}
- component: {fileID: 3112543308671902406}
- component: {fileID: 765601037215907792}
- component: {fileID: 7076450762560944811}
- component: {fileID: 2388818083735658671}
- component: {fileID: 4915210356326827529}
- component: {fileID: 7085319043430451804}
- component: {fileID: 2960408672335473125}
m_Layer: 0
m_Name: Player 1
m_TagString: Player
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &8611562969287616908
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1982641947073638671}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 10.14, y: 7.09, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &351134532918863842
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1982641947073638671}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 0
m_RayTraceProcedural: 0
m_RayTracingAccelStructBuildFlagsOverride: 0
m_RayTracingAccelStructBuildFlags: 1
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_Sprite: {fileID: 21300000, guid: 0f39a9205e4394ee1b6ba8269428d176, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 2, y: 2}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!50 &3112543308671902406
Rigidbody2D:
serializedVersion: 4
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1982641947073638671}
m_BodyType: 0
m_Simulated: 1
m_UseFullKinematicContacts: 0
m_UseAutoMass: 0
m_Mass: 1
m_LinearDrag: 0
m_AngularDrag: 0.05
m_GravityScale: 0
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_Interpolate: 0
m_SleepingMode: 1
m_CollisionDetection: 0
m_Constraints: 4
--- !u!114 &765601037215907792
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1982641947073638671}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ac9691efec698a049863abfc3159596a, type: 3}
m_Name:
m_EditorClassIdentifier:
playerSpeed: 3
playerBody: {fileID: 3112543308671902406}
animator: {fileID: 7076450762560944811}
maxHealth: 100
currentHealth: 0
healthbar: {fileID: 0}
floorTilemap: {fileID: 0}
wallTilemap: {fileID: 0}
--- !u!95 &7076450762560944811
Animator:
serializedVersion: 7
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1982641947073638671}
m_Enabled: 1
m_Avatar: {fileID: 0}
m_Controller: {fileID: 9100000, guid: d01807f35b2c42345960b8c401a7c092, type: 2}
m_CullingMode: 0
m_UpdateMode: 0
m_ApplyRootMotion: 0
m_LinearVelocityBlending: 0
m_StabilizeFeet: 0
m_AnimatePhysics: 0
m_WarningMessage:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorStateOnDisable: 0
m_WriteDefaultValuesOnDisable: 0
--- !u!70 &2388818083735658671
CapsuleCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1982641947073638671}
m_Enabled: 1
serializedVersion: 3
m_Density: 1
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_ForceSendLayers:
serializedVersion: 2
m_Bits: 4294967295
m_ForceReceiveLayers:
serializedVersion: 2
m_Bits: 4294967295
m_ContactCaptureLayers:
serializedVersion: 2
m_Bits: 4294967295
m_CallbackLayers:
serializedVersion: 2
m_Bits: 4294967295
m_IsTrigger: 1
m_UsedByEffector: 0
m_CompositeOperation: 0
m_CompositeOrder: 0
m_Offset: {x: -0.016467094, y: -0.19431353}
m_Size: {x: 1.5455036, y: 1.822154}
m_Direction: 0
--- !u!114 &4915210356326827529
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1982641947073638671}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ea11a6b6faa14e445a3cf50dbbb7fd76, type: 3}
m_Name:
m_EditorClassIdentifier:
TheFollowed: {fileID: 0}
followerSpeed: 2
animator: {fileID: 7076450762560944811}
--- !u!114 &7085319043430451804
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1982641947073638671}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ae0cdfc5f82c08d47ac0f5fa406acc6a, type: 3}
m_Name:
m_EditorClassIdentifier:
floorTilemap: {fileID: 0}
wallTilemap: {fileID: 0}
cellSize: 1
--- !u!61 &2960408672335473125
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1982641947073638671}
m_Enabled: 1
serializedVersion: 3
m_Density: 1
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_ForceSendLayers:
serializedVersion: 2
m_Bits: 4294967295
m_ForceReceiveLayers:
serializedVersion: 2
m_Bits: 4294967295
m_ContactCaptureLayers:
serializedVersion: 2
m_Bits: 4294967295
m_CallbackLayers:
serializedVersion: 2
m_Bits: 4294967295
m_IsTrigger: 1
m_UsedByEffector: 0
m_CompositeOperation: 0
m_CompositeOrder: 0
m_Offset: {x: -0.016467094, y: -0.18772626}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0.5, y: 0.5}
oldSize: {x: 2, y: 2}
newSize: {x: 2, y: 2}
adaptiveTilingThreshold: 0.5
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
m_Size: {x: 0.82094765, y: 1.3742452}
m_EdgeRadius: 0
7 changes: 7 additions & 0 deletions Assets/Prefabs/Player 1.prefab.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 254024d

Please sign in to comment.