Ejemplo n.º 1
0
    //When a new item is added.
    public void OnNewItemAddedToPlayerInventory()
    {
        switch (CurrentLevelVariableManagement.GetMainGameData().currentLevel)
        {
        case 0:
            //Check to make sure the objective has not already been completed
            //Wooden Pickaxe Objective
            if (objectives [0].completed == false)
            {
                //Check whether the player has the hatchet.
                if (CurrentLevelVariableManagement.GetMainInventoryReference().GetComponent <InventoryFunctions> ().CheckForCertainInventoryItem(new ResourceReferenceWithStack(ResourceDatabase.GetItemByParameter("Wooden Pickaxe"), 1)) != null)
                {
                    OnObjectiveHasBeenCompleted(1);
                }
            }
//
//			//Wooden Sword Objective
//			if (objectives [3].completed == false) {
//				if (ModifiesSlotContent.DetermineWhetherPlayerHasCertainInventoryItem(new UISlotContentReference(ResourceDatabase.GetItemByParameter ("Wooden Pickaxe"), 1)) != null) {
//					OnObjectiveHasBeenCompleted(4);
//				}
//			}
            break;

        default:
            Debug.LogError("Objective Manager does not have a definition for this level!");
            break;
        }
    }
Ejemplo n.º 2
0
    public override void NPCActionBeforeSpeaking()
    {
        //Check to make sure that the player has not already created fire.
        if (playerHasCreatedFire == false)
        {
            if (CurrentLevelVariableManagement.GetMainObjectiveManager().CheckStateOfObjective(5))               //Check whether the player has created fire;
            {
                playerHasCreatedFire = true;
                string[] dialogue = new string[] {
                    "Nice job!",
                    "I wish you luck on your travels."
                };
                GetComponent <NPCPanelController> ().SetCharacterDialogue(dialogue);
            }
        }

        //Check whether the NPC has talked to the player
        if (talkedToPlayer && playerHasCreatedFire == false)
        {
            string[] dialogue = new string[] {
                "Hello again!  Forgot already?",
                "While on me many travels, I discovered something that will change our lives forever.",
                "I call it FIRE.",
                "Here's how you make it.  Gather some wood.  6 blocks should be enough.",
                "Combine them to make 3 planks.",
                "Then burn a bit of wood to make charcoal, and combine that with the planks."
            };
            GetComponent <NPCPanelController>().SetCharacterDialogue(dialogue);
        }
    }
Ejemplo n.º 3
0
    void StartCountdown()
    {
        //Show the district thing.
        gameObject.SetActive(true);

        //Define the level that will be used locally by checking the current level in the GameData.
        int levelToUse = CurrentLevelVariableManagement.GetMainGameData().currentLevel;

        if (levelToUse + 1 <= levels.Length)
        {
            //Access game data and determine the correct LevelDisplay.
            LevelDisplay levelDisplayToUse = levels [levelToUse];

            //Set the text or image.
            if (levelDisplayToUse.useImageInsteadOfText)
            {
                transform.Find("Image").gameObject.SetActive(true);
                transform.Find("Image").GetComponent <Image> ().sprite = levelDisplayToUse.image;
            }
            else
            {
                transform.Find("Text").gameObject.SetActive(true);
                transform.Find("Text").GetComponent <Text> ().text = levelDisplayToUse.text;
            }

            StartCoroutine(DistrictDisplayingTimer());
        }
        else
        {
            Debug.LogError("No LevelDisplay fit the specified criteria");
        }
    }
