// 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>(); }
public override Item clone() { ClassStone itemClone = new ClassStone(); itemClone.quantity = this.quantity; return(itemClone); }
// 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>(); }
// 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); } } } } } }