void Weapon(MonsterHealth monsterHealth) { if (monsterHealth != null) { monsterHealth.TakeDamage(lightDamage); } }
void CheckAttack() { //Collider targetCollider = FIndTarget(); if (m_collider == null) { return; } m_targetHealth = m_collider.GetComponent <MonsterHealth>(); if (m_targetHealth == null || m_targetHealth.IsDie) { return; } float distance = Vector3.Distance(m_targetHealth.transform.position, transform.position); AnimatorStateInfo stateinfo = m_animator.GetCurrentAnimatorStateInfo(0); if ((stateinfo.IsName("Combo3") || stateinfo.IsName("Combo4")) && m_collider.tag == "Monster") { m_collider.GetComponent <MonsterController>().GetHitBack = true; } if (distance <= m_attackRange) { m_targetHealth.DecreaseHp(m_totalStr, CriticalCheck(), gameObject); //m_targetHealth.DecreaseHp(10, CriticalCheck()); if (m_collider.tag == "Monster") { Animator animator = m_targetHealth.GetComponent <Animator>(); m_targetHealth.GetComponent <MonsterController>().GetHitCheck = true; m_targetHealth.GetComponent <MonsterController>().PlayerAttackCheck(gameObject); } } }
void ModifyMonster(string monsterType, GameObject monsterInstance) { Monster monsterScript = monsterInstance.GetComponent <Monster>(); MonsterHealth health = monsterInstance.GetComponentInChildren <MonsterHealth>(); NavMeshAgent monsterNMA = monsterInstance.GetComponent <NavMeshAgent>(); Renderer[] monsterRenderers = monsterInstance.GetComponentsInChildren <Renderer>(); // get the info for (int i = 0; i < monsterInfo.Length; i++) { if (monsterType == monsterInfo[i][MONSTER_NAME]) { // set the score monsterScript.Score = int.Parse(monsterInfo[i][MONSTER_SCORE]); // set the health health.setHealth(int.Parse(monsterInfo[i][MONSTER_HEALTH])); // set the speed monsterNMA.speed = int.Parse(monsterInfo[i][MONSTER_SPEED]); // set the color for (int j = 0; j < monsterRenderers.Length; j++) { if (monsterRenderers[j].name != "HealthBar") { Color color; ColorUtility.TryParseHtmlString(monsterInfo[i][MONSTER_COLOR], out color); monsterRenderers[j].material.SetColor("_Color", color); } } } } }
public void ForthSkill() { //지금은 몬스터가 바로 앞으로 소환 되는데 이후 자연스럽게 이동하게 처리하기 Collider[] targets = Physics.OverlapSphere(transform.position, forthDistance); float forwardRange = 1.0f; if (targets.Length != 0) { foreach (Collider col in targets) { if (col.gameObject.tag == "Monster" || col.gameObject.tag == "Boss") { if (m_collider == null) { m_collider = col.GetComponent <Collider>(); } int damage = (int)(m_totalStr * FindSkillInfo("Skill4", m_SL4)); col.transform.position = transform.position + transform.forward * forwardRange; MonsterHealth health = col.GetComponent <MonsterHealth>(); health.DecreaseHp(damage, CriticalCheck(), gameObject); if (col.tag == "Monster") { health.GetComponent <MonsterController>().PlayerAttackCheck(gameObject); } } } } }
void Start() { GetComponent <NavMeshAgent>().enabled = true; m_transform = this.gameObject.GetComponent <Transform>(); //m_playerTransform = GameObject.FindWithTag("Player").GetComponent<Transform>(); nvAgent = this.gameObject.GetComponent <NavMeshAgent>(); m_animator = this.gameObject.GetComponent <Animator>(); m_originPosition = this.transform.position; marker = transform.Find("MarkerPivot/Marker.Crosshair").gameObject; marker.SetActive(false); m_Material = transform.Find("Body").GetComponent <SkinnedMeshRenderer>().material; m_deadMat = Instantiate(Resources.Load <Material>("Materials/DissolveTexRampNor")); m_playerTransform = null; //m_playerTransform = FindPlayer(); Coroutine(); //monster info m_monsterHp = m_monsterInfo.monHp; m_monsterStr = m_monsterInfo.monStr; m_monsterDef = m_monsterInfo.monDef; m_monsterCri = m_monsterInfo.monCri; m_monsterAtDis = m_monsterInfo.monAtDis; m_monsterLevel = m_monsterInfo.monLevel; m_monsterName = m_monsterInfo.monName; health = GetComponent <MonsterHealth>(); health.GetHp = m_monsterHp; health.Init(); }
public override void Attack() { print("Shoot shotgun"); //shotgun has larger hit range Ray rayCenter = _camera.ScreenPointToRay(Input.mousePosition); Ray rayLeft = _camera.ScreenPointToRay(new Vector3(_camera.pixelWidth * 9 / 20, _camera.pixelWidth / 2, 0)); Ray rayRight = _camera.ScreenPointToRay(new Vector3(_camera.pixelWidth * 11 / 20, _camera.pixelWidth / 2, 0)); Ray rayUp = _camera.ScreenPointToRay(new Vector3(_camera.pixelWidth / 2, _camera.pixelWidth * 9 / 20, 0)); Ray rayDown = _camera.ScreenPointToRay(new Vector3(_camera.pixelWidth / 2, _camera.pixelWidth * 11 / 20, 0)); RaycastHit hit; if (Physics.Raycast(rayCenter, out hit) || Physics.Raycast(rayLeft, out hit) || Physics.Raycast(rayRight, out hit) || Physics.Raycast(rayUp, out hit) || Physics.Raycast(rayDown, out hit)) { GameObject obj = hit.transform.gameObject; if (Array.IndexOf(enemies, obj) != -1) { print("hit"); monsterHealth = obj.GetComponent <MonsterHealth> (); monsterHealth.TakeDamage(shotgunDamage); } } }
void OnTriggerEnter(Collider other) { GameObject otherobj = other.gameObject; if (otherobj.tag == EnemyTag || otherobj.tag == BossTag) { Debug.Log("Deal Damage"); otherobj.GetComponent <MonsterHealth>().TakeDamage(20); Vector3 damageSystemPosition = Vector3.zero; damageSystemPosition.y += .5f; GameObject damageSystem = (GameObject)Instantiate(damageObject); damageSystem.transform.parent = otherobj.transform; damageSystem.transform.localPosition = damageSystemPosition; damageSystem.transform.localScale = new Vector3(1, 1, 1); MonsterHealth health = otherobj.GetComponent <MonsterHealth>(); if (health != null) { health.TakeDamage(damage * damageMultiplier); } } }
void Awake() { player = GameObject.FindGameObjectWithTag("Player").transform; playerHealth = player.GetComponent <PlayerHealth> (); enemyHealth = GetComponent <MonsterHealth> (); nav = GetComponent <UnityEngine.AI.NavMeshAgent> (); }
void Awake() { player = GameObject.FindGameObjectWithTag("Player"); playerHealth = player.GetComponent <PlayerHealth> (); enemyHealth = GetComponent <MonsterHealth>(); anim = GetComponent <Animator> (); }
void Awake() { player = this.gameObject; enemy = FindObjectOfType <MonsterInstantiate>(); monsterHP = FindObjectOfType <MonsterHealth>(); if (!enemy) { Debug.Log("No Enemy"); return; } else { if (!monsterHP) { Debug.Log("The is no monster"); } else { healthBar = monsterHP.healthBar; HP = monsterHP.monsterHP; healthBar.fillAmount = HP; return; } return; } }
public void FifthSkill() { Collider[] targets = Physics.OverlapSphere(transform.position, fifthDistance); if (targets.Length != 0) { foreach (Collider col in targets) { if (col.gameObject.tag == "Monster" || col.gameObject.tag == "Boss") { if (m_collider == null) { m_collider = col.GetComponent <Collider>(); } int damage = (int)(m_totalStr * FindSkillInfo("Skill5", m_SL5)); MonsterHealth health = col.GetComponent <MonsterHealth>(); health.DecreaseHp(damage, CriticalCheck(), gameObject); if (col.tag == "Monster") { health.GetComponent <MonsterController>().PlayerAttackCheck(gameObject); } } } } }
//AWAKE //Assign components to variables void Awake() { Player = GameObject.FindGameObjectWithTag("Player"); PlayerLife = Player.GetComponent <PlayerHealth>(); MonsterLife = GetComponent <MonsterHealth>(); MonsterAnimator = GetComponent <Animator>(); }
// Use this for initialization void Start() { player = GameObject.Find("Player"); playerHealth = player.GetComponent <PlayerHealth> (); enemyHealth = GetComponent <MonsterHealth> (); playerInRange = false; timer = 0; }
// Use this for initialization void Start() { scaleX = transform.localScale.x; scaleY = transform.localScale.y; scaleZ = transform.localScale.z; player = FindObjectOfType <PlayerController> (); monster = FindObjectOfType <MonsterHealth> (); OkToMove = true; }
private void OnTriggerEnter(Collider other) { MonsterHealth health = other.GetComponentInChildren <MonsterHealth>(); if (health) { health.decrease(); Destroy(gameObject); } }
//ONCOLLISIONENTER //Checks if something in range is a chocolate void OnCollisionEnter(Collision collision) { if (collision.collider.gameObject.layer == 10) { ChocolateInRange = true; //Set the flag Monster = collision.collider.gameObject; //Target this Chocolate for damage MonsterLife = Monster.GetComponent <MonsterHealth>(); Debug.Log("Hit a chocolate!"); //DEBUG } }
//ONCOLLISIONENTER //Checks if something in range is a marshmellow void OnCollisionEnter(Collision collision) { if (collision.collider.gameObject.layer == 9) { MarshmellowInRange = true; //Set the flag Monster = collision.collider.gameObject; //Target this Marshmellow for damage MonsterLife = Monster.GetComponent <MonsterHealth>(); Debug.Log("Hit a marshmellow!"); //DEBUG } }
private void OnTriggerEnter2D(Collider2D collision) { MonsterHealth MH = collision.GetComponent <MonsterHealth>(); if (MH != null) { MH.TakeDamage(damage); Destroy(gameObject); } }
void Start() { agent = GetComponent <UnityEngine.AI.NavMeshAgent>(); player = GameObject.FindGameObjectWithTag("Player"); playerHealth = player.GetComponent <PlayerHealth>(); enemySonar = GetComponent <MonsterSonar>(); enemyHealth = GetComponent <MonsterHealth>(); anim = transform.GetComponent <Animator>(); attackBool = Animator.StringToHash("attack"); lookBool = Animator.StringToHash("look"); }
void Start() { theAnimation = GetComponent<Animation>(); theNavAgent = GetComponent<NavMeshAgent>(); theCollider = GetComponent<Collider>(); theMonsterHealth = GetComponent<MonsterHealth>(); theAttack = GetComponent<CreagAttack>(); fpsTarget = GameObject.FindWithTag("Player").transform; fpsTargetDistance = enemyLookDistance + 1f; theNavAgent.speed = enemyMovementSpeed; }
void OnTriggerEnter(Collider other) { if (mHealth.health > 0) { if (other.tag == "monster") { monsterHealth = other.gameObject.GetComponent<MonsterHealth> (); monsterHealth.TakeDamage (30); } if (other.tag == "boss") { bossHealth = other.gameObject.GetComponent<BossHealth> (); bossHealth.TakeDamage (30); } } //Destroy(other.gameObject); }
// Use this for initialization void Start() { // Find the player and playercontroller player = GameObject.FindGameObjectWithTag(Tags.playerTag); playerController = player.GetComponent <PlayerController>(); animator = GetComponentInChildren <Animator>(); characterController = GetComponent <CharacterController>(); // Assign the reference to the controls and game data manager gameController = GameObject.FindGameObjectWithTag(Tags.gameControllerTag).GetComponent <GameController>(); // Assign the script component references monsterSight = GetComponent <MonsterSight>(); monsterHealth = GetComponent <MonsterHealth>(); monsterMovement = GetComponent <MonsterMovement>(); }
// Start is called before the first frame update void Start() { currentState = BasicRangeState.Idle; player = GameObject.FindGameObjectWithTag("Player"); playerGridPosition = player.GetComponent<GridPosition>(); playerHealth = player.GetComponent<PlayerHealth>(); gridPosition = GetComponent<GridPosition>(); aStar = GetComponent<AIPath>(); attackCooldownCounter = 0; attackTimeCounter = 0; canAttack = false; fleeController = GetComponent<EnemyFleeController>(); animator = GetComponentInChildren<Animator>(); monsterHealth = GetComponent<MonsterHealth>(); stateCounter = 0; }
// Start is called before the first frame update void Start() { currentState = BasicMeleeState.Idle; player = GameObject.FindGameObjectWithTag("Player"); playerGridPosition = player.GetComponent <GridPosition>(); playerHealth = player.GetComponent <PlayerHealth>(); gridPosition = GetComponent <GridPosition>(); aStar = GetComponent <AIPath>(); animator = GetComponentInChildren <Animator>(); attackCooldownCounter = 0; attackTimeCounter = 0; canAttack = true; stateCounter = 0; monsterHealth = GetComponent <MonsterHealth>(); attacksfx.Pause(); }
void Awake () { m_position = GetComponent <Rigidbody> (); nav = GetComponent <NavMeshAgent> (); anim = GetComponent <Animator> (); mHealth = GetComponent<MonsterHealth> (); player = GameObject.FindGameObjectWithTag ("Player"); playerHealth = player.GetComponent<PlayerHealth> (); OriPosition = m_position.position; mAnimation = 0; goHome = true; }
public void MagicianFirstSkill() { Collider[] targets = Physics.OverlapSphere(transform.position + transform.forward * 4.0f, m_firstSkillDistance); foreach (Collider col in targets) { if (col.gameObject.tag == "Monster" || col.gameObject.tag == "Boss") { //int damage = (int)(m_totalStr * FindSkillInfo("Skill3", m_SL3)); MonsterHealth health = col.GetComponent <MonsterHealth>(); health.DecreaseHp(m_str, false, gameObject); if (col.gameObject.tag == "Monster") { health.GetComponent <MonsterController>().PlayerAttackCheck(gameObject); } } } }
public override void Attack() { if (timer > timeBetweenAttacks) { timer = 0; Ray ray = _camera.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { GameObject obj = hit.transform.gameObject; if (Array.IndexOf(enemies, obj) != -1) { print("hit"); monsterHealth = obj.GetComponent <MonsterHealth> (); monsterHealth.TakeDamage(pistolDamage); } } } }
//battle clicked void Battle_Clicked(object sender, System.EventArgs e) { //pick a random number for monster and user Random random = new Random(); double m = random.Next(1, 10); double u = random.Next(1, 10); double p; //if monster number is larger if (m >= u) { UHealth -= m * 10; //if user health reachs 0 if (UHealth <= 0) { LostLabel.IsVisible = true; ReturnButton.IsVisible = true; BattleButton.IsVisible = false; } p = UHealth / 500; UserHealth.ProgressTo(p, 250, Easing.Linear); UpdateHealthlabels(); } //if users number is larger else if (u > m) { MHealth -= u * 10; //if monster health reachs 0 if (MHealth <= 0) { WonLabel.IsVisible = true; ReturnButton.IsVisible = true; BattleButton.IsVisible = false; } p = MHealth / monsterInfo.Health; MonsterHealth.ProgressTo(p, 250, Easing.Linear); UpdateHealthlabels(); } }
void OnTriggerEnter(Collider other) { GameObject otherObject = other.gameObject; if (isEnemy(otherObject)) { Vector3 damageSystemPosition = Vector3.zero; damageSystemPosition.y += .5f; GameObject damageSystem = (GameObject)Instantiate(damageObject); damageSystem.transform.parent = otherObject.transform; damageSystem.transform.localPosition = damageSystemPosition; damageSystem.transform.localScale = new Vector3(1, 1, 1); MonsterHealth health = otherObject.GetComponent <MonsterHealth>(); if (health != null) { health.TakeDamage(damage * damageMultiplier); } } }
void DealDamage() { foreach (GameObject enemy in enemyTargetList) { //deal damge Debug.Log("Deal Damage"); enemy.GetComponent <MonsterHealth>().TakeDamage(18); Vector3 damageSystemPosition = Vector3.zero; damageSystemPosition.y += .5f; GameObject damageSystem = (GameObject)Instantiate(damageObject); damageSystem.transform.parent = enemy.transform; damageSystem.transform.localPosition = damageSystemPosition; damageSystem.transform.localScale = new Vector3(1, 1, 1); MonsterHealth health = enemy.GetComponent <MonsterHealth>(); if (health != null) { health.TakeDamage(damage * damageMultiplier); } } }
public void SecondSkill() { m_targetObj.Clear(); float forwardRange = 3.0f; Collider[] targets = Physics.OverlapBox(transform.position + transform.forward * forwardRange, new Vector3(1, 1, 3.0f), transform.rotation); foreach (Collider col in targets) { if (col.gameObject.tag == "Monster" || col.gameObject.tag == "Boss") { if (m_collider == null) { m_collider = col.GetComponent <Collider>(); } int damage = (int)(m_totalStr * FindSkillInfo("Skill2", m_SL2)); MonsterHealth health = col.GetComponent <MonsterHealth>(); health.DecreaseHp(damage, CriticalCheck(), gameObject); if (col.tag == "Monster") { health.GetComponent <MonsterController>().PlayerAttackCheck(gameObject); } } } }
public void SkillOne() { /* * mesh 사용할때 참고 * Shader sh = Shader.Find(""); * Material mat; * mat.shader = sh; */ m_targetObj.Clear(); Collider[] targets = Physics.OverlapSphere(transform.position, firstDistance); foreach (Collider col in targets) { if (col.gameObject.tag == "Monster" || col.gameObject.tag == "Boss") { FirstSkillRange(col.transform); } } if (m_targetObj.Count != 0) { foreach (GameObject g in m_targetObj) { if (m_collider == null) { m_collider = g.GetComponent <Collider>(); } int damage = (int)(m_totalStr * FindSkillInfo("Skill1", m_SL1)); MonsterHealth health = g.GetComponent <MonsterHealth>(); health.DecreaseHp(damage, CriticalCheck(), gameObject); if (g.tag == "Monster") { health.GetComponent <MonsterController>().PlayerAttackCheck(gameObject); } } } }
// Use this for initialization void Start () { mHealth = gameObject.GetComponentInParent<MonsterHealth> (); }
// Start is called before the first frame update void Start() { monsterHealth = GetComponent <MonsterHealth>(); isAlreadyTrigger = false; }