Ejemplo n.º 4
0
 public void PickupItem(GameObject item)
 {
     if (playerInventory == null)
     {
         playerInventory = CurrentLevelVariableManagement.GetMainInventoryReference().GetComponent <InventoryFunctions> ();
     }
     //This does not check the resourcereference property of the attached script as a comparison, only the tag.  Consider changing later.
     if (item.CompareTag("ExpNodule"))
     {
         transform.parent.gameObject.GetComponent <PlayerHealthPanelManager> ().OnExperienceNodulePickedUp();
         Destroy(item);
     }
     else if (item.CompareTag("Coin"))
     {
         transform.parent.gameObject.GetComponent <PlayerHealthPanelManager> ().OnCoinPickedUp(1);
         Destroy(item);
     }
     else
     {
         ResourceReferenceWithStack pendingObject = item.GetComponent <DroppedItemProperties> ().localResourceReference;
         if (!playerInventory.AssignNewItemToBestSlot(pendingObject))
         {
             Debug.LogError("ERROR WHEN ASSIGNING OBJECT");
         }
         else
         {
             Destroy(item);
         }
     }
 }
Ejemplo n.º 5
0
    //Used when a player profession is changed.
    public void UpdatePlayerProfession(Profession profession)
    {
        //Update with common gender sprites
        body.sprite       = profession.body;
        idleArm.sprite    = profession.arm;
        holdingArm.sprite = profession.arm;
        topLeg.sprite     = profession.leg;
        bottomLeg.sprite  = profession.leg;

        //Gender check.
        if (CurrentLevelVariableManagement.GetMainGameData().chosenGender == 0)
        {
            head.sprite = profession.maleHead;
        }
        else
        {
            head.sprite = profession.femaleHead;
        }

        //Add the initial items for the profession to the inventory.
        for (int i = 0; i < profession.initialObjects.Length; i++)
        {
            playerInventory.AssignNewItemToBestSlot(profession.initialObjects[i]);
        }
    }
Ejemplo n.º 6
0
    void ShootArrow()
    {
        GameObject playerObject = CurrentLevelVariableManagement.GetPlayerReference();

        float preHeading = attachedCharacterInput.GetActualClass().GetFacingDirection() == 1 ? 0 : 180;

        //Apparently there is some issue with the bow's position when attached to the player object, because it is always (0, 0, 0).  This fixes it.
        GameObject instantiatedArrow = (GameObject)(Instantiate(arrow, attachedCharacterInput.GetActualClass().gameObject.transform.position + new Vector3(1.2f, 0, 0) * attachedCharacterInput.GetActualClass().GetFacingDirection(), Quaternion.identity));

        ProjectileScript instantiatedArrowScript = instantiatedArrow.GetComponent <ProjectileScript> ();

        Vector3 positionToFireToward;
        float   accuracy;

        if (attackPlayer)
        {
            positionToFireToward = playerObject.transform.position;
            accuracy             = 30;
        }
        else
        {
            Vector3 shootDirection;
            shootDirection       = Input.mousePosition;
            shootDirection.z     = 0.0f;
            shootDirection       = Camera.main.ScreenToWorldPoint(shootDirection);
            shootDirection       = shootDirection - transform.position;
            positionToFireToward = shootDirection;
            accuracy             = 0;
        }

        instantiatedArrowScript.InitializeProjectileWithThresholdAndDeviation(positionToFireToward, 12, preHeading, 30, accuracy, attackPowerStrength);
    }
Ejemplo n.º 7
0
    //Initialize Objective References
    void InitializeObjectiveReferences()
    {
        int totalNumberOfObjectives = 2;

        objectives = new ObjectiveReference[totalNumberOfObjectives];
        //Set objective references
        for (int i = 0; i < totalNumberOfObjectives; i++)
        {
            objectives[i] = new ObjectiveReference(transform.Find("Objective " + (i + 1)));
            objectives [i].Reset();
        }
        //Set the button reference.
        continueToNextLevel = transform.Find("Level Continue").Find("Button").GetComponent <Button> ();
        continueToNextLevel.interactable = false;

        //Set initial values.
        switch (CurrentLevelVariableManagement.GetMainGameData().currentLevel)
        {
        case 0:
            objectives [0].icon.sprite      = ResourceDatabase.GetItemByParameter("Subsidiary Reactor Core").itemIcon;
            objectives [0].description.text = "Subsidiary Reactor Core";

            objectives [1].icon.sprite      = ResourceDatabase.GetItemByParameter("Wooden Pickaxe").itemIcon;
            objectives [1].description.text = "Pickaxe";
            break;

        default:
            Debug.LogError("The current level has not been added in ObjectiveManager!");
            break;
        }
    }
    //Required to initialize.
    public void StartPlayerDistanceChecking()
    {
        player             = CurrentLevelVariableManagement.GetPlayerReference().transform;
        mainParticleSystem = GetComponent <ParticleSystem> ();

        //Start the coroutine.
        StartCoroutine(ActivityIsDependentOnPlayerDistance());
    }
