Esempio n. 1
0
    // Use this for initialization
    public new void Start()
    {
        base.Start();
        originMoveSpeed = 5;
        moveSpeed       = originMoveSpeed;
        playerTransform = GameObject.FindGameObjectWithTag("Player").transform;
        playerScript    = playerTransform.GetComponent <Player>();
        alerted         = false;
        navAgent        = this.GetComponent <NavMeshAgent>();
        animator        = this.GetComponent <Animator>();
        rotateSpeed     = 1200;
        //lookRange = 15;
        actionTimer = 0.5f;
        attackRange = 7;
        dropList    = new Item[7];
        name        = "Monguer";

        dropList[0] = new MonguerAxe();
        dropList[1] = new HpPotion();
        dropList[2] = new MpPotion();
        dropList[3] = new VillageStone();
        dropList[4] = new TridentStone();
        dropList[5] = new LevelUpStone();
        dropList[6] = new ClassStone();
        audioSource = this.GetComponent <AudioSource>();
    }
Esempio n. 2
0
    public override Item clone()
    {
        HpPotion itemClone = new HpPotion();

        itemClone.quantity = this.quantity;
        return(itemClone);
    }
Esempio n. 3
0
    // Use this for initialization
    public new void Start()
    {
        //charLevel = 1;
        //maxHp = 5;
        //baseHp = maxHp;
        //baseAttack = 1f;
        //dropExp = 5;
        //dropGold = 5;
        //recoverHp = 8 / 3;

        base.Start();
        originMoveSpeed = 5;
        moveSpeed       = originMoveSpeed;
        playerTransform = GameObject.FindGameObjectWithTag("Player").transform;
        playerScript    = playerTransform.GetComponent <Player>();
        alerted         = false;
        navAgent        = this.GetComponent <NavMeshAgent>();
        animator        = this.GetComponent <Animator>();
        rotateSpeed     = 1200;
        //lookRange = 10;
        actionTimer = 0.5f;
        attackRange = 7;
        dropList    = new Item[6];
        name        = "Big Crush";

        dropList[0] = new ClassStone();
        dropList[1] = new HpPotion();
        dropList[2] = new MpPotion();
        dropList[3] = new VillageStone();
        dropList[4] = new TridentStone();
        dropList[5] = new LevelUpStone();

        audioSource = this.GetComponent <AudioSource>();
    }
    public ElimMonguer()
    {
        name           = "Eliminating threats";
        goal           = 10;
        progress       = 0;
        description    = "That was expected of you. Before I will acknowledge you, come back alive after killing " + goal + " Monguers. You can find them after leaving this village via the portal at (55, 5).";
        task           = "Kill " + goal + " Monguers and talk to the class instructor.";
        rewardGold     = 50;
        rewardExp      = 20;
        rewardItemList = new Item[1];
        HpPotion hpPotion = new HpPotion();

        hpPotion.quantity = 3;
        rewardItemList[0] = hpPotion;
        completeText      = "Well done!";
        next = new BringAxes();
        id   = 7;
    }
