private void DisplayLootUIElement(CollectibleComponent collectible) { string interactString = " to gather " + collectible.baseCollectible.name; player.uiComponent.gatheringPrompt.gatherTXT.text = interactString; player.eventComponent.OnDisplayUIElement(player.uiComponent.gatheringPrompt.gameObject, false); }
public void RemoveFromInventoryUI(CollectibleComponent br) { int slotIndex = 10; for (int i = 0; i < slots.Length; i++) { if (slots[i].image.sprite == br.baseCollectible.GuiSprite) { slotIndex = i; } } if (slotIndex > 6) { } else { if (slots[slotIndex].image.sprite != StandardSprite && slotIndex < slots.Length) { slots[slotIndex].amount -= 1; if (slots[slotIndex].amount < 1) { sprites[slotIndex].sprite = StandardSprite; // slots[slotIndex].GetComponent<RectTransform>().sizeDelta = slotSize; } slots[slotIndex].amountTXT.text = slots[slotIndex].amount.ToString(); if (slots[slotIndex].amount < 1) { slots[slotIndex].amountTXT.text = ""; // slots[slotIndex].GetComponent<RectTransform>().sizeDelta = slotSize; } } } }
public bool RemoveItemFromInventory(CollectibleComponent item, int HowManyToRemove) { if (DoesThisManyItemExist(item.baseCollectible, HowManyToRemove)) { for (int i = 0; i < InventoryBag.Count; i++) { //if (InventoryBag[i] != null) //{ if (InventoryBag[i].itemType.baseCollectible == item.baseCollectible) { if (InventoryBag[i].amountOfItem == HowManyToRemove) { InventoryBag[i].AdjustAmount(-HowManyToRemove); InventoryBag[i] = tempColl; } else if (InventoryBag[i].amountOfItem > HowManyToRemove) { InventoryBag[i].AdjustAmount(-HowManyToRemove); } break; } // } } return(true); } else { return(false); } }
public void UpdateInventory(CollectibleComponent br) { for (int i = 0; i < slots.Length; i++) { if (slots[i].image.sprite == br.baseCollectible.GuiSprite) { slots[i].amount += br.Quantity; slots[i].amountTXT.text = slots[i].amount.ToString(); // slots[i].GetComponent<RectTransform>().sizeDelta = slotSize; return; } } for (int i = 0; i < slots.Length; i++) { if (slots[i].image.sprite == StandardSprite) { slots[i].image.sprite = br.baseCollectible.GuiSprite; slots[i].amount += br.Quantity; slots[i].amountTXT.text = slots[i].amount.ToString(); // slots[i].GetComponent<RectTransform>().sizeDelta = slotSize; return; } //else if (slots[i].image.sprite == br.baseCollectible.GuiSprite) //{ // slots[i].amount += br.Quantity; // slots[i].amountTXT.text = slots[i].amount.ToString(); // break; //} } }
private void DisplayGatherPrompt(CollectibleComponent collectible) { string interactString = "hold [A] " + collectible.interactionString; player.uiComponent.gatheringPrompt.gatherTXT.text = interactString; player.uiComponent.gatheringPrompt.gameObject.SetActive(true); player.uiComponent.currentlyDisplayedGatherPrompt = player.uiComponent.gatheringPrompt; }
void FindVisibleTargets() { Collider[] targetsInViewRadius = Physics.OverlapSphere( player.go.transform.position, player.gatheringComponent.viewRadius, player.gatheringComponent.targetMask); for (int i = 0; i < targetsInViewRadius.Length; i++) { CollectibleComponent c = targetsInViewRadius[i].GetComponent <CollectibleComponent>(); if (c == null) { return; } Vector3 dirToTarget = (c.transform.position - player.go.transform.position).normalized; if (Vector3.Angle(player.go.transform.forward, dirToTarget) < player.gatheringComponent.viewAngle / 2) { if (!player.gatheringComponent.nearbyCollectibles.Contains(c)) { player.gatheringComponent.nearbyCollectibles.Add(c); DisplayLootUIElement(c); } } } foreach (CollectibleComponent c in player.gatheringComponent.nearbyCollectibles) { if (!c.gameObject.activeSelf) { player.gatheringComponent.nearbyCollectibles.Remove(c); player.eventComponent.OnHideUIElement(player.uiComponent.gatheringPrompt.gameObject); break; } /*float dst = Vector3.Distance( * c.transform.position, * player.go.transform.position);*/ Vector3 dirToTarget = (c.transform.position - player.go.transform.position).normalized; if (Vector3.Angle(player.go.transform.forward, dirToTarget) > player.gatheringComponent.viewAngle / 2) { player.gatheringComponent.nearbyCollectibles.Remove(c); player.eventComponent.OnHideUIElement(player.uiComponent.gatheringPrompt.gameObject); break; } } }
public bool AddtoInventroy(CollectibleComponent item, InventoryComponent componentThatHoldsTheInventory, int resourceAmount) { //if (componentThatHoldsTheInventory.InventoryBag.Count <= componentThatHoldsTheInventory.MaxInventorySpace) for (int i = 0; i < componentThatHoldsTheInventory.InventoryBag.Count; i++) { // componentThatHoldsTheInventory.InventoryBag[i].itemType = item; if (componentThatHoldsTheInventory.InventoryBag[i].itemType.baseCollectible == item.baseCollectible) { if (componentThatHoldsTheInventory.invUI) { componentThatHoldsTheInventory.invUI.UpdateInventory(item); } componentThatHoldsTheInventory.InventoryBag[i].AdjustAmount(resourceAmount); return(true); } } for (int i = 0; i < componentThatHoldsTheInventory.InventoryBag.Count; i++) { if (componentThatHoldsTheInventory.InventoryBag[i] == componentThatHoldsTheInventory.tempColl) { //for (int y = 0; y < componentThatHoldsTheInventory.InventoryBag.Count; y++) //{ // //if (componentThatHoldsTheInventory.InventoryBag[i] != null) // //{ // if (componentThatHoldsTheInventory.InventoryBag[y].itemType == item) // { // if (componentThatHoldsTheInventory.invUI) // componentThatHoldsTheInventory.invUI.UpdateInventory(item); // componentThatHoldsTheInventory.InventoryBag[y].AdjustAmount(resourceAmount); // return true; // } // // } //} InventoryComponent.itemClass tempitem = new InventoryComponent.itemClass(); //tempitem.item = item; tempitem.SetAmount(resourceAmount); if (componentThatHoldsTheInventory.invUI) { componentThatHoldsTheInventory.invUI.UpdateInventory(item); } tempitem.itemType = item; componentThatHoldsTheInventory.InventoryBag[i] = tempitem; return(true); } } return(false); }
void CreateItem(CollectibleComponent finalItem) { CollectibleComponent newItem; newItem = finalItem; //Do thing with item, add to inventory? //cartComponent.GetComponent<InventoryComponent>().AddtoInventroy(newItem,cartComponent.GetComponent<InventoryComponent>(), newItem.Quantity); if (finalItem.TypeofCollectible == CollectibleComponent.CollectibleType.BATTLEPOTION) { player.inventoryComponent.AddtoInventroy(newItem, player.inventoryComponent, newItem.Quantity); } else { cartComponent.GetComponent <InventoryComponent>().AddtoInventroy(newItem, cartComponent.GetComponent <InventoryComponent>(), newItem.Quantity); } //return newItem; }
private void GatherResource(CollectibleComponent resource, InventoryComponent ic) { player.inventoryComponent.AddtoInventroy(resource, player.inventoryComponent, resource.Quantity); player.uiComponent.groceryList.UpdateList(); pickedUpItem.Add(resource); //player.eventComponent.OnHidePreviousGatherPrompt(); isGathering = false; player.eventComponent.OnGatherResource(); /* * if (resource == mushroomResource) * { * player.gatheringComponent.mushroomAmount++; * } * else if (resource == flowerResource) * { * player.gatheringComponent.flowerAmount++; * }*/ }
public static Entity CreateItem(EntityModel model) { var item = new Entity { Name = model.Name, Id = model.Id, Model = model }; if (atlas == null) { atlas = SKTextureAtlas.FromName("Items"); } var spriteComp = new ItemSpriteComponent(atlas.TextureNamed(model.TextureName), item); item.AddComponent(spriteComp); var clickableComp = new ClickableComponent(); item.AddComponent(clickableComp); var lookableComp = new LookableComponent(); item.AddComponent(lookableComp); var collectableComp = new CollectibleComponent(); item.AddComponent(collectableComp); var giveableComp = new GiveableComponent(); item.AddComponent(giveableComp); var useableComp = new UseableComponent(); item.AddComponent(useableComp); items [item.Id] = item; return(item); }
/* * public void UpdateCurrentResourcesTexts() * { * GatheringComponent gc = player.GetComponent<GatheringComponent>(); * //mushroomTXT.text = .ToString(); * //flowerTXT.text = gc.flowerAmount.ToString(); * //cart.GetComponent<InventoryComponent>().InventoryBag. * } */ public bool CraftPotion(CollectibleComponent finalQuestPotion, int amount) { GatheringComponent gc = player.GetComponent <GatheringComponent>(); for (int i = 0; i < cart.GetComponent <InventoryComponent>().InventoryBag.Count; i++) { if (cart.GetComponent <InventoryComponent>().InventoryBag[i].itemType == finalQuestPotion) //player = cart { //Do stuff with quest = complete? if (cart.GetComponent <InventoryComponent>().RemoveItemFromInventory(finalQuestPotion, amount)) { //you turned in the quest! gc.hasPurificationPotion = true;//ful bool, obselete, enbart för testing } else { //You did't manage to complete the quest! } } } return(false); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { AggregateFactory = new AggregateFactory(this); WeaponFactory = new WeaponFactory(this); DoorFactory = new DoorFactory(this); RoomFactory = new RoomFactory(this); CollectableFactory = new CollectibleFactory(this); WallFactory = new WallFactory(this); EnemyFactory = new EnemyFactory(this); SkillEntityFactory = new SkillEntityFactory(this); NPCFactory = new NPCFactory(this); // Initialize Components PlayerComponent = new PlayerComponent(); LocalComponent = new LocalComponent(); RemoteComponent = new RemoteComponent(); PositionComponent = new PositionComponent(); MovementComponent = new MovementComponent(); MovementSpriteComponent = new MovementSpriteComponent(); SpriteComponent = new SpriteComponent(); DoorComponent = new DoorComponent(); RoomComponent = new RoomComponent(); HUDSpriteComponent = new HUDSpriteComponent(); HUDComponent = new HUDComponent(); InventoryComponent = new InventoryComponent(); InventorySpriteComponent = new InventorySpriteComponent(); ContinueNewGameScreen = new ContinueNewGameScreen(graphics, this); EquipmentComponent = new EquipmentComponent(); WeaponComponent = new WeaponComponent(); BulletComponent = new BulletComponent(); PlayerInfoComponent = new PlayerInfoComponent(); WeaponSpriteComponent = new WeaponSpriteComponent(); StatsComponent = new StatsComponent(); EnemyAIComponent = new EnemyAIComponent(); NpcAIComponent = new NpcAIComponent(); CollectibleComponent = new CollectibleComponent(); CollisionComponent = new CollisionComponent(); TriggerComponent = new TriggerComponent(); EnemyComponent = new EnemyComponent(); NPCComponent = new NPCComponent(); //QuestComponent = new QuestComponent(); LevelManager = new LevelManager(this); SpriteAnimationComponent = new SpriteAnimationComponent(); SkillProjectileComponent = new SkillProjectileComponent(); SkillAoEComponent = new SkillAoEComponent(); SkillDeployableComponent = new SkillDeployableComponent(); SoundComponent = new SoundComponent(); ActorTextComponent = new ActorTextComponent(); TurretComponent = new TurretComponent(); TrapComponent = new TrapComponent(); ExplodingDroidComponent = new ExplodingDroidComponent(); HealingStationComponent = new HealingStationComponent(); PortableShieldComponent = new PortableShieldComponent(); PortableStoreComponent = new PortableStoreComponent(); ActiveSkillComponent = new ActiveSkillComponent(); PlayerSkillInfoComponent = new PlayerSkillInfoComponent(); Quests = new List<Quest>(); #region Initialize Effect Components AgroDropComponent = new AgroDropComponent(); AgroGainComponent = new AgroGainComponent(); BuffComponent = new BuffComponent(); ChanceToSucceedComponent = new ChanceToSucceedComponent(); ChangeVisibilityComponent = new ChangeVisibilityComponent(); CoolDownComponent = new CoolDownComponent(); DamageOverTimeComponent = new DamageOverTimeComponent(); DirectDamageComponent = new DirectDamageComponent(); DirectHealComponent = new DirectHealComponent(); FearComponent = new FearComponent(); HealOverTimeComponent = new HealOverTimeComponent(); InstantEffectComponent = new InstantEffectComponent(); KnockBackComponent = new KnockBackComponent(); TargetedKnockBackComponent = new TargetedKnockBackComponent(); ReduceAgroRangeComponent = new ReduceAgroRangeComponent(); ResurrectComponent = new ResurrectComponent(); StunComponent = new StunComponent(); TimedEffectComponent = new TimedEffectComponent(); EnslaveComponent = new EnslaveComponent(); CloakComponent = new CloakComponent(); #endregion base.Initialize(); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { AggregateFactory = new AggregateFactory(this); WeaponFactory = new WeaponFactory(this); DoorFactory = new DoorFactory(this); RoomFactory = new RoomFactory(this); CollectableFactory = new CollectibleFactory(this); WallFactory = new WallFactory(this); EnemyFactory = new EnemyFactory(this); SkillEntityFactory = new SkillEntityFactory(this); NPCFactory = new NPCFactory(this); // Initialize Components PlayerComponent = new PlayerComponent(); LocalComponent = new LocalComponent(); RemoteComponent = new RemoteComponent(); PositionComponent = new PositionComponent(); MovementComponent = new MovementComponent(); MovementSpriteComponent = new MovementSpriteComponent(); SpriteComponent = new SpriteComponent(); DoorComponent = new DoorComponent(); RoomComponent = new RoomComponent(); HUDSpriteComponent = new HUDSpriteComponent(); HUDComponent = new HUDComponent(); InventoryComponent = new InventoryComponent(); InventorySpriteComponent = new InventorySpriteComponent(); ContinueNewGameScreen = new ContinueNewGameScreen(graphics, this); EquipmentComponent = new EquipmentComponent(); WeaponComponent = new WeaponComponent(); BulletComponent = new BulletComponent(); PlayerInfoComponent = new PlayerInfoComponent(); WeaponSpriteComponent = new WeaponSpriteComponent(); StatsComponent = new StatsComponent(); EnemyAIComponent = new EnemyAIComponent(); NpcAIComponent = new NpcAIComponent(); CollectibleComponent = new CollectibleComponent(); CollisionComponent = new CollisionComponent(); TriggerComponent = new TriggerComponent(); EnemyComponent = new EnemyComponent(); NPCComponent = new NPCComponent(); //QuestComponent = new QuestComponent(); LevelManager = new LevelManager(this); SpriteAnimationComponent = new SpriteAnimationComponent(); SkillProjectileComponent = new SkillProjectileComponent(); SkillAoEComponent = new SkillAoEComponent(); SkillDeployableComponent = new SkillDeployableComponent(); SoundComponent = new SoundComponent(); ActorTextComponent = new ActorTextComponent(); TurretComponent = new TurretComponent(); TrapComponent = new TrapComponent(); ExplodingDroidComponent = new ExplodingDroidComponent(); HealingStationComponent = new HealingStationComponent(); PortableShieldComponent = new PortableShieldComponent(); PortableStoreComponent = new PortableStoreComponent(); ActiveSkillComponent = new ActiveSkillComponent(); PlayerSkillInfoComponent = new PlayerSkillInfoComponent(); MatchingPuzzleComponent = new MatchingPuzzleComponent(); pI = new PlayerInfo(); Quests = new List <Quest>(); #region Initialize Effect Components AgroDropComponent = new AgroDropComponent(); AgroGainComponent = new AgroGainComponent(); BuffComponent = new BuffComponent(); ChanceToSucceedComponent = new ChanceToSucceedComponent(); ChangeVisibilityComponent = new ChangeVisibilityComponent(); CoolDownComponent = new CoolDownComponent(); DamageOverTimeComponent = new DamageOverTimeComponent(); DirectDamageComponent = new DirectDamageComponent(); DirectHealComponent = new DirectHealComponent(); FearComponent = new FearComponent(); HealOverTimeComponent = new HealOverTimeComponent(); PsiOrFatigueRegenComponent = new PsiOrFatigueRegenComponent(); InstantEffectComponent = new InstantEffectComponent(); KnockBackComponent = new KnockBackComponent(); TargetedKnockBackComponent = new TargetedKnockBackComponent(); ReduceAgroRangeComponent = new ReduceAgroRangeComponent(); ResurrectComponent = new ResurrectComponent(); StunComponent = new StunComponent(); TimedEffectComponent = new TimedEffectComponent(); EnslaveComponent = new EnslaveComponent(); CloakComponent = new CloakComponent(); #endregion base.Initialize(); }
private void AttemptWorldInteract(InteractorComponent interactorComp, InventoryComponent inventoryComp, LayerMask mask) { bool DontRemoveItemIfFull = false; if (player.gatheringComponent.nearbyCollectibles.Count != 0) { for (int i = 0; i < player.gatheringComponent.nearbyCollectibles.Count; i++) { if (player.gatheringComponent.nearbyCollectibles[i].isGatherable) { CollectibleComponent c = player.gatheringComponent.nearbyCollectibles[i]; // if several items, interact with one most in front of player if (interactedTime >= c.baseCollectible.interactionTime && c.isGatherable) { for (int y = 0; y < player.inventoryComponent.InventoryBag.Count; y++) { if (c.baseCollectible == player.inventoryComponent.InventoryBag[y].itemType.baseCollectible || player.inventoryComponent.InventoryBag[y].itemType.baseCollectible == player.inventoryComponent.tempColl.itemType.baseCollectible) { DontRemoveItemIfFull = true; break; } else { continue; } } //c.baseCollectible.PerformCollectibleEvent(player); if (!c.baseCollectible.PerformCollectibleEvent(player)) { if (DontRemoveItemIfFull) { if (c.TypeofCollectible != CollectibleComponent.CollectibleType.UTILITY) { GatherResource(c, inventoryComp); } player.animationComponent.OnPlayGatherAnimation(); interactedTime = 0f; } } else { /*Light l = c.GetComponentInChildren<Light>(); * * if (l) * { * Debug.Log(l); * if (player.lightComponent.nearbyLights.Contains(l)) * { * player.lightComponent.nearbyLights.Remove(l); * } * }*/ player.eventComponent.OnHidePreviousGatherPrompt(); interactedTime = 0f; } if (DontRemoveItemIfFull) { if (c.baseCollectible.destroyObjectOnPickup) { c.gameObject.SetActive(false); interactedTime = 0f; } player.gatheringComponent.nearbyCollectibles.Remove(c); } interactedTime = 0f; DontRemoveItemIfFull = false; } else if (interactedTime <= c.baseCollectible.interactionTime && c.isGatherable) { interactedTime += Time.deltaTime; player.uiComponent.gatheringPrompt.ProgressFill(interactedTime / c.baseCollectible.interactionTime); } if (!c.isGatherable) { isGathering = false; } } } } }
void FindVisibleTargets() { Collider[] targetsInViewRadius = Physics.OverlapSphere( player.go.transform.position, player.interactorComponent.viewRadius, player.interactorComponent.targetMask); for (int i = 0; i < targetsInViewRadius.Length; i++) { InteractableComponent interactable = targetsInViewRadius[i].GetComponent <InteractableComponent>(); if (interactable == null) { return; } Vector3 dirToTarget = (interactable.transform.position - player.go.transform.position).normalized; if (Vector3.Angle(player.go.transform.forward, dirToTarget) < player.interactorComponent.viewAngle / 2) { if (!player.interactorComponent.nearbyInteractables.Contains(interactable)) { CollectibleComponent c = interactable as CollectibleComponent; if (c) { if (!player.gatheringComponent.nearbyCollectibles.Contains(c)) { player.gatheringComponent.nearbyCollectibles.Add(c); player.eventComponent.OnDisplayGatherPrompt(c); } } Light lc = interactable.GetComponentInChildren <Light>(); if (lc) { if (!player.lightComponent.nearbyLights.Contains(lc) && lc.enabled) { player.lightComponent.nearbyLights.Add(lc); } } player.interactorComponent.nearbyInteractables.Add(interactable); //DisplayInteractUIElement(c); } } } foreach (InteractableComponent interactable in player.interactorComponent.nearbyInteractables) { if (!interactable.gameObject.activeSelf) { player.interactorComponent.nearbyInteractables.Remove(interactable); player.eventComponent.OnHideUIElement(player.uiComponent.gatheringPrompt.gameObject); break; } float dst = Vector3.Distance( interactable.transform.position, player.go.transform.position); Vector3 dirToTarget = (interactable.transform.position - player.go.transform.position).normalized; if (dst > 4 || Vector3.Angle(player.go.transform.forward, dirToTarget) > player.interactorComponent.viewAngle / 2) { CollectibleComponent c = interactable as CollectibleComponent; if (c) { if (player.gatheringComponent.nearbyCollectibles.Contains(c)) { player.gatheringComponent.nearbyCollectibles.Remove(c); player.eventComponent.OnHidePreviousGatherPrompt(); } } Light lc = interactable.GetComponentInChildren <Light>(); if (lc) { if (player.lightComponent.nearbyLights.Contains(lc)) { player.lightComponent.nearbyLights.Remove(lc); } } player.interactorComponent.nearbyInteractables.Remove(interactable); player.eventComponent.OnHideUIElement(player.uiComponent.gatheringPrompt.gameObject); break; } } }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { AggregateFactory = new AggregateFactory(this); WeaponFactory = new WeaponFactory(this); DoorFactory = new DoorFactory(this); RoomFactory = new RoomFactory(this); CollectableFactory = new CollectibleFactory(this); WallFactory = new WallFactory(this); EnemyFactory = new EnemyFactory(this); // Initialize Components PlayerComponent = new PlayerComponent(); LocalComponent = new LocalComponent(); RemoteComponent = new RemoteComponent(); PositionComponent = new PositionComponent(); MovementComponent = new MovementComponent(); MovementSpriteComponent = new MovementSpriteComponent(); SpriteComponent = new SpriteComponent(); DoorComponent = new DoorComponent(); RoomComponent = new RoomComponent(); HUDSpriteComponent = new HUDSpriteComponent(); HUDComponent = new HUDComponent(); InventoryComponent = new InventoryComponent(); InventorySpriteComponent = new InventorySpriteComponent(); ContinueNewGameScreen = new ContinueNewGameScreen(graphics, this); EquipmentComponent = new EquipmentComponent(); WeaponComponent = new WeaponComponent(); BulletComponent = new BulletComponent(); PlayerInfoComponent = new PlayerInfoComponent(); WeaponSpriteComponent = new WeaponSpriteComponent(); StatsComponent = new StatsComponent(); EnemyAIComponent = new EnemyAIComponent(); CollectibleComponent = new CollectibleComponent(); CollisionComponent = new CollisionComponent(); TriggerComponent = new TriggerComponent(); EnemyComponent = new EnemyComponent(); QuestComponent = new QuestComponent(); LevelManager = new LevelManager(this); SpriteAnimationComponent = new SpriteAnimationComponent(); SkillProjectileComponent = new SkillProjectileComponent(); SkillAoEComponent = new SkillAoEComponent(); SkillDeployableComponent = new SkillDeployableComponent(); //TurretComponent = new TurretComponent(); //TrapComponent = new TrapComponent(); //PortableShopComponent = new PortableShopComponent(); //PortableShieldComponent = new PortableShieldComponent(); //MotivateComponent = new MotivateComponent(); //FallbackComponent = new FallbackComponent(); //ChargeComponent = new ChargeComponent(); //HealingStationComponent = new HealingStationComponent(); //ExplodingDroidComponent = new ExplodingDroidComponent(); base.Initialize(); }