Ejemplo n.º 9
0
 //Set references to the playerIcon, start necessary coroutines, etc.
 void InitializeNPCPanelController()
 {
     playerTransform   = CurrentLevelVariableManagement.GetPlayerReference().transform;
     playerIcon        = transform.Find("FlippingItem").Find("Character").Find("Head").GetComponent <SpriteRenderer> ().sprite;
     mainSpeechControl = CurrentLevelVariableManagement.GetLevelUIReference().transform.Find("Speech Bubble").GetComponent <SpeechControl> ();
     mainInteractablePanelController = CurrentLevelVariableManagement.GetLevelUIReference().transform.Find("InteractablePanels").gameObject.GetComponent <InteractablePanelController> ();
     StartCoroutine("CheckForAndAttemptToSpeakToPlayer");
 }
Ejemplo n.º 10
0
    //Assigns a new item to the best possible slot.
    public bool AssignNewItemToBestSlot(ResourceReferenceWithStack item)
    {
        //Has to be here for the return statement
        bool successfullyAssigned = false;

        //Make sure that the prerequisites are met.
        if (initialized && item != null)
        {
            SlotScript bestAvailableSlot = FindBestAvailableSlot(item);

            if (bestAvailableSlot != null)
            {
                //Set successfully assigned.
                successfullyAssigned = true;
                //Add the new stack to the current item stack.
                bestAvailableSlot.ModifyCurrentItemStack(item.stack);
                Debug.Log("Assigned " + item.uiSlotContent.itemScreenName + " to slot with items of same type.");
                //Check whether an objective has been completed
                CurrentLevelVariableManagement.GetMainObjectiveManager().OnNewItemAddedToPlayerInventory();
            }
            else
            {
                Debug.Log("Could not stack item: Attempting to add to an empty slot");
                bestAvailableSlot = FindBestAvailableNullSlot();
                if (bestAvailableSlot != null)
                {
                    successfullyAssigned = true;
                    bestAvailableSlot.AssignNewItem(item);
                    //Update the hotbar item.
                    CurrentLevelVariableManagement.GetLevelUIReference().transform.Find("Hotbar").GetComponent <HotbarManager> ().UpdateSelectedItem();
                    //Check whether an objective has been completed
                    CurrentLevelVariableManagement.GetMainObjectiveManager().OnNewItemAddedToPlayerInventory();
                }
                else
                {
                    Debug.LogError("No slots are empty!");
                }
            }
        }
        else
        {
            if (initialized == false && item == null)
            {
                Debug.LogError("Not initialized and item is null");
            }
            else if (initialized == false)
            {
                Debug.LogError("Not initialized");
            }
            else
            {
                Debug.LogError("Item is null");
            }
        }

        return(successfullyAssigned);
    }
Ejemplo n.º 11
0
    protected override void InitializeCharacter()
    {
        //Set required variables for the enemy to function.
        player = CurrentLevelVariableManagement.GetPlayerReference().transform;

        InitializeEnemy();

        enemyControlCoroutine = EnemyControl();
        StartCoroutine(enemyControlCoroutine);
    }