Esempio n. 5
0
        private void HandleSkillControls()
        {
            if (Input.GetKeyDown(KeyCode.Tab))
            {
                ui.SwitchConsole();
            }

            if (Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.KeypadEnter))
            {
                ui.OnEnter();
            }

            if (!ui.consoleActive)
            {
                if (Input.GetKeyDown(KeyCode.Q))
                {
                    data.StartMeleeTargeting(false);
                }

                if (data.ActiveConfirmationSkill == null && Input.GetMouseButtonDown(0) && !ui.MouseOverUI)
                {
                    data.StartMeleeTargeting(true);
                }

                if (Input.GetKeyDown(KeyCode.W))
                {
                    EquippableItem u = new HpUpgradeAdd(1);
                    u.Init();
                    u.SpawnGameObject(Utils.GenerateRandomPositionAround(data.GetBody().transform.position, 3));
                    //data.GetOwner().AddUpgrade(u);
                    //data.GetOwner().EquipUpgrade(u);
                }

                if (Input.GetKeyDown(KeyCode.I))
                {
                    ui.SwitchInventory();
                }

                if (Input.GetKeyDown(KeyCode.U))
                {
                    Player p = data.GetOwner() as Player;
                    p.UnlockSkill(temp++, true);

                    //ui.DamageMessage(data.GetBody(), 10, Color.cyan);

                    //ui.ScreenMessage("Ahoasdddddddddddddddddddsssssssssddddddddddddoj" + (temp++), 1);
                    //data.AddPhysicsPush(new Vector2(0, 100), ForceMode2D.Impulse);
                }

                if (Input.GetKeyDown(KeyCode.E))
                {
                    InventoryItem u = new DnaItem(Random.Range(10, 20));
                    u.Init();
                    u.SpawnGameObject(Utils.GenerateRandomPositionAround(data.GetBody().transform.position, 3));

                    InventoryItem p = new HpPotion(1);
                    p.Init();
                    p.SpawnGameObject(Utils.GenerateRandomPositionAround(data.GetBody().transform.position, 3));
                }

                if (Input.GetKeyDown(KeyCode.B))
                {
                    AbstractLevelData levelData = WorldHolder.instance.activeMap.levelData;

                    if (levelData.CanHaveBase())
                    {
                        levelData.CreateBase();
                    }
                }

                if (Input.GetKeyDown(KeyCode.L))
                {
                    ui.ShowLevelsView();
                }

                if (Input.GetKeyDown(KeyCode.M))
                {
                    ui.HideLevelsView();
                }

                if (Input.GetKeyDown(KeyCode.V))
                {
                    AbstractLevelData levelData = WorldHolder.instance.activeMap.levelData;

                    if (levelData.HasBase())
                    {
                        if (SiegeManager.IsSiegeActive() == false)
                        {
                            SiegeManager.StartSiege(WorldHolder.instance.activeMap);
                        }
                        else
                        {
                            SiegeManager.CancelSiege();
                        }
                    }
                }

                if (Input.GetKeyDown(KeyCode.R))
                {
                    InventoryItem u = UpgradeTable.Instance.GenerateUpgrade(ItemType.CLASSIC_UPGRADE, 1, 2, 1);
                    u.Init();
                    u.SpawnGameObject(Utils.GenerateRandomPositionAround(data.GetBody().transform.position, 3));
                }

                /*if (Input.GetKeyDown(KeyCode.R))
                 * {
                 *      AbstractUpgrade u = data.GetOwner().Inventory.GetUpgrade(typeof (TemplateUpgrade));
                 *      data.GetOwner().UnequipUpgrade(u);
                 *      data.GetOwner().RemoveUpgrade(u);
                 *
                 *      u = data.GetOwner().Inventory.GetUpgrade(typeof(TemplateUpgrade));
                 *      data.GetOwner().UnequipUpgrade(u);
                 *      data.GetOwner().RemoveUpgrade(u);
                 * }*/

                if (Input.GetKeyDown(KeyCode.Alpha1))
                {
                    data.LaunchSkill(1);
                }

                if (Input.GetKeyDown(KeyCode.Alpha2))
                {
                    data.LaunchSkill(2);
                }

                if (Input.GetKeyDown(KeyCode.Alpha3))
                {
                    data.LaunchSkill(3);
                }

                if (Input.GetKeyDown(KeyCode.Alpha4))
                {
                    data.LaunchSkill(4);
                }

                if (Input.GetKeyDown(KeyCode.Alpha5))
                {
                    data.LaunchSkill(5);
                }

                if (Input.GetKeyDown(KeyCode.Alpha6))
                {
                    data.LaunchSkill(6);
                }

                if (Input.GetKeyDown(KeyCode.Alpha7))
                {
                    data.LaunchSkill(7);
                }

                if (Input.GetKeyDown(KeyCode.Alpha8))
                {
                    data.LaunchSkill(8);
                }

                if (Input.GetKeyDown(KeyCode.Alpha9))
                {
                    data.LaunchSkill(9);
                }

                if (Input.GetKeyDown(KeyCode.Alpha0))
                {
                    data.LaunchSkill(10);
                }
            }
        }
    // Update is called once per frame
    void Update()
    {
        if (playerScript.getHp() > 0)
        {
            attackTimer -= Time.deltaTime;
            AnimatorStateInfo info = animator.GetCurrentAnimatorStateInfo(0);
            if (info.fullPathHash == Animator.StringToHash("Base Layer.attack") && !animator.IsInTransition(0))
            {
                animator.SetBool("attack", false);
            }

            if (Input.GetMouseButtonDown(0) && attackTimer <= 0)
            {
                animator.SetBool("attack", true);
                audioSource.PlayOneShot(swingClip);
                attackTimer = 0.6f;
                RaycastHit hitInfo;
                bool       hit = Physics.Raycast(camTransform.position, camTransform.TransformDirection(Vector3.forward), out hitInfo, playerScript.attackRange, layers);
                if (hit)
                {
                    if (hitInfo.transform.tag.Equals("Enemy"))
                    {
                        Enemy enemy = hitInfo.transform.GetComponent <Enemy>();
                        //print(enemy.baseHp);
                        if (enemy.baseHp > 0)
                        {
                            enemy.damaged(Random.Range(playerScript.calMinAttack(), playerScript.calMaxAttack()));
                        }
                    }
                    else if (GameEngine.ge.showPanel == 0)
                    {
                        if (hitInfo.transform.tag.Equals("NPC"))
                        {
                            NPC npc = hitInfo.transform.GetComponent <NPC>();
                            if (npc != null)
                            {
                                npc.interact();
                            }
                        }
                        else if (hitInfo.transform.tag.Equals("Bank"))
                        {
                            GameEngine.ge.changePanel(9);
                        }
                        else if (hitInfo.transform.tag.Equals("chest"))
                        {
                            HpPotion hpPotion = new HpPotion();
                            hpPotion.quantity = 5;
                            MpPotion mpPotion = new MpPotion();
                            mpPotion.quantity = 5;

                            if (Random.value > 0.5)
                            {
                                Item  rareItem;
                                float rare = Random.value;
                                if (rare <= 0.15)
                                {
                                    rareItem = new ClassStone();
                                }
                                else if (rare <= 0.30)
                                {
                                    rareItem = new LevelUpStone();
                                }
                                else if (rare <= 0.65)
                                {
                                    rareItem = new TridentStone();
                                }
                                else
                                {
                                    rareItem = new VillageStone();
                                }
                                playerScript.bag.insertItem(rareItem, true, true);
                            }

                            playerScript.bag.insertItem(hpPotion, true, true);
                            playerScript.bag.insertItem(mpPotion, true, true);
                            Destroy(hitInfo.transform.gameObject);
                        }
                    }
                }
            }
        }
    }