示例#1
0
        // PRAGMA MARK - Public Interface
        public void Init(Direction facingDirection, Vector3[] worldPatrolPoints)
        {
            if (worldPatrolPoints == null)
            {
                throw new ArgumentNullException();
            }

            if (worldPatrolPoints.Length <= 1)
            {
                throw new ArgumentException("worldPatrolPoints - should have two points or more!");
            }

            facingDirection_ = facingDirection;
            rotationContainer_.transform.rotation = Quaternion.Euler(0.0f, DirectionUtil.AngleInDegreesFrom(Direction.UP, facingDirection_), 0.0f);
            patrolDirection_   = EnumUtil.Random <HorizontalDirection>();
            worldPatrolPoints_ = worldPatrolPoints;

            int startIndex = patrolDirection_ == HorizontalDirection.RIGHT ? 0 : worldPatrolPoints_.Length - 1;

            this.transform.position = worldPatrolPoints_[startIndex];
        }