Ejemplo n.º 12
0
    public void OnFireBuilt()
    {
        switch (CurrentLevelVariableManagement.GetMainGameData().currentLevel)
        {
        case 0:
//			if (objectives[4].completed == false)
//				OnObjectiveHasBeenCompleted(5);
            break;
        }
    }
Ejemplo n.º 13
0
 //Look into initializing this once the player comes into activation distance.
 protected virtual void InitializeHealthBar()
 {
     player        = CurrentLevelVariableManagement.GetPlayerReference().transform;
     currentHealth = lifePoints;
     //Create panel
     uiHealthController = CurrentLevelVariableManagement.GetLevelUIReference().transform.Find("Health Controller").gameObject.GetComponent <UIHealthController> ();
     //Initialize icon
     characterHeadSprite = transform.GetChild(0).GetChild(0).Find("Head").GetComponent <SpriteRenderer> ().sprite;
     //Start the coroutine that manages the active state of the health bar item.
     StartCoroutine(ControlHealthBarState());
 }
Ejemplo n.º 14
0
 protected override void InitializeNPC()
 {
     npcName = "Soldier";
     //Sets the initial dialogue for the player.
     string[] dialogue = new string[] {
         "INTRUDER!",
         "Follow us.  We will take you to leader."
     };
     GetComponent <NPCPanelController> ().SetCharacterDialogue(dialogue);
     player = CurrentLevelVariableManagement.GetPlayerReference().GetComponent <PlayerAction> ();
 }
Ejemplo n.º 15
0
 //Done during the InitializePurchasePanels phase (no real dependencies).
 void InitializePurchasePanelReference()
 {
     //Define required components.
     currentItemIcon = transform.Find("Animation Controller").Find("Item Icon").GetComponent <SpriteRenderer> ();
     cost            = transform.Find("Animation Controller").Find("Value").Find("Cost").GetComponent <TextMesh> ();
     //Not accessible in the editor, but can be modified via code.  (Looks weird otherwise).
     cost.GetComponent <MeshRenderer> ().sortingLayerName = "PPanelFront";
     cost.GetComponent <MeshRenderer> ().sortingOrder     = 0;
     player          = CurrentLevelVariableManagement.GetPlayerReference().transform;
     playerInventory = CurrentLevelVariableManagement.GetMainInventoryReference().gameObject.GetComponent <InventoryFunctions> ();
     StartCoroutine(CheckForPurchase());
 }
Ejemplo n.º 16
0
    //Initializing the NPC
    protected override void InitializeCharacter()
    {
        //Get required components.
        playerTransform = CurrentLevelVariableManagement.GetPlayerReference().transform;
        playerInventory = CurrentLevelVariableManagement.GetMainInventoryReference().GetComponent <InventoryFunctions> ();

        //Initialize the NPC before starting to walk around.
        InitializeNPC();
        //Create and start the coroutine.
        walkAroundCoroutine = WalkAround();
        StartCoroutine(walkAroundCoroutine);
    }
Ejemplo n.º 17
0
    public void TreeChopped()
    {
        currentlyActiveSegments--;
        UpdateTree();
        DropItems();
        if (currentlyActiveSegments == 0)
        {
            Destroy(gameObject);
        }

        CurrentLevelVariableManagement.GetMainObjectiveManager().OnTreeChopped();
    }
Ejemplo n.º 18
0
    //When an item drop hits the player.
    void OnTriggerEnter2D(Collider2D externalTrigger)
    {
        if (playerInventory == null)
        {
            playerInventory = CurrentLevelVariableManagement.GetMainInventoryReference().GetComponent <InventoryFunctions> ();
        }

        if (((externalTrigger.gameObject.GetComponent <DroppedItemProperties> () != null || externalTrigger.gameObject.CompareTag("Coin") ||
              externalTrigger.gameObject.CompareTag("ExpNodule"))) && playerInventory.IsInitialized())
        {
            PickupItem(externalTrigger.gameObject);
        }
    }
