Beispiel #1
0
    public void CompleteQuest(NPCQuest quest)
    {
        if (player.Inventory.Count + quest.QuestReward.Count <= player.MaxInventorySpace)
        {
            for (int i = 0; i < quest.QuestReward.Count; i += 0)
            {
                bool addedItem = player.AddItem(quest.QuestReward[i]);
                if (addedItem)
                {
                    quest.QuestReward.RemoveAt(i);
                }
                else
                {
                    Debug.Log("Stack is full");
                }
            }

            if (quest.QuestReward.Count == 0)
            {
                player.AddExp(quest.QuestExpReward);
                player.ModifyGold(quest.QuestGoldReward);
                quest.isFinished = true;
                player.questsComplete.Add(quest);

                if (quest.qego != null && !quest.EnableQuestGOPerm)
                {
                    quest.qego.DisableGameObjects();
                }
                if (quest.numberToObtain > 0)
                {
                    for (int i = 0; i < player.Inventory.Count; i++)
                    {
                        if (player.Inventory[i].Name == quest.nameOfItem)
                        {
                            player.Inventory[i].CurStacks -= quest.numberToObtain;
                            if (player.Inventory[i].CurStacks <= 0)
                            {
                                player.Inventory.RemoveAt(i);
                            }
                        }
                    }
                }

                player.QuestsInProgress.Remove(quest);
                EnterDialog();
            }
        }
        else
        {
            Debug.Log("Inventory is Full!");
        }
    }
Beispiel #2
0
    void Update()
    {
        timeSinceLastAttack += Time.deltaTime;

        float curHealth = GetComponent <Health>().CurrentHealth;

        if (curHealth <= 0)
        {
            MonsterHealth = 0;
            isDead        = true;
        }

        if (isDead)
        {
            player.AddExp(expValue);
            string nameOfMobToSend = monsterType == MonsterType.Normal ? NameOfMob : "BOSS" + NameOfMob;
            Messenger <string> .Broadcast("MonsterKilled", nameOfMobToSend);

            //Destroy all floating text attached to this
            FloatingTextGUI[] floatingTexts = GetComponentsInChildren <FloatingTextGUI>();
            for (int i = 0; i < floatingTexts.Length; i++)
            {
                Destroy(floatingTexts[i].gameObject, 0.5f);
            }

            DropLoot();
            Destroy(gameObject);
        }
        else
        {
            if (inCombat)
            {
                EnableCombat = true;
            }
            else
            {
                EnableCombat = false;
            }

            if (isStunned)
            {
                EnableCombat = false;
            }

            if (isUseless)
            {
                return;
            }

            if (EnableCombat)
            {
                float angleToTarget = Mathf.Atan2((player.transform.position.x - transform.position.x), (player.transform.position.z - transform.position.z)) * Mathf.Rad2Deg;
                transform.eulerAngles = new Vector3(0, angleToTarget, 0);

                if (Vector3.Distance(transform.position, player.transform.position) > 2)
                {
                    transform.position = Vector3.MoveTowards(transform.position, player.transform.position, RunSpeed * Time.deltaTime);
                }

                bool canDealDamage = timeSinceLastAttack > 1 / AttacksPerSecond ? true : false;

                if (canDealDamage)
                {
                    timeSinceLastAttack = 0;
                    PlayerHealth php = player.GetComponent <PlayerHealth>();
                    if (php == null)
                    {
                        Debug.Log("No player health");
                    }
                    DealDamage(php);
                    canDealDamage = false;
                }
            }
        }
    }
Beispiel #3
0
 public void AddExp()
 {
     player.AddExp(ExpToAdd);
 }