// 魂に戻る処理 private void ReturnToSoul(ActorController actor_controller) { if (return_ == false || actor_controller.GetActorType() == ActorController.ActorType.kSoul) { return; } if (actor_controller.GetActorParameter().CanSwimming == true && is_swimming_ == true) { is_swimming_ = false; return; } // Soul soul_.SetBrainType(ActorController.BrainType.kPlayer); var soul_state = soul_.gameObject.AddComponent <SoulReturnState>(); soul_state.SetSoulAmount(soul_amount_); soul_state.transform.SetPositionAndRotation(transform.position, transform.rotation); soul_state.SetReturnPoint(transform.position + transform.right * 2f); soul_.ChangeState(soul_state); // This ChangeStateToNpc(actor_controller); }
// 乗り移ってるときに魂ゲージを減る private void ReduceSoulAmount(ActorController actor_controller) { soul_amount_ -= actor_controller.GetActorParameter().SoulDamage *Time.deltaTime; SoulGaugeController.Instance.SetLifeRate(soul_amount_ / kMaxSoulAmount); if (soul_amount_ <= 0f) { soul_amount_ = 0f; if (actor_controller.GetActorType() == ActorController.ActorType.kSoul) { CameraController camera = Camera.main.GetComponent <CameraController>(); if (camera != null) { camera.SetTarget(null); } if (MinimapSystem.Instance) { MinimapSystem.Instance.Camera.SetTarget(null); } Destroy(gameObject); GameFlowController.Instance.GameOver(); } } }
// 乗り移る処理 private void RelyOnTarget(ActorController actor_controller) { if (!rely_ || rely_detector_.Target == null) { return; } if (actor_controller.GetActorType() != ActorController.ActorType.kSoul) {// 魂に戻ってから乗り移る soul_.SetBrainType(ActorController.BrainType.kPlayer); var soul_rely_state = soul_.gameObject.AddComponent <SoulRelyState>(); soul_rely_state.transform.SetPositionAndRotation(transform.position, transform.rotation); soul_rely_state.SetSoulAmount(soul_amount_); soul_rely_state.SetTarget(rely_detector_.Target.GetComponent <ActorController>()); soul_.ChangeState(soul_rely_state); // This ChangeStateToNpc(actor_controller); } else { // Target var soul_rely_state = gameObject.AddComponent <SoulRelyState>(); soul_rely_state.SetSoulAmount(soul_amount_); soul_rely_state.SetTarget(rely_detector_.Target.GetComponent <ActorController>()); actor_controller.ChangeState(soul_rely_state); } }
// 今の器をNpcに切り替える protected void ChangeStateToNpc(ActorController actor_controller) { gameObject.tag = "Npc"; actor_controller.SetBrainType(ActorController.BrainType.kNPC); switch (actor_controller.GetActorType()) { case ActorController.ActorType.kAnonymous: actor_controller.ChangeState(gameObject.AddComponent <NpcDemoState>()); break; case ActorController.ActorType.kGolem: actor_controller.ChangeState(gameObject.AddComponent <NpcDemoState>()); break; case ActorController.ActorType.kCarbuncle: actor_controller.ChangeState(gameObject.AddComponent <NpcDemoState>()); break; case ActorController.ActorType.kSoul: actor_controller.ChangeState(gameObject.AddComponent <NpcSoulState>()); break; default: break; } }
public void SetTarget(Transform target) { if (target_ == target) { return; } target_ = target; if (target_ != null) { actor_controller_ = target_.GetComponent <ActorController>(); var type = actor_controller_.GetActorType(); if (type == ActorController.ActorType.kAnonymous) { offset_ = kAnonymousOffset; } else if (type == ActorController.ActorType.kCarbuncle) { offset_ = kCarbuncleOffset; } else { offset_ = kGolemOffset; } } }
public void RegisterActor(ActorController actor_controller) { var minimap_actor = GameObject.Instantiate(kMinimapActorPrefab, kMinimapMask); var minimap_actor_image = minimap_actor.GetComponent <Image>(); // 色 switch (actor_controller.GetActorType()) { case ActorController.ActorType.kAnonymous: minimap_actor_image.color = kAnonymousIconColor; break; case ActorController.ActorType.kGolem: minimap_actor_image.color = kGolemIconColor; break; case ActorController.ActorType.kCarbuncle: minimap_actor_image.color = kCarbuncleIconColor; break; default: break; } hashtable_[actor_controller] = minimap_actor; }
/// <summary> /// 火に入った処理 /// </summary> /// <param name="actor_controller"></param> public override void Burn(ActorController actor_controller) { if (actor_controller.GetActorType() != ActorController.ActorType.kSoul) { return; } // 魂を燃やす soul_amount_ = Mathf.Clamp(soul_amount_ - actor_controller.GetActorParameter().FireDamage , 0f, kMaxSoulAmount); }
/// <summary> /// 初期化処理 /// </summary> /// <param name="actor_controller"></param> public override void Init(ActorController actor_controller) { if (soul_ == null) {// 魂のコントローラを保存しておく soul_ = actor_controller; } CameraController camera = Camera.main.GetComponent <CameraController>(); if (camera != null) { camera.SetTarget(transform); } if (MinimapSystem.Instance) { MinimapSystem.Instance.Camera.SetTarget(transform); } animator_ = GetComponentInChildren <Animator>(); gameObject.tag = "Player"; var rely_detector_object = new GameObject("RelyDetector"); rely_detector_object.transform.SetParent(transform); rely_detector_ = rely_detector_object.AddComponent <RelyDetector>(); var parameter = actor_controller.GetActorParameter(); nav_mesh_agent_ = GetComponent <NavMeshAgent>(); nav_mesh_agent_.velocity = Vector3.zero; nav_mesh_agent_.angularSpeed = parameter.TurnSpeed; nav_mesh_agent_.updatePosition = true; nav_mesh_agent_.updateRotation = false; var rigidbody = GetComponent <Rigidbody>(); rigidbody.angularVelocity = Vector3.zero; rigidbody.velocity = Vector3.zero; if (kActorLifeUiPrefab == null) { kActorLifeUiPrefab = (GameObject)Resources.Load("Prefabs/ActorLifeUi", typeof(GameObject)); } if (actor_controller.GetActorType() != ActorController.ActorType.kSoul) {// Life ui life_ui_ = GameObject.Instantiate(kActorLifeUiPrefab).GetComponent <ActorLifeUiController>(); life_ui_.SetTarget(transform); } }