Ejemplo n.º 19
0
    /******************************* MOUSE CLICK MANAGER *******************************/

    public void OnPointerClick(PointerEventData data)
    {
        if (data.button == PointerEventData.InputButton.Left)
        {
            if (currentlyAssigned != null)
            {
                if (CurrentLevelVariableManagement.GetPlayerReference().GetComponent <PlayerHealthPanelManager> ().GiveMoneyToPlayer(-currentlyAssigned.price))
                {
                    //Add the deassigned item to the player inventory and deduct the price of the item.
                    CurrentLevelVariableManagement.GetMainInventoryReference().GetComponent <InventoryFunctions> ().AssignNewItemToBestSlot(new ResourceReferenceWithStack(currentlyAssigned.mainContentReference.uiSlotContent, 1));
                    ModifyCurrentItemStack(-1);
                }
            }
        }
    }
Ejemplo n.º 20
0
    //When a tree is chopped.  Possibly consider counting this as a stat: i.e. trees chopped during game.
    public void OnTreeChopped()
    {
        switch (CurrentLevelVariableManagement.GetMainGameData().currentLevel)
        {
        case 0:
//			if (objectives [1].completed == false) {
//				OnObjectiveHasBeenCompleted (2);
//			}
            break;

        default:
            Debug.LogError("Objective Manager does not have a definition for this level!");
            break;
        }
    }
Ejemplo n.º 21
0
    protected override void InitializeNPC()
    {
        //Find and hide the inventory.
        merchantInventory = CurrentLevelVariableManagement.GetLevelUIReference().transform.Find("Merchant Inventory").GetComponent <MerchantInventoryFunctions> ();

        //Define the UISlotContent items that will be added to the inventory.
        merchantItems     = new ResourceReferenceWithStackAndPrice[2];
        merchantItems [0] = new ResourceReferenceWithStackAndPrice(new ResourceReferenceWithStack(ResourceDatabase.GetItemByParameter("Wooden Hatchet"), 1), 10);
        merchantItems [1] = new ResourceReferenceWithStackAndPrice(new ResourceReferenceWithStack(ResourceDatabase.GetItemByParameter("Diamond Sword"), 2), 20);

        string[] dialogue = new string[] {
            "Purchase any item you like!",
            "Everything is cheap at Sluk's Hardware Store!"
        };
        GetComponent <NPCPanelController> ().SetCharacterDialogue(dialogue);
    }
Ejemplo n.º 22
0
 //Called whenever the specified action (by the dictionary) occurs.
 public override void InfluenceEnvironment(MovementAndMethod.PossibleMovements actionKey)
 {
     if (physicalFireObject != null)
     {
         //Create the object.
         Vector3    physicalFireOffset = new Vector3(1, 0, 0) * CurrentLevelVariableManagement.GetPlayerReference().GetComponent <PlayerAction> ().GetFacingDirection();
         GameObject createdFireObject  = (GameObject)(Instantiate(physicalFireObject, CurrentLevelVariableManagement.GetPlayerReference().transform.position + physicalFireOffset + physicalFireObject.transform.localPosition, Quaternion.identity));
         createdFireObject.GetComponent <PhysicalFireScript> ().OnFireCreated();
         //Used to remove the current item from the hotbar.
         ChangeStackOfCurrentHotbarItem(1);
     }
     else
     {
         Debug.LogError("Physical Fire Object does not exist!");
     }
 }
Ejemplo n.º 23
0
    //When some amount of money is earned or taken.
    public void OnMoneyModified(int amount)
    {
        switch (CurrentLevelVariableManagement.GetMainGameData().currentLevel)
        {
        case 0:
//			if (amount > 0) {
//				if (objectives[2].completed == false) {
//					OnObjectiveHasBeenCompleted(3);
//				}
//			}
            break;

        default:
            Debug.LogError("Objective Manager does not have a definition for this level!");
            break;
        }
    }
