public override void Initialize(Transform[] objects) { // list because I don't know size here List <Filter> tmpFilters = new List <Filter>(); int index = 0; for (int i = 0; i < objects.Length; i++) { // check performance InventoryComponent invC = objects[i].GetComponent <InventoryComponent>(); InputComponent inpC = objects[i].GetComponent <InputComponent>(); InteractorComponent intC = objects[i].GetComponent <InteractorComponent>(); MovementComponent movC = objects[i].GetComponent <MovementComponent>(); if (invC && inpC && intC && movC) { tmpFilters.Add(new Filter(index, objects[i].gameObject, invC, inpC, intC, movC)); } } filters = tmpFilters.ToArray(); environmentComponent = GetComponentInChildren <EnvironmentComponent>(); transportableComponent = GetComponentInChildren <CartComponent>(); cartInteractable = transportableComponent.GetComponent <InteractableComponent>(); lightComponent = GetComponentInChildren <LightComponent>(); //villagerComponent = GetComponentInChildren<VillagerComponent>(); travelComponent = GetComponentInChildren <TravelComponent>(); treeComponents = GetComponentsInChildren <CollectibleComponent>(); goapSystem = GetComponent <GOAPSystem>(); navMeshComponent = playerGO.GetComponent <NavMeshComponent>(); }
public static void AssignPlayerNav() { GameObject player = GameObject.FindGameObjectWithTag("Player"); GameObject environment = GameObject.FindGameObjectWithTag("Environment"); NavMeshComponent navComp = player.GetComponent <NavMeshComponent>(); if (player.GetComponent <NavMeshAgent>() == null) { player.AddComponent <NavMeshAgent>(); } if (navComp == null) { player.AddComponent <NavMeshComponent>(); } if (navComp != null && navComp.surface == null && player.GetComponent <NavMeshAgent>() != null) { environment.AddComponent <NavMeshSurface>().transform.position = player.GetComponent <NavMeshAgent>().transform.position; navComp.surface.collectObjects = CollectObjects.Volume; navComp.surface.size = new Vector3(10, 10, 10); navComp.surface.overrideTileSize = true; navComp.surface.tileSize = 16; } }
public static void AssignEnemyNav() { GameObject[] enemies = GameObject.FindGameObjectsWithTag("Enemy"); GameObject environment = GameObject.FindGameObjectWithTag("Environment"); for (int i = 0; i < enemies.Length; i++) { NavMeshComponent navComp = enemies[i].GetComponent <NavMeshComponent>(); if (enemies[i].GetComponent <NavMeshAgent>() == null) { enemies[i].AddComponent <NavMeshAgent>(); } if (enemies[i].GetComponent <NavMeshComponent>() == null) { enemies[i].AddComponent <NavMeshComponent>(); } if (enemies[i].GetComponent <NavMeshComponent>() != null && enemies[i].GetComponent <NavMeshComponent>().surface == null && enemies[i].GetComponent <NavMeshAgent>() != null) { foreach (GameObject e in enemies) { environment.AddComponent <NavMeshSurface>().transform.position = enemies[i].GetComponent <NavMeshAgent>().transform.position; navComp.surface.collectObjects = CollectObjects.Volume; navComp.surface.size = new Vector3(10, 10, 10); navComp.surface.overrideTileSize = true; navComp.surface.tileSize = 16; } } } }
public virtual void Init(CharacterBase myCharacter) { m_myCharacter = myCharacter; m_NavComponent = Common.GetOrAddComponent <NavMeshComponent>(gameObject); m_NavComponent.Init(m_myCharacter); ChangeState(m_DefaultState); }
public Filter( int id, GameObject go, NavMeshComponent navComp ) { this.id = id; gameObject = go; navMeshComponent = navComp; }
public override void Tick(float deltaTime) { for (int i = 0; i < filters.Length; i++) { // cache variables Filter filter = filters[i]; NavMeshComponent navMeshComponent = filter.navMeshComponent; if (Vector3.Distance(navMeshComponent.transform.position, navMeshComponent.surface.transform.position) >= navMeshComponent.distanceThreshold) { UpdateNavMesh(navMeshComponent); } } }
public void BuildCorridorNavMesh(NavMesh navMesh) { if (direction == Direction.North || direction == Direction.South) { navMeshComponent = new NavMeshComponent(new Vector2(xPos + 1, yPos + corridorLength), new Vector2(xPos + 3, yPos + corridorLength), new Vector2(xPos + 1, yPos - 1), new Vector2(xPos + 3, yPos - 1)); navMesh.AddNavMeshComponent(navMeshComponent); } else { navMeshComponent = new NavMeshComponent(new Vector2(xPos - 1, yPos + 3), new Vector2(xPos + corridorLength, yPos + 3), new Vector2(xPos - 1, yPos + 1), new Vector2(xPos + corridorLength, yPos + 1)); navMesh.AddNavMeshComponent(navMeshComponent); } }
public override void Initialize(Transform[] objects) { List <Filter> tmpFilters = new List <Filter>(); int index = 0; for (int i = 0; i < objects.Length; i++) { NavMeshComponent navMeshComponent = objects[i].GetComponent <NavMeshComponent>(); if (navMeshComponent) { tmpFilters.Add(new Filter(index, objects[i].gameObject, navMeshComponent)); navMeshComponent.surface.BuildNavMesh(); navMeshComponent.OnUpdateNavMesh += UpdatePlayerNavMesh; } } filters = tmpFilters.ToArray(); }
public void Initialize() { if (!initialized) { return; } Transform[] worldObjects = GetComponentsInChildren <Transform>(); inputSystem.Initialize(worldObjects); InputComponent inpC = playerObject.GetComponent <InputComponent>(); HealthComponent healthC = playerObject.GetComponent <HealthComponent>(); InteractorComponent intC = playerObject.GetComponent <InteractorComponent>(); MovementComponent moveC = playerObject.GetComponent <MovementComponent>(); InventoryComponent invC = playerObject.GetComponent <InventoryComponent>(); GameManagerComponent gmC = playerObject.GetComponent <GameManagerComponent>(); AnimationComponent animC = playerObject.GetComponent <AnimationComponent>(); PlayerStoryComponent storyBeatC = playerObject.GetComponent <PlayerStoryComponent>(); PlayerEventComponent eventC = playerObject.GetComponent <PlayerEventComponent>(); GatheringComponent gatC = playerObject.GetComponent <GatheringComponent>(); UIComponent uiC = playerObject.GetComponent <UIComponent>(); NavMeshComponent nmC = playerObject.GetComponent <NavMeshComponent>(); LightComponent lC = playerObject.GetComponent <LightComponent>(); VFXComponent vfxC = playerObject.GetComponent <VFXComponent>(); CombatComponent cC = playerObject.GetComponent <CombatComponent>(); AudioComponent aC = playerObject.GetComponent <AudioComponent>(); ConditionsComponent conC = playerObject.GetComponent <ConditionsComponent>(); PlayerFilter pf = new PlayerFilter( playerObject, inpC, healthC, intC, moveC, invC, gmC, animC, storyBeatC, eventC, gatC, uiC, nmC, lC, vfxC, cC, aC, conC); sbs = GetComponent <StoryBeatSystem>(); for (int i = 0; i < systems.Length; i++) { systems[i].player = pf; systems[i].Initialize(worldObjects); systems[i].SetupInputComponent(inputSystem.inputComponent); } }
public PlayerFilter( GameObject go, InputComponent inputC, HealthComponent healthC, InteractorComponent interactC, MovementComponent moveC, InventoryComponent inventoryC, GameManagerComponent gmc, AnimationComponent animC, PlayerStoryComponent psC, PlayerEventComponent peC, GatheringComponent gC, UIComponent uiC, NavMeshComponent nmC, LightComponent lC, VFXComponent vfxC, CombatComponent cC, AudioComponent aC, ConditionsComponent conC) { this.go = go; inputComponent = inputC; healthComponent = healthC; interactorComponent = interactC; movementComponent = moveC; inventoryComponent = inventoryC; gameManagerComponent = gmc; animationComponent = animC; playerStoryComponent = psC; eventComponent = peC; gatheringComponent = gC; uiComponent = uiC; navMeshComponent = nmC; lightComponent = lC; vfxComponent = vfxC; combatComponent = cC; audioComponent = aC; conditionsComponent = conC; }
public NavMeshGateway(NavMeshComponent navMeshComponent1, NavMeshComponent navMeshComponent2) { this.navMeshComponent1 = navMeshComponent1; this.navMeshComponent2 = navMeshComponent2; }
public void AddNavMeshComponent(NavMeshComponent navMeshComponent) { navMeshComponents.Add(navMeshComponent); }
private void UpdateNavMesh(NavMeshComponent navMeshComponent) { navMeshComponent.surface.RemoveData(); navMeshComponent.surface.transform.position = navMeshComponent.transform.position; navMeshComponent.surface.BuildNavMesh(); }
public void BuildRoomNavMesh(NavMesh navMesh) { navMeshComponent = new NavMeshComponent(new Vector2(xPos + 1, yPos + roomHeight - 2), new Vector2(xPos + roomWidth - 2, yPos + roomHeight - 2), new Vector2(xPos + 1, yPos + 1), new Vector2(xPos + roomWidth - 2, yPos + 1)); navMesh.AddNavMeshComponent(navMeshComponent); }