Пример #1
0
        /// <summary>
        /// Pops the length.
        /// </summary>
        /// <param name="jumpBeh">The jump beh.</param>
        /// <exception cref="System.InvalidOperationException">jump required after consuming metered field</exception>
        internal void PopLength(JumpBehavior jumpBeh = JumpBehavior.ThrowIfJumpNeeded)
        {
            switch (jumpBeh)
            {
            case JumpBehavior.ThrowIfJumpNeeded:
                if (this.MaxBytes != 0)
                {
                    throw new InvalidOperationException("jump required after consuming metered field");
                }
                else
                {
                    int nextOffset = this.Pos - this.next.Pos;
                    this.MaxBytes = this.next.MaxBytes - nextOffset;
                    this.next     = this.next.next;
                }

                break;

            case JumpBehavior.AdjustPosition:
            {
                int nextOffset = this.Pos - this.next.Pos;
                this.MaxBytes = this.next.MaxBytes - nextOffset - this.MaxBytes;
                this.next     = this.next.next;
            }

            break;

            case JumpBehavior.PopPosition:
                this.Pos      = this.next.Pos;
                this.MaxBytes = this.next.MaxBytes;
                this.next     = this.next.next;

                break;
            }
        }
Пример #2
0
 public MovementInput(MonoBehaviour root, JumpBehavior jump, MovementBehavior move, string horzName = DEFAULT_HORZ_AXIS_NAME, string vertName = DEFAULT_VERT_AXIS_NAME)
 {
     rootObject        = root;
     controller        = root.GetComponent <CharacterController>();
     horzInputAxisName = horzName;
     vertInputAxisName = vertName;
 }
        private CutOffBehavior ConvertCOC2COB(CutOffCondition coc)
        {
            CutOffBehavior cob = new CutOffBehavior();

            cob.Condition.Parameter = coc.Parameter;
            cob.Condition.Mark      = coc.Mark;
            cob.Condition.Value     = coc.Value;
            JumpBehavior jpb = new JumpBehavior();

            jpb.JumpType = coc.JumpType;
            jpb.Index    = coc.Index;
            cob.JumpBehaviors.Add(jpb);
            return(cob);
        }
Пример #4
0
    void Awake()
    {
        // Add event subscription with callback
        GameManager.onGameStartEvent  += EnablePlayer;
        GameManager.onKnightsWinEvent += Celebrate;
        animator      = gameObject.GetComponent <Animator>();
        healthManager = GetComponent <HealthManager>();
        inputManager  = GetComponent <KnightInputManager>();
        soundManager  = GetComponent <SoundManager>();

        // Get Behaviors
        moveBehavior       = GetComponent <MoveBehavior>();
        attackBehavior     = GetComponent <AttackBehavior>();
        blockBehavior      = GetComponent <BlockBehavior>();
        jumpBehavior       = GetComponent <JumpBehavior>();
        takeDamageBehavior = GetComponent <TakeDamageBehavior>();

        //Invoke("Die", 5);
    }
        public override async Task ExecuteAsync(ExecutionContext context, ExecutionBranchContext branchContext)
        {
            await base.ExecuteAsync(context, branchContext);

            MovementType = (MovementType)context.Reader.Read <uint>();

            switch (MovementType)
            {
            case MovementType.Ground:
                await GroundBehavior.ExecuteAsync(context, branchContext);

                return;

            case MovementType.Jump:
                await JumpBehavior.ExecuteAsync(context, branchContext);

                return;

            case MovementType.Falling:
                await FallingBehavior.ExecuteAsync(context, branchContext);

                return;

            case MovementType.DoubleJump:
                await DoubleJumpBehavior.ExecuteAsync(context, branchContext);

                return;

            case MovementType.Jetpack:
                await JetpackBehavior.ExecuteAsync(context, branchContext);

                return;

            case MovementType.Stunned:
                return;

            default:
                throw new Exception($"Invalid {nameof(MovementType)}! Got {MovementType}!");
            }
        }
Пример #6
0
        public override async Task ExecuteAsync(ExecutionContext context, ExecutionBranchContext branchContext)
        {
            await base.ExecuteAsync(context, branchContext);

            MovementType = (MovementType)context.Reader.Read <uint>();

            context.Writer.Write((uint)MovementType);

            switch (MovementType)
            {
            case MovementType.Ground:
                await GroundBehavior.ExecuteAsync(context, branchContext);

                return;

            case MovementType.Jump:
                await JumpBehavior.ExecuteAsync(context, branchContext);

                return;

            case MovementType.Falling:
                await FallingBehavior.ExecuteAsync(context, branchContext);

                return;

            case MovementType.DoubleJump:
                await DoubleJumpBehavior.ExecuteAsync(context, branchContext);

                return;

            case MovementType.Jetpack:
                await JetpackBehavior.ExecuteAsync(context, branchContext);

                return;

            default:
                return;
            }
        }
Пример #7
0
    public static JumpBehavior CreateJumpBehavior(JumpType type, MonoBehaviour root)
    {
        JumpBehavior toReturn = null;

        switch (type)
        {
        case JumpType.Null:
            toReturn = new NullJump();
            break;

        case JumpType.Single:
            toReturn = new SingleJump(root.GetComponent <CharacterController>())
            {
                StartFallSpeed   = DEFAULT_START_FALL_SPEED,
                TerminalVelocity = DEFAULT_TERMINAL_VELOCITY,
                Gravity          = DEFAULT_GRAVITY,
                JumpForce        = DEFAULT_JUMP_FORCE
            };
            break;

        case JumpType.Double:
            toReturn = new DoubleJump(root.GetComponent <CharacterController>())
            {
                StartFallSpeed   = DEFAULT_START_FALL_SPEED,
                TerminalVelocity = DEFAULT_TERMINAL_VELOCITY,
                Gravity          = DEFAULT_GRAVITY,
                JumpForce        = DEFAULT_JUMP_FORCE
            };
            break;

        default:
            //Only thrown if a new jump type is added and there is no corresponding case.
            throw new NotImplementedException();
            break;
        }
        return(null);
    }
    private void Start()
    {
        theJumpBehaviorController = this.GetComponentInParent <JumpBehavior>();

        jumpSound = this.GetComponent <AudioSource>();
    }
Пример #9
0
 public void SetJumpBehavior(JumpBehavior jumpBehavior)
 {
     _jumpBehaviour = jumpBehavior;
 }
Пример #10
0
 private void Start()
 {
     theJumpBehaviorController = this.GetComponentInParent <JumpBehavior>();
 }
Пример #11
0
 public void JumpObj(JumpBehavior j)
 {
     jump = j;
     jump.jump(forgeJump, obj);
 }
Пример #12
0
        public readonly JumpBehavior _jpb; //为了将其添加到Program里面去(见ProgramViewModel Add),不得不开放给viewmodel。以后再想想有没有别的办法。

        #endregion                         // Fields

        #region Constructor

        public JumpBehaviorViewModel(JumpBehavior jpb)
        {
            _jpb = jpb;
            _jpb.PropertyChanged += _jpb_PropertyChanged;
        }