public bool ChangeStateToHeal() { Robot_Status temptarget = null; foreach (GameObject go in UsefulFunctions.GetNearbyRobotWithBoxColliderArray(parent_object.transform.position, robot_local_sprite_size * 4)) { if (go != parent_object) { temptarget = go.GetComponent <Robot_Status>(); if (temptarget.GetHealthPoint() < temptarget.GetBaseHealthPoint() && (temptarget.state_manager.states_enum != ROBOT_STATES.DEAD && temptarget.state_manager.states_enum != ROBOT_STATES.OUTOFENERGY)) { ally_target = go; break; } else { ally_target = null; } } } if (ally_target != null && Random.Range(1, 101) < parent_object.GetComponent <Robot_Status>().GetChanceToHeal()) { SetCurrentState(ROBOT_STATES.HEAL); return(true); } return(false); }
// Update is called once per frame void Update() { if (baseUIcs.target != null || monsterUIcs.target != null) { this_obj.SetActive(false); } else { this_obj.SetActive(true); } //左クリックした奴を顔を拡大して出す。 // 左クリックされた場所のオブジェクトを取得 // Left Click if (Input.GetMouseButtonDown(0)) { Vector2 tapPoint = Camera.main.ScreenToWorldPoint(Input.mousePosition); Collider2D collition2d = Physics2D.OverlapPoint(tapPoint); if (collition2d && collition2d.gameObject.tag == "Robot") { //BaseUIStateがtrueだったらBaseUIを消す if (baseUIcs.target != null) { Destroy(baseUIcs.target); } else if (monsterUIcs.target != null) { Destroy(monsterUIcs.target); } //すでにRobotのUIが表示されていたら消す if (statusClone != null) { Destroy(target); Destroy(statusClone); } _getObject = collition2d.transform.gameObject; //Make clone of robot clicked //クリックしたロボットのcloneを作る //ロボットの性格を読み取る statusClone = Instantiate(_getObject, new Vector2(-40.0f, clonePotision.y), Quaternion.identity); statusClone.gameObject.tag = "clone"; robot_status = _getObject.GetComponent <Robot_Status>(); if (!deadState) { viewNum = (int)robot_status.GetMood(); } else { viewNum = 6; } target = Instantiate(viewUI[viewNum], new Vector2(clonePotision.x, clonePotision.y), Quaternion.identity); } } //scripts取得 //HP Energyリアルタイム更新 //cloneのスピード0 if (_getObject != null) { robot_status = _getObject.GetComponent <Robot_Status>(); if (statusClone != null) { clone_status = statusClone.GetComponent <Robot_Status>(); //target clone_status.speed_point = 0.0f; //hp energy test clone_status.SetHealthPoint(robot_status.GetHealthPoint()); clone_status.SetEnergyPoint(robot_status.GetEnergyPoint()); } } //ステータスリアルタイム更新 if (robot_status != null) { //Get Status Here hp_point = robot_status.GetHealthPoint(); energy_point = robot_status.GetEnergyPoint(); personality_point = robot_status.GetPersonality(); mood_point = robot_status.GetMood(); atk_point = robot_status.GetAttackPoint(); spd_point = robot_status.GetSpeedPoint(); int_point = robot_status.GetMagicPoint(); luk_point = robot_status.GetLuckPoint(); def_point = robot_status.GetDefencePoint(); uihp_point = (int)hp_point; uienergy_point = (int)robot_status.GetEnergyPoint(); if ((hp_point <= 0 || energy_point <= 0)) { textDead = "DEAD"; viewNum = 6; deadState = true; } else { textDead = personality_point.ToString(); deadState = false; } Debug.Log(viewNum); //Text statusText[(int)STATUS.PERSONALITY].text = ":" + textDead; statusText[(int)STATUS.MOOD].text = ":" + mood_point; statusText[(int)STATUS.ATK].text = "ATK:" + atk_point.ToString(); statusText[(int)STATUS.SPD].text = "SPD:" + spd_point.ToString(); statusText[(int)STATUS.INT].text = "MAG:" + int_point.ToString(); statusText[(int)STATUS.LUK].text = "LCK:" + luk_point.ToString(); statusText[(int)STATUS.DEF].text = "DEF:" + def_point.ToString(); statusText[(int)STATUS.HP].text = "HELTH" + uihp_point.ToString() + "/" + robot_status.GetBaseHealthPoint(); statusText[(int)STATUS.ENERGY].text = "ENERGY" + uienergy_point.ToString() + "/" + robot_status.GetBaseEnergyPoint(); } }