Ejemplo n.º 24
0
    void Start()
    {
        CurrentLevelVariableManagement.SetGameUIReferences();
        //Initialize the static database.
        ResourceDatabase.InitializeDatabase();
        //Initialize the initial UI elements.
        if (InitializeProfileSwitcher != null)
        {
            InitializeProfileSwitcher();
        }
        else
        {
            Debug.LogError("InitializeProfileSwitcher was null!!");
        }

        CurrentLevelVariableManagement.GetMainGameControl().DefineInitialLevelElements();
    }
Ejemplo n.º 25
0
    void InitializeSpriteChildren()
    {
        mainPlayerAction = transform.parent.parent.gameObject.GetComponent <PlayerAction> ();
        playerInventory  = CurrentLevelVariableManagement.GetMainInventoryReference().GetComponent <InventoryFunctions> ();
        //Just setting up the basic race costume.
        body        = transform.Find("Body").GetComponent <SpriteRenderer> ();
        head        = transform.Find("Head").GetComponent <SpriteRenderer> ();
        idleArm     = transform.Find("Hands").Find("IdleHand").GetComponent <SpriteRenderer> ();
        holdingArm  = transform.Find("Hands").Find("HoldingHand").GetComponent <SpriteRenderer> ();
        topLeg      = transform.Find("Legs").Find("Top Leg").GetComponent <SpriteRenderer> ();
        bottomLeg   = transform.Find("Legs").Find("Bottom Leg").GetComponent <SpriteRenderer> ();
        holdingItem = holdingArm.transform.Find("HoldingItem");

        Profession currentPlayerProfession = CurrentLevelVariableManagement.GetMainGameData().chosenProfession;

        UpdatePlayerProfession(currentPlayerProfession);
    }
Ejemplo n.º 26
0
    //Add/subtract coins.
    public bool UpdateCoinValue(int valueToAdd)
    {
        //In case an objective depends on this.
        CurrentLevelVariableManagement.GetMainObjectiveManager().OnMoneyModified(valueToAdd);
        //Determine the new coin value.
        int newCoinValue = int.Parse(coinValue.text) + valueToAdd;

        if (newCoinValue >= 0)
        {
            coinValue.text = newCoinValue.ToString();
            return(true);
        }
        else
        {
            return(false);
        }
    }
Ejemplo n.º 27
0
    /**************************** TUTORIAL ****************************/

    public void OnCurrentLevelCompleted()
    {
        Debug.Log("Gathering player data...");

        //Get player money.
        GetComponent <GameData> ().currentPlayerMoney = CurrentLevelVariableManagement.GetPlayerReference().GetComponent <PlayerHealthPanelManager> ().GetPlayerMoney();
        Debug.Log("Set player money to " + GetComponent <GameData> ().currentPlayerMoney);

        //Get player items.
        GetComponent <GameData> ().currentPlayerItems = CurrentLevelVariableManagement.GetMainInventoryReference().GetComponent <InventoryFunctions> ().GetAllPlayerItems();
        Debug.Log("Player has " + GetComponent <GameData> ().currentPlayerItems.Length + " items");

        Debug.Log("Tutorial has been completed!");
        //Increment the current level.
        GetComponent <GameData> ().currentLevel += 1;
        //Load the Profession Chooser for the next level
        SceneManager.LoadScene("Profession Chooser");
    }
Ejemplo n.º 28
0
    //The method that initializes the values of the health panel.
    protected override void InitializeHealthPanelReference()
    {
        base.InitializeHealthPanelReference();

        //Name of player
        playerName      = transform.Find("Name").gameObject.GetComponent <Text> ();
        playerName.text = CurrentLevelVariableManagement.GetMainGameData().specifiedPlayerName;
        //Experience components.
        currentPlayerProfession      = transform.Find("Experience").Find("ProfessionName").gameObject.GetComponent <Text> ();
        currentPlayerProfession.text = CurrentLevelVariableManagement.GetMainGameData().chosenProfession.name;
        experienceSlider             = transform.Find("Experience").Find("Experience Indicator").gameObject.GetComponent <Slider> ();
        playerLevel = transform.Find("Experience").Find("PlayerLevel").gameObject.GetComponent <Text> ();
        experienceSlider.maxValue = maxExpValue;
        experienceSlider.value    = 0;
        //Coin Values
        coinValue      = transform.Find("Cash").Find("Value").GetComponent <Text> ();
        coinValue.text = "0";
    }
Ejemplo n.º 29
0
    protected override void InitializeHealthBar()
    {
        if (lifePoints <= 0)
        {
            Debug.Log("Player health is " + lifePoints + " which is an invalid value.  Switching to 10.");
            lifePoints = 10;
        }
        currentHealth = lifePoints;
        //Create panel
        uiHealthController         = CurrentLevelVariableManagement.GetLevelUIReference().transform.Find("Health Controller").gameObject.GetComponent <UIHealthController> ();
        playerHealthPanelReference = uiHealthController.GetPlayerHealthPanelReference();
        //Initialize icon
        characterHeadSprite = transform.Find("FlippingItem").GetChild(0).Find("Head").GetComponent <SpriteRenderer> ().sprite;
        playerHealthPanelReference.InitializePanel(characterHeadSprite, lifePoints, currentHealth);

        //Give player money obtained previously.
        GiveMoneyToPlayer(CurrentLevelVariableManagement.GetMainGameData().currentPlayerMoney);
    }
Ejemplo n.º 30
0
    public void InitializeProjectileWithThresholdAndDeviation(Vector3 positionToFireToward, float velocity, float currentHeading, float headingThreshold, float maxRandomDeviation, float ctorArrowPower)
    {
        playerObject = CurrentLevelVariableManagement.GetPlayerReference();

        //Set physics of the projectile.
        rb2d = GetComponent <Rigidbody2D> ();
        //Returned in radians.
        float radianAngleToTarget = Mathf.Atan2((positionToFireToward.y - transform.position.y), (positionToFireToward.x - transform.position.x));
        float degreeAngleToTarget = ScriptingUtilities.RadiansToDegrees(radianAngleToTarget);

        //Used to set the threshold angles that the arrow can be shot at.
        if (currentHeading == 0)
        {
            if (180 >= degreeAngleToTarget && degreeAngleToTarget >= headingThreshold)
            {
                degreeAngleToTarget = headingThreshold;
            }
            else if (-180 <= degreeAngleToTarget && degreeAngleToTarget <= -headingThreshold)
            {
                degreeAngleToTarget = -headingThreshold;
            }
        }
        else if (currentHeading == 180)
        {
            if (0 <= degreeAngleToTarget && degreeAngleToTarget <= 180 - headingThreshold)
            {
                degreeAngleToTarget = 180 - headingThreshold;
            }
            else if (0 >= degreeAngleToTarget && degreeAngleToTarget >= -180 + headingThreshold)
            {
                degreeAngleToTarget = -180 + headingThreshold;
            }
        }

        degreeAngleToTarget += Random.Range(0, maxRandomDeviation) - maxRandomDeviation / 2;

        transform.localRotation = Quaternion.Euler(new Vector3(0, 0, degreeAngleToTarget));
        rb2d.velocity           = new Vector2(velocity * Mathf.Cos(ScriptingUtilities.DegreesToRadians(degreeAngleToTarget)), velocity * Mathf.Sin(ScriptingUtilities.DegreesToRadians(degreeAngleToTarget)));

        arrowPower = ctorArrowPower;

        //Start the coroutine that checks when the arrow should be destroyed (takes up memory space)
        StartCoroutine(DestroyIfDistanceFromPlayer());
    }