public void GetHit(DHitParam hit) { GameObject flyingtext = DGameSystem.LoadPool("TextDame", transform.position + new Vector3(0, 0.5f)); flyingtext.GetComponent <TextMeshPro>().text = Convert.ToInt32(hit.dame).ToString(); hitCount -= 1; if (hitCount <= 0) { float random = UnityEngine.Random.Range(0, 100); Debug.Log("ramdom: " + random); float pivot = 0; for (int i = 0; i < dropRates.Length; i++) { if (pivot < random && random < pivot + dropRates[i]) { DGameSystem.LoadPool("Ghost", transform.position); } pivot += dropRates[i]; } if (respawn_time < 0) { Destroy(gameObject); } else { Invoke("Respawn", respawn_time); } gameObject.SetActive(false); } }
public virtual void ReceiveParam(DHitParam hitParam) { if (hitParam.target != null) { hitParam.target.SendMessage("GetHit", hitParam, SendMessageOptions.DontRequireReceiver); } gameObject.SetActive(false); }
public void ApplyDame(GameObject target) { DHitParam hit = new DHitParam(); hit.dame = current.dame; hit.owner = gameObject; hit.ownerTag = gameObject.tag; target.SendMessage("GetHit", hit, SendMessageOptions.DontRequireReceiver); }
public void GetHit(DHitParam hit) { GameObject flyingtext = DGameSystem.LoadPool("TextDame", transform.position + new Vector3(0, 0.5f)); flyingtext.GetComponent <TextMeshPro>().text = Convert.ToInt32(hit.dame).ToString(); current.hp -= hit.dame; UpdateHealthBar(); if (current.hp <= 0) { DGameSystem.LoadPool("Ghost", transform.position); gameObject.SetActive(false); } }
//public void Attack() //{ // Quaternion quaternion = Quaternion.Euler(0, 0, 0); // switch (GetComponent<DMovement>().Facing) // { // case "up": // quaternion = Quaternion.Euler(0, 0, 90); // break; // case "down": // quaternion = Quaternion.Euler(0, 0, 270); // break; // case "left": // quaternion = Quaternion.Euler(0, 0, 180); // break; // case "right": // quaternion = Quaternion.Euler(0, 0, 0); // break; // default: // quaternion = Quaternion.Euler(0, 0, 0); // break; // } // GameObject attack = DGameSystem.LoadPool("Attack", transform.position); // attack.transform.rotation = quaternion; // DHitParam hitParam = attack.GetComponent<DHitParam>(); // hitParam.dame = current.dame; // hitParam.owner = this.gameObject; // hitParam.ownerTag = this.gameObject.tag; // hitParam.type1 = stat.type1; // hitParam.type2 = stat.type2; // if (gameObject.tag == "Player") // { // string facing = GetComponent<DMovement>().Facing; // Sprite[] attacks = GetComponent<DMovement>().ConvertStringToSprites("attack_" + facing); // GetComponent<DAnimator>().spritesheet = attacks; // //GetComponent<DAnimator>().attacking = true; // } //} public void ExecuteAttack() { GameObject attackObj = DGameSystem.LoadPool(stat.attackObjectName, transform.position); attackObj.transform.rotation = Quaternion.Euler(0, 0, 0); DHitParam hitParam = new DHitParam(); hitParam.dame = current.dame; hitParam.owner = gameObject; hitParam.ownerTag = gameObject.tag; hitParam.type1 = stat.type1; hitParam.type2 = stat.type2; if (gameObject.CompareTag("Pet")) { hitParam.targetTags = new List <string> { "Monster" } } ; else { hitParam.targetTags = new List <string> { "Pet" } }; if (gameObject.tag == "Player") { hitParam.direction = GetComponent <DMovement>().Facing; } else { hitParam.target = GetComponent <DFollow>().enemy; hitParam.direction = GetComponent <DFollow>().direction; if (hitParam.direction == "left") { attackObj.transform.rotation = Quaternion.Euler(0, 0, 180); } else { attackObj.transform.rotation = Quaternion.Euler(0, 0, 0); } } attackObj.SendMessage("ReceiveParam", hitParam, SendMessageOptions.DontRequireReceiver); } }
public void GetHit(DHitParam hit) { float calculatedDame = DGameSystem.pokemonSystem.CalculateReceiveDame(hit, stat); GameObject flyingtext = DGameSystem.LoadPool("TextDame", transform.position); flyingtext.GetComponent <TextMeshPro>().text = Convert.ToInt32(calculatedDame).ToString(); current.hp -= calculatedDame; UpdateHealthBar(); if (current.hp <= 0) { DGameSystem.LoadPool("Ghost", transform.position); gameObject.SetActive(false); } Debug.Log(gameObject.name + " get hit from " + hit.owner.name); }
public void ExecuteAttack() { GameObject attackObj = DGameSystem.LoadPool(stat.attackObjectName, transform.position); attackObj.transform.rotation = Quaternion.Euler(0, 0, 0); DHitParam hitParam = new DHitParam(); hitParam.dame = current.dame; hitParam.owner = gameObject; hitParam.ownerTag = gameObject.tag; if (gameObject.tag == "Player") { hitParam.direction = GetComponent <DMovement>().Facing; } else { hitParam.target = GetComponent <DFollow>().enemy; hitParam.direction = GetComponent <DFollow>().direction; } attackObj.SendMessage("ReceiveParam", hitParam, SendMessageOptions.DontRequireReceiver); }
public virtual void ReceiveParam(DHitParam hitParam) { hit = hitParam; }