public CharacterState GetPlayerStateFromType( PlayerType type ) { CharacterState state = null; switch (type) { case PlayerType.PLAYER: state = new NormalState( gameObject ); break; case PlayerType.MONSTER: state = new MonsterState( gameObject ); break; case PlayerType.AI_MONSTER: state = new AIMonsterState( gameObject ); break; case PlayerType.AI_PLAYER: state = new AIState( gameObject ); break; } return state; }
void Start() { // リソースロード autoLockOnIconSprite = Resources.Load<Sprite>("Sprites/AutoLockOnIcon"); manualLockOnIconSprite = Resources.Load<Sprite>("Sprites/ManualRockOnIcon"); barrierPrefab = Resources.Load<GameObject>("Prefabs/Effects/Barrier/Barrier"); cameraRigPrefab = Resources.Load<GameObject>("Prefabs/Player/CameraRig"); characterController = GetComponent<CharacterController>(); GameObject cameraRig = GameObject.FindGameObjectWithTag(TagName.CameraController); if (cameraRig == null) { cameraRig = Instantiate(cameraRigPrefab); } cameraController = cameraRig.GetComponent<CameraController>(); cameraController.target = transform; //playerTrampled = GetComponentInChildren<PlayerTrampled>(); playerCamera = new PlayerCamera(cameraController, horizontalRotationSpeed, verticalRotationSpeed); animator = GetComponentInChildren<Animator>(); // アニメーションをコントロールするためのAnimatorを子から取得 meshRoot = animator.transform; // Animatorがアタッチされているのがメッシュのはずだから // ジャンプできる高さから初速を計算(√2gh) jumpPower = Mathf.Sqrt(2.0f * -Physics.gravity.y * jumpHeight); highJumpPower = Mathf.Sqrt(2.0f * -Physics.gravity.y * highJumpHeight); if (autoLockOnArea == null) { Debug.Log(typeof(ContainedObjects) + " が見つかりません"); } speedID = Animator.StringToHash("Speed"); isJumpID = Animator.StringToHash("IsJump"); isGroundedID = Animator.StringToHash("IsGrounded"); isTrampledID = Animator.StringToHash("IsTrampled"); isFallID = Animator.StringToHash("IsFall"); isDamageID = Animator.StringToHash("IsDamage"); attackFlow = new PlayerAttackFlow(animator); // 初期状態へ currentState = new NormalState(this); // ロックオンアイコン用のCanvas UICanvasGenerator.FollowIconCanvasGenerate(); GameObject lockOnIconPrefab = Resources.Load<GameObject>("Prefabs/UI/LockOnIcon"); lockOnIcon = Instantiate(lockOnIconPrefab).GetSafeComponent<FollowIcon>(); lockOnIcon.Hide(); powerPointPrefab = Resources.Load<GameObject>("Prefabs/Effects/PowerPoint"); // 結界の点を生成するためのスクリプトをアタッチ powerPointCreator = gameObject.AddComponent<PowerPointCreator>(); }