Ejemplo n.º 1
0
            public void Execute(ref ActorAttribute3 <_Power> attribute3, ref ControlForceDirection controlForceDirection, ref ControlTorqueAngular controlTorqueAngular)
            {
                var scale = 1f;

                if (controlForceDirection.force > 0f)
                {
                    scale -= 0.5f;
                }
                if (controlTorqueAngular.torque > 0f)
                {
                    scale -= 0.25f;
                }

#if ENABLE_UNITY_COLLECTIONS_CHECKS
                if (attribute3.regain < 0f)
                {
                    throw new System.Exception("attribute3.regain < 0f");
                }
#endif
                //value
                attribute3.value += attribute3.regain * scale * fixedDeltaTime;
                if (attribute3.value >= attribute3.max)
                {
                    attribute3.value = attribute3.max;
                }
            }
Ejemplo n.º 2
0
            public void Execute(ref ControlForceDirection controlForceDirection, ref ShipForceControl shipForceControl,
                                [ReadOnly] ref ShipControlInfo shipControlData, [ReadOnly] ref ShipMoveInput shipMoveInput, [ReadOnly] ref ActorAttribute1 <_VelocityLevel> shipVelocityLevel, [ReadOnly] ref Rotation rotation)
            {
                shipForceControl.moveDirection = float3.zero;

                if (shipMoveInput.lost)
                {
                    shipForceControl.noControlTime = 0f;
                    controlForceDirection.force    = 0f;
                    return;
                }


                var shipForward = math.forward(rotation.Value);
                var shipBack    = -shipForward;
                var shipLeft    = math.mul(rotation.Value, new float3(-1f, 0f, 0f));
                var shipRight   = -shipLeft;


                //
                var velocityLevel = (int)shipVelocityLevel.value;
                var velocity      = shipControlData.getVelocity(velocityLevel);

                if (shipMoveInput.accelerate == false)
                {
                    if (shipMoveInput.moveForward)
                    {
                        shipForceControl.moveDirection = shipForward * shipControlData.forwardScale;
                    }
                    else if (shipMoveInput.moveBack)
                    {
                        shipForceControl.moveDirection = shipBack * shipControlData.backScale;
                    }

                    if (shipMoveInput.moveLeft)
                    {
                        shipForceControl.moveDirection += shipLeft * shipControlData.leftRightScale;
                    }
                    else if (shipMoveInput.moveRight)
                    {
                        shipForceControl.moveDirection += shipRight * shipControlData.leftRightScale;
                    }

                    if ((shipMoveInput.moveForward || shipMoveInput.moveBack) &&
                        (shipMoveInput.moveLeft || shipMoveInput.moveRight))
                    {
                        shipForceControl.moveDirection *= shipControlData.moveComboScale;
                    }


                    var force = velocity.force;
                    if (shipForceControl.moveDirection.Equals(default))