Inheritance: MonoBehaviour
Esempio n. 1
0
        public void DropItem(EntityManager entity)
        {
            if (spawnPoint == null)
            {
                spawnPoint = transform;
            }
            GameObject      item            = Instantiate(itemToDrop, spawnPoint.position, Quaternion.identity);
            FallingBehavior fallingBehavior = item.GetComponent <FallingBehavior>();

            if (fallingBehavior == null)
            {
                Debug.LogWarning("the item does not have a falling behavior");
            }
            else
            {
                fallingBehavior.Initialize(spawnDirection.normalized * 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}!");
            }
        }
Esempio n. 3
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;
            }
        }