private void Awake() { player = GameObject.FindGameObjectWithTag("Player"); playerManager = player.GetComponent <PlayerManager>(); characterStats = playerManager.player.GetComponent <AllCharacterStats>(); focusController = playerManager.player.GetComponent <FocusController>(); shop = focusController.focus.interactionPoint.GetComponent <Shop>().transform; itemSpawnPos = focusController.focus.interactionPoint.GetComponent <Shop>().itemsSpawnPosition; }
private void Start() { int SlotSize = System.Enum.GetNames(typeof(EquipmentSlots)).Length; equipmentSlot = new EquipmentBlueprint[SlotSize]; // Get player instance playerManager = PlayerManager.Instance.player.GetComponent <PlayerManager>(); characterStats = playerManager.player.GetComponent <AllCharacterStats>(); }
public void Start() { playerManager = PlayerManager.Instance.player.GetComponent <PlayerManager>(); characterStats = playerManager.player.GetComponent <AllCharacterStats>(); focusController = playerManager.player.GetComponent <FocusController>(); if (interactionPoint == null) { interactionPoint = this.transform; } }
public static void SaveData(AllCharacterStats characterStats, Inventory inventory) { BinaryFormatter formatter = new BinaryFormatter(); string path = Application.persistentDataPath + "/Data.bacon"; FileStream stream = new FileStream(path, FileMode.Create); SavedData data = new SavedData(characterStats, inventory); formatter.Serialize(stream, data); stream.Close(); }
// Used the Player Instance Class to avoid slowdowns //private GameObject playerInstance; // In order to avoid having to drag and drop each Gameobject to every single coin we create, // we can use GetComponent and search all the game files for the specific gameobject, this // is not a perfect solution but we only do it once right before the game starts. private void Start() { // Removed this in order to prevent unessesary game slowdowns // Replaced it with an instance of the player in 1 global script //GameObject Player = GameObject.Find("Player"); //focusController = Player.GetComponent<FocusController>(); //characterStats = Player.GetComponent<AllCharacterStats>(); // Get player instance playerManager = PlayerManager.Instance.player.GetComponent <PlayerManager>(); focusController = playerManager.player.GetComponent <FocusController>(); characterStats = playerManager.player.GetComponent <AllCharacterStats>(); }
public void Start() { playerManager = PlayerManager.Instance.player.GetComponent <PlayerManager>(); characterStats = playerManager.player.GetComponent <AllCharacterStats>(); focusController = playerManager.player.GetComponent <FocusController>(); if (interactionPoint == null) { interactionPoint = this.transform; } // set the health on spawn of enemy health = enemy.maxHealth; }
private void Start() { player = GameObject.FindGameObjectWithTag("Player"); characterStats = player.GetComponent <AllCharacterStats>(); if (navigationName == "") { Debug.LogError("ERROR - Ai: Navigation was not assigned!"); } else { spawner = GameObject.Find(navigationName).GetComponent <AiSpawner>(); if (spawner.characterType == CharacterType.Enemy) { for (int i = 0; i < spawner.EnemyBlueprints.Count; i++) { if (this.name == spawner.EnemyBlueprints[i].prefabName) { indexInList = i; totalAttackChance = spawner.EnemyBlueprints[i].smallAttackChance + spawner.EnemyBlueprints[i].bigAttackChance + spawner.EnemyBlueprints[i].critiaclChance; } } } else { for (int i = 0; i < spawner.passiveNPCBlueprints.Count; i++) { if (this.name == spawner.passiveNPCBlueprints[i].prefabName) { indexInList = i; } } } timer = attackTimer; } }
private void Start() { player = GameObject.FindGameObjectWithTag("Player"); characterStats = player.GetComponent <AllCharacterStats>(); inventory = Inventory.InventoryInstance; }
public SavedData(AllCharacterStats characterStats, Inventory inventory) { // player position/rotation position = new float[3]; position[0] = characterStats.transform.position.x; position[1] = characterStats.transform.position.y; position[2] = characterStats.transform.position.z; rotation = new float[4]; rotation[0] = characterStats.transform.rotation.x; rotation[1] = characterStats.transform.rotation.y; rotation[2] = characterStats.transform.rotation.z; rotation[3] = characterStats.transform.rotation.w; // player stats balance = characterStats.Balance; health = characterStats.Health; protection = characterStats.Protection; speed = characterStats.Speed; damage = characterStats.Damage; // player inventory inventorySlots = inventory.InventoryItems.Count; inventoryItems = new List <InventoryItem>(); inventoryEquipment = new List <InventoryEquipment>(); for (int i = 0; i < inventorySlots; i++) { Debug.Log("checking inventory slot at index" + i); if (inventory.GetInventory()[i] != null) { Debug.Log("found item at index " + i); if (inventory.GetInventory()[i].item is EquipmentBlueprint) { InventoryEquipment item = new InventoryEquipment(); EquipmentBlueprint equipBP = inventory.GetInventory()[i].item.equipBP; EquipmentSlots equipmentSlots = equipBP.EquipSlot; item.EquipSlot = equipmentSlots; List <Positives> positives = new List <Positives>(); for (int j = 0; j < equipBP.PositiveTraits.Count; j++) { Positives posTrait = new Positives(); posTrait.traitLevel = equipBP.PositiveTraits[j].traitLevel; posTrait.traits = equipBP.PositiveTraits[j].traits; positives.Add(posTrait); } List <Negatives> negatives = new List <Negatives>(); for (int j = 0; j < equipBP.NegativeTraits.Count; j++) { Negatives negTrait = new Negatives(); negTrait.traitLevel = equipBP.NegativeTraits[j].traitLevel; negTrait.traits = equipBP.NegativeTraits[j].traits; negatives.Add(negTrait); } item.ItemName = equipBP.ItemName; Texture2D tex = equipBP.ItemIcon.texture; exportObj.x = tex.width; exportObj.y = tex.height; exportObj.bytes = ImageConversion.EncodeToPNG(tex); string icon = JsonUtility.ToJson(exportObj, false); item.ItemIcon = icon; item.isDefault = equipBP.isDefault; item.StackUntil = equipBP.StackUntil; item.Bundle = equipBP.Bundle; item.AssetName = equipBP.AssetName; item.ItemDescription = equipBP.ItemDescription; inventoryEquipment.Add(item); } else { InventoryItem item = new InventoryItem(); ItemBlueprint itemBP = inventory.GetInventory()[i].item; item.ItemName = itemBP.ItemName; Texture2D tex = itemBP.ItemIcon.texture; exportObj.x = tex.width; exportObj.y = tex.height; exportObj.bytes = ImageConversion.EncodeToPNG(tex); string icon = JsonUtility.ToJson(exportObj, false); item.ItemIcon = icon; item.isDefault = itemBP.isDefault; item.StackUntil = itemBP.StackUntil; item.Bundle = itemBP.Bundle; item.AssetName = itemBP.AssetName; item.ItemDescription = itemBP.ItemDescription; inventoryItems.Add(item); } } } }
private void Start() { // Get player instance playerManager = PlayerManager.Instance.player.GetComponent <PlayerManager>(); characterStats = playerManager.player.GetComponent <AllCharacterStats>(); }