public void Update() { // 마우스 클릭시 상태 변환 if (Input.GetMouseButtonDown(0)) { // 상태 변동 //if (CurrntState == PlayerState.IDLE) SetState(PlayerState.Run); //else SetState(PlayerState.IDLE); // 클릭시 선이 보임 Ray r = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit rayhit; if (Physics.Raycast(r, out rayhit, 10000.0f, clickLayer)) { if (rayhit.transform.gameObject.layer == 9) { _marker.position = rayhit.point; SetState(PlayerState.Run); } else if (rayhit.transform.gameObject.layer == 10) { GameLib.Log(this, "Monster"); _target = rayhit.transform; SetState(PlayerState.Chase); } _marker.position = rayhit.point; // 마커를 가져오는 로직. } } }
private void Update() { GameLib.Log(this, "GoblinIDLE"); time += Time.deltaTime; if (time > idleTime) { _manager.SetState(MonsterStates.Patrol); } }
private void Update() { GameLib.Log(this, "MonsterAttack"); if ((Vector3.Distance(_manager.playerTran.position, transform.position) >= _manager.MonsterState.AttackRange)) { _manager.SetState(MonsterStates.Chase); return; } transform.LookAt(_manager.playerTran); }
public void Update() { //Plane[] ps = GeometryUtility.CalculateFrustumPlanes(_manager.sight); //bool _isDestected = GeometryUtility.TestPlanesAABB(ps, _manager._testTarget.bounds); //if (_isDestected) //{ // Debug.Log(_manager._testTarget.bounds); // // GameLib.Log() //} Vector3 dest = _manager.Marker.transform.position; dest.y = 0.0f; Vector3 playerPos = transform.position; playerPos.y = 0.0f; if (Vector3.Distance(dest, playerPos) < Mathf.Epsilon) { _manager.SetState(PlayerState.IDLE); return; } GameLib.Log(this, "RUN"); //_marker.Maerker.postion; // 이동. Vector3 deltaMove = Vector3.zero; Vector3 moveDir = _manager.Marker.position - transform.position; moveDir.y = 0.0f; Vector3 nextMove = Vector3.MoveTowards(transform.position, _manager.Marker.position, _manager.playerState.moveSpeed * Time.deltaTime); deltaMove = nextMove - transform.position; deltaMove += Physics.gravity * Time.deltaTime; _manager.CC.Move(deltaMove); // 방향 전환 if (moveDir != Vector3.zero) { transform.rotation = Quaternion.RotateTowards(transform.rotation, Quaternion.LookRotation(moveDir), _manager.playerState.turnSpeed * Time.deltaTime); } // Quaternion playerRotation = Quaternion.LookRotation(Vector3 rot(transform.rotation, 0.0f, 0.0f)); }
public void SetState(PlayerState newState) { if (_isinit) { _state[_currentState].enabled = false; _state[_currentState].EndState(); GameLib.Log(this, "False"); } _currentState = newState; _state[_currentState].BeginState(); _state[_currentState].enabled = true; // 지정한 친구만 로그를 보여준다. _anim.SetInteger("CurrentState", (int)_currentState); }
public void AttackCheck() { if (_manager.CurrntState != PlayerState.Attack) { return; } GameLib.Log(this, "call Attack Check"); // 타겟에 대한 스테이트를 가져온다. CharacterState targetState = _manager.target.GetComponent <CharacterState>(); playerState.ProcessDamage(_manager.playerState, targetState); }
void HitCheck() { GameLib.Log(this, "HitCheck"); // 효율 쓰레기니까 사용하지 않으면 좋다. // transform.root.SendMessage("AttackCheck"); PlayerAttack attackState = _manager.CurrentSateComponent as PlayerAttack; if (attackState != null) { attackState.AttackCheck(); } }
public void TakeDamage(CharacterState from, float damage) { _hp = Mathf.Clamp(_hp - damage, 0, 10); if (_hp <= 0) { if (LastHitBy == null) { LastHitBy = from; } GetComponent <IFSMManager>().SetDeadState(); from.GetComponent <IFSMManager>().NotifyTargetKilled(); GameLib.Log(this, name + "IS KILLED BY" + LastHitBy.name); } }
private void Update() { GameLib.Log(this, "MonsterPATROL"); if (GameLib.DetectCharacter(_manager.sight, _manager.playercc)) { _manager.SetState(MonsterStates.Chase); return; } if ((Vector3.Distance(destination, transform.position) < 0.1f)) { _manager.SetState(MonsterStates.IDLE); return; } _manager.CC.CKMove(destination, _manager.MonsterState); }
private void Update() { GameLib.Log(this, "GoblinChase"); if (!GameLib.DetectCharacter(_manager.sight, _manager.playercc)) { _manager.SetState(MonsterStates.IDLE); return; } if (GameLib.DetectCharacter(_manager.sight, _manager.playercc)) { if ((Vector3.Distance(_manager.playerTran.position, transform.position) < _manager.MonsterState.AttackRange)) { _manager.SetState(MonsterStates.Attack); return; } } _manager.CC.CKMove(_manager.playerTran.position, _manager.MonsterState); }
protected override void Update() { base.Update(); Vector3 dest = _manager.target.transform.position; dest.y = 0.0f; Vector3 playerPos = transform.position; playerPos.y = 0.0f; if (Vector3.Distance(dest, playerPos) < 2.0f) { _manager.SetState(PlayerState.Attack); return; } GameLib.Log(this, "CHASE"); //_marker.Maerker.postion; // 이동. Vector3 deltaMove = Vector3.zero; Vector3 moveDir = _manager.Marker.position - transform.position; moveDir.y = 0.0f; Vector3 nextMove = Vector3.MoveTowards(transform.position, _manager.Marker.position, _manager.playerState.moveSpeed * Time.deltaTime); deltaMove = nextMove - transform.position; deltaMove += Physics.gravity * Time.deltaTime; _manager.CC.Move(deltaMove); // 방향 전환 if (moveDir != Vector3.zero) { transform.rotation = Quaternion.RotateTowards(transform.rotation, Quaternion.LookRotation(moveDir), _manager.playerState.turnSpeed * Time.deltaTime); } // Quaternion playerRotation = Quaternion.LookRotation(Vector3 rot(transform.rotation, 0.0f, 0.0f)); }
private void Awake() { // 레이어마스크에서 가져오는 방법. clickLayer = (1 << 9) + (1 << 10); // name 프레이어 라는 함수를 제공해줌. _marker = GameObject.FindGameObjectWithTag("Marker").transform; if (null == _marker) { GameLib.Log(this, "Marker Error"); return; } _cc = GetComponent <CharacterController>(); _playerState = GetComponent <playerState>(); // _animation = GetComponentInChildren<Animation>(); _anim = GetComponentInChildren <Animator>(); // 카메라로 인한 인식을 위해 설정. _sight = GetComponentInChildren <Camera>(); _sight.aspect = sightaspectRatio; PlayerState[] stateValue = (PlayerState[])System.Enum.GetValues(typeof(PlayerState)); // 시스템 정보를 배열형식으로 요청하여 가져옴. foreach (var s in stateValue) // var 대신 PlayerState 써도됨. var가 뭔지 알아보기. { System.Type FSMType = System.Type.GetType("Player" + s.ToString()); FSMState state = (FSMState)GetComponent(FSMType); if (null == state) { state = (FSMState)gameObject.AddComponent(FSMType); // 만약에 컴포넌트가 없으면 넣어버린다. } // 예외값 처리인듯 // 미리 NULL인지 아닌지 해주는게 좋기는 함. _state.Add(s, state); //GameLib.Log(this ,s.ToString("G")); state.enabled = false; // 로그를 전부다 꺼준다. } }
private void Awake() { GameLib.Log(this, "Awake"); }
private void Update() { GameLib.Log(this, "MonsterDead"); }
private void Update() { GameLib.Log(this, "IDLE"); }
private void Update() { GameLib.Log(this, "GoblinDead"); }