예제 #1
0
        protected override bool IsColliding()
        {
            if (base.IsColliding())
            {
                foreach (var activeColliderPair in m_ActiveColliderPairs)
                {
                    if (Physics.ComputePenetration(activeColliderPair.Item1, activeColliderPair.Item1.transform.position, activeColliderPair.Item1.transform.rotation,
                                                   activeColliderPair.Item2, activeColliderPair.Item2.transform.position, activeColliderPair.Item2.transform.rotation,
                                                   out Vector3 direction, out _))
                    {
                        m_ControlMovement.Collision(direction);

                        if (Vector3.Dot(direction, m_CurrentDirection) < -0.0001f)
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
예제 #2
0
    private void FixedUpdate()
    {
        if (_wayList.Count <= 0)
        {
            _isMove = false;
        }

        if (StaticLevelManager.IsGameFlove)
        {
            if (_isMove)
            {
                _targetHexagon = _wayList[0];

                if (_targetHexagon.TypeHexagon == 2 && gameObject.layer == 8)
                {
                    gameObject.layer = 11;
                }
                else if (_targetHexagon.TypeHexagon == 0 && gameObject.layer == 11)
                {
                    gameObject.layer = 8;
                }

                transform.position = Vector2.MoveTowards(transform.position, _targetHexagon.transform.position, _speedMove);

                Vector2 NextPos = (Vector2)transform.position + (Vector2)(_targetHexagon.transform.position - transform.position).normalized * 1.8f;

                Control.Collision(NextPos);

                if (_wayList.Count > 0)
                {
                    if (((Vector2)transform.position - (Vector2)_wayList[0].transform.position).magnitude <= 0.01f)
                    {
                        _wayList.Remove(_wayList[0]);
                    }
                }
            }
            else
            {
                if (((Vector2)transform.position - Control.HexagonMain().position).magnitude >= 0.01f)
                {
                    transform.position = Vector2.MoveTowards(transform.position, Control.HexagonMain().position, _speed);
                }

                if (_isBypass)
                {
                    if (_wayList.Count > 0)
                    {
                        IMove move = _currentPos.ObjAbove;
                        if ((move == null))
                        {
                            if (_currentPos.IsFree)
                            {
                                _isMove = true;
                            }
                        }
                        else if (!move.IsGo())
                        {
                            IMove enemy = Control.Target() != null?Control.Target() : null;

                            WayBypass(_wayList[_wayList.Count - 1], enemy, _currentPos.ObjAbove);
                        }
                    }
                }
            }
        }
        else
        {
            if (((Vector2)transform.position - Control.HexagonMain().position).magnitude >= 0.01f)
            {
                transform.position = Vector2.MoveTowards(transform.position, Control.HexagonMain().position, _speed);
            }
